Android 安卓:有些通知可以取消,有些不可以
我编写了一个android应用程序来取消所有通知Android 安卓:有些通知可以取消,有些不可以,android,android-notifications,Android,Android Notifications,我编写了一个android应用程序来取消所有通知 public class NotificationListener extends NotificationListenerService { @Override public void onNotificationPosted(StatusBarNotification sbn) { Log.d("NotificationListener", "package:" + sbn.getPackageName())
public class NotificationListener extends NotificationListenerService {
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
Log.d("NotificationListener", "package:" + sbn.getPackageName());
Log.d("NotificationListener", "tag:" + sbn.getTag());
Log.d("NotificationListener", "id:" + sbn.getId());
cancelAllNotifications();
}
@Override
public void onNotificationRemoved(StatusBarNotification sbn) {
Log.d("NotificationListener", "remove package:" + sbn.getPackageName());
Log.d("NotificationListener", "remove tag:" + sbn.getTag());
Log.d("NotificationListener", "remove id:" + sbn.getId());
}
}
在AndroidManifest.xml中
<service android:name=".NotificationListener"
android:label="@string/service_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService" />
</intent-filter>
</service>
但我无法取消以下程序包通知:
05-19 10:25:22.422 1289 1307 D NotificationListener : remove package:com.android.providers.downloads
05-19 10:25:22.422 1289 1307 D NotificationListener : remove tag:1:com.android.vending
05-19 10:25:22.422 1289 1307 D NotificationListener : remove id:0
05-19 10:25:20.492 1289 1306 D NotificationListener : package:com.android.settings
05-19 10:25:20.492 1289 1306 D NotificationListener : tag:null
05-19 10:25:20.492 1289 1306 D NotificationListener : id:2130837807
有人知道为什么吗
提前谢谢
Eric某些通知无法取消,因为它们已设置了
标志\u NO\u CLEAR
。检查文档