[BroadcastReceiver(Enabled = true)]
[IntentFilter(new[] { "com.example.ACTION" })]
public class MyBroadcastReceiver : BroadcastReceiver
{
public override void OnReceive(Context context, Intent intent)
{
//处理接收到的广播
}
}
var intent = new Intent("com.example.ACTION");
SendBroadcast(intent);
注意:Intent Action名称必须匹配,以便BroadcastReceiver能够接收到广播。