2014-12-30 33 views
0

我有來電接收方,我想在收到廣播時清除通話通知,我該怎麼辦?呼叫接收方清除來電通知

public class IncommingCallReceiver extends BroadcastReceiver 
{ 
    public void onReceive(final Context context, final Intent intent) 
    { 
     //some method 
    } 
} 

回答

1

使用ID

NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); 
notificationManager.cancel(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

+0

感謝post.but我不知道該怎麼創建一個ID取消通知是通話通知ID? – Ali