单击通知按钮后如何关闭状态栏?
我试过这个,但我有一个例外:
java.lang.NoSuchMethodException: collapse []
at java.lang.Class.getConstructorOrMethod(Class.java:460)
at java.lang.Class.getMethod(Class.java:915)
...
我的代码:
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));
}