gt; <intent-filter> <!-- 和Intent中的action对应 --> <action android:name="com.forrest.action.mybroadcast"/> </intent-filter> </receiver> 2)在代码中注册 Java代码 IntentFilter filter = new IntentFilter("com.forrest.action.mybroadcast"); // 和广播中Intent的action对应 MyBroadcastReceiver br = new MyBroadcastReceiver(); registerReceiver(new MyBroadcastReceiver(), filter); IntentFilter filter = new IntentFilter("com.forrest.action.mybroadcast"); // 和广播中Intent的action对应 MyBroadcastReceiver br = new MyBroadcastReceiver(); registerReceiver(new MyBroadcastReceiver(), filter); 3)注销 Java代码 unregisterReceiver(br); unregisterReceiver(br); 3. 示例代码 Java代码 public class Receiver1 extends BroadcastReceiver { private Context context; public static final int NOTIFICATION_ID = 10001; public void onReceive(Context context, Intent intent) { this.context = context; showNotification(); } private void showNotification() { Notification notification = new Notification(R.drawable.icon, "来电话啦", System.currentTimeMillis()); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0); notification.setLatestEventInfo(context, "来电话啦嘿嘿", "赶紧接电话,否则误大事了", contentIntent); NotificationManager notificationManager = (NotificationManager) context.getSystemService( android.content.Context.NOTIFICATION_SERVICE); notificationManager.notify(NOTIFICATION_ID, notification); } } public class Receiver1 extends BroadcastReceiver { private Context context; public static final int NOTIFICATION_ID = 10001; public void onReceive(Context context, Intent intent) { this.context = context; showNotification(); } private void showNotification() { Notification notification = new Notification(R.drawable.icon, "来电话啦", System.currentTimeMillis()); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0); notification.setLatestEventInfo(context, "来电话啦嘿嘿", "赶紧接电话,否则误大事了", contentIntent); NotificationManager notificationManager = (NotificationManager) context.getSystemService( android.content.Context.NOTIFICATION_SERVICE); notificationManager.notify(NOTIFICATION_ID, notification); } } Java代码 public class Receiver2 extends BroadcastReceiver {