本文介绍了如何设置通知明确自己的点击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置我的通知,明确自己的点击?

我已经设置 autoCancel(真),但它不能正常工作

我的code:

 通知N =新Notification.Builder(本)
                .setContentTitle(更新为你)
                .setContentText(请点击这里查看更新信息)
                .setLargeIcon(BitmapFactory.de codeResource(this.getResources()
                                                           R.drawable.ic_launcher))
                .setSmallIcon(R.drawable.ic_launcher)
                .setContentIntent(PLIST)
                .setAutoCancel(真)
                .addAction(R.drawable.ic_read,读,$ P $垫)
                .addAction(R.drawable.ic_list,所有更新,PLIST)
                。建立();NotificationManager notificationManager =
                      (NotificationManager)getSystemService(NOTIFICATION_SERVICE);notificationManager.notify(0,n)的;


解决方案

使用的

  n.flags | = Notification.FLAG_AUTO_CANCEL;

How to set my notification to clear itself on click?

I've set autoCancel(true) but it doesn't work

My code:

Notification n  = new Notification.Builder(this)
                .setContentTitle("Update for you")
                .setContentText("Please click here to see the update information")
                .setLargeIcon(BitmapFactory.decodeResource(this.getResources(),
                                                           R.drawable.ic_launcher))
                .setSmallIcon(R.drawable.ic_launcher)
                .setContentIntent(pList)
                .setAutoCancel(true)
                .addAction(R.drawable.ic_read, "Read", pRead)
                .addAction(R.drawable.ic_list, "All Updates", pList)
                .build();

NotificationManager notificationManager =
                      (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

notificationManager.notify(0, n);
解决方案

Use FLAG_AUTO_CANCEL

n.flags |= Notification.FLAG_AUTO_CANCEL;

这篇关于如何设置通知明确自己的点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 18:26