我有来电接收器,我想在收到广播时清除来电通知,我该怎么办?
public class IncommingCallReceiver extends BroadcastReceiver
{
public void onReceive(final Context context, final Intent intent)
{
//some method
}
}
最佳答案
使用 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
关于java - 清除来电接收器上的来电通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27706642/