我有一个接听来电,我希望在收到广播时清除通话通知,我该怎么办?
public class IncommingCallReceiver extends BroadcastReceiver
{
public void onReceive(final Context context, final Intent intent)
{
//some method
}
}
答案 0 :(得分:1)
使用ID
取消通知NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(id);
创建通知时创建ID
// Sets an ID for the notification
int mNotificationId = 001;
// Gets an instance of the NotificationManager service
NotificationManager mNotifyMgr =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// Builds the notification and issues it.
mNotifyMgr.notify(mNotificationId, mBuilder.build());
参考here