有没有办法检测通知栏上的事件,例如向左或向右滑动?
答案 0 :(得分:0)
请参阅此http://stackoverflow.com/questions/14671453/catch-on-swipe-to-dismiss-event
它使用DeleteIntent。 DeleteIntent:DeleteIntent是一个PendingIntent对象,可以与通知关联,并在通知被删除时被触发,以太通过:
用户特定的操作 用户删除所有通知。 您可以将Pending Intent设置为广播Receiver,然后执行您想要的任何操作。
Intent intent = new Intent(this, MyBroadcastReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this.getApplicationContext(), 0, intent, 0);
Builder builder = new Notification.Builder(this):
.....您的通知代码 builder.setDeleteIntent(的PendingIntent); MyBroadcastReceiver
public class MyBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
.... code to handle cancel
}
}