首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在锁屏上解除android棒棒糖通知?

如何在锁屏上解除android棒棒糖通知?
EN

Stack Overflow用户
提问于 2015-08-28 01:21:57
回答 1查看 883关注 0票数 0

在棒棒糖上,如果用户设置了个人识别码,那么一些通知就不能被刷走。当他们试图被解雇时,他们就像是一个持久的通知。

一些应用程序的通知可以在锁屏上滑动而不解锁。

我只测试了隐藏敏感通知内容,设置标志会改变这个能力吗?

我该如何实现这一点?

EN

回答 1

Stack Overflow用户

发布于 2015-08-28 01:56:18

这个标志让你的通知固定不变: Notification.FLAG_ONGOING_EVENT;

如果您将其省略,则可以将其删除。如果你把它放进去,它就会粘住。

仅供参考:我如何发出通知:

代码语言:javascript
运行
复制
    //These are parameters for setting up the tag in the tray
private static final String NOTIFICATION_ID_TAG="notificationID";
private static final int NOTIFICATION_ID=123456;

public void createNotification() {
    // Prepare intent which is triggered if the
    // notification is selected
    Intent intent = new Intent(this, MainActivity_Host.class);
    intent.putExtra(NOTIFICATION_ID_TAG, NOTIFICATION_ID);
    PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);

    // Build notification
    Notification noti = new Notification.Builder(this)
            .setContentTitle("Service Running")
            .setContentText("The service is running").setSmallIcon(R.mipmap.ic_launcher)
            .setContentIntent(pIntent)
            .build();
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    //THIS FLAG MAKES THE NOTIFICATION STICK = YOU CAN'T SWIPE IT AWAY... IF YOU LEAVE IT OUT YOU CAN REMOVE THE NOTIFICATION
    noti.flags |= Notification.FLAG_ONGOING_EVENT;

    notificationManager.notify(NOTIFICATION_ID, noti);

}

下面是从代码中删除通知的方法:

代码语言:javascript
运行
复制
        //Erase the notification that we set up when the service started
    NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.cancel(NOTIFICATION_ID);

如您所见,您可以通过用于创建通知的NOTIFICATION_ID从NotificationManager获取通知。这只是我编的一个数字。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32255726

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档