private Context context; @Override public void onReceive(Context context, Intent intent) { this.context = context; deleteNotification(); } private void deleteNotification() { NotificationManager notificationManager = (NotificationManager) context.getSystemService(android.content.Context.NOTIFICATION_SERVICE); notificationManager.cancel(Receiver1.NOTIFICATION_ID); } } public class Receiver2 extends BroadcastReceiver { private Context context; @Override public void onReceive(Context context, Intent intent) { this.context = context; deleteNotification(); } private void deleteNotification() { NotificationManager notificationManager = (NotificationManager) context.getSystemService(android.content.Context.NOTIFICATION_SERVICE); notificationManager.cancel(Receiver1.NOTIFICATION_ID); } } Java代码 public class MainActivity extends Activity { private final String ACTION_SEND = "com.forrest.action.SENDMESSAGE", ACTION_CLEAR = "com.forrest.action.CLEARNOTIFICATION"; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ( (Button) findViewById(R.id.btn1) ).setOnClickListener(new OnClickListener() { public void onClick(View v) { clickMenuItem(ACTION_SEND); } }); ( (Button) findViewById(R.id.btn2) ).setOnClickListener(new OnClickListener() { public void onClick(View v) { clickMenuItem(ACTION_CLEAR); } }); } private void clickMenuItem(final String action) { Intent intent = new Intent(action); sendBroadcast(intent); } } public class MainActivity extends Activity { private final String ACTION_SEND = "com.forrest.action.SENDMESSAGE", ACTION_CLEAR = "com.forrest.action.CLEARNOTIFICATION"; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ( (Button) findViewById(R.id.btn1) ).setOnClickListener(new OnClickListener() { public void onClick(View v) { clickMenuItem(ACTION_SEND); } }); ( (Button) findViewById(R.id.btn2) ).setOnClickListener(new OnClickListener() { public void onClick(View v) { clickMenuItem(ACTION_CLEAR); } }); } private void clickMenuItem(final String action) { Intent intent = new Intent(action); sendBroadcast(intent); } } 注册Broadcast Reciver Xml代码 <application android:ic