Android 4.1:如何检查应用程序的通知被禁用? [英] Android 4.1: How to check notifications are disabled for the application?

查看:34
本文介绍了Android 4.1:如何检查应用程序的通知被禁用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android 4.1 为用户提供了一个复选框,用于禁用特定应用程序的通知.

但是,作为开发人员,我们无法知道通知调用是否有效.

我真的需要检查当前应用程序的通知是否被禁用,但我在 API 中找不到任何设置.

有没有办法在代码中检查这个设置?

解决方案

你不能 100% 不能.

Android 4.1 offers the user a check box to disable notifications for a specific application.

However, as a developer we have no way to know whether a call to notify was effective or not.

I really need to check if the notifications are disabled for the current application but I can't find any setting for that in the API.

Is there ever a way to check this setting in the code?

解决方案

You can't 100% can't.

It is asked in this Google I/O 2012 video and the Project lead for the new notifications declares that you can't.


Edit

2016 update: Now you can check it, as said in this Google I/O 2016 video.

Use NotificationManagerCompat.areNotificationsEnabled(), from support library, to check if notifications are blocked on API 19+. The versions below API 19 will return true (notifications are enabled).

这篇关于Android 4.1:如何检查应用程序的通知被禁用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆