单击通知按钮后如何关闭状态栏?
I tried this https://stackoverflow.com/a/15571784/1735077,但我有一个例外:
java.lang.NoSuchMethodException: collapse []
at java.lang.Class.getConstructorOrMethod(Class.java:460)
at java.lang.Class.getMethod(Class.java:915)
...
My code:
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.icon)
.setContentTitle("Sync Failed")
.setContentText("Lorem ipsum dolor sit amet")
.setStyle(new NotificationCompat.BigTextStyle().bigText("Lorem ipsum dolor sit amet"))
.addAction(R.drawable.change, "Change Pass", pChangePass)
.addAction(R.drawable.remove, "Ignore", pIgnore)
.setAutoCancel(false);
mNotificationManager.notify(accountUnique, builder.build());
在NotificationIntent类中
@Override
public void onReceive(Context context, Intent intent) {
int notificationID = intent.getExtras().getInt("NOT_ID");
this.callbackContext = StatusBarNotification.getCallback();
this.mNotificationManager = StatusBarNotification.getNotificationManager();
this.mNotificationManager.cancel(notificationID);
this.callbackContext.success(returnJSON(intent));
}
以下解决方案应该更简单,并且不使用非公共 API:
Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
context.sendBroadcast(it);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)