如何在三星 S5 (SM-G800H) 上申请请勿打扰权限? [英] How to request Do Not Disturb permission on Samsung S5 (SM-G800H)?

查看:64
本文介绍了如何在三星 S5 (SM-G800H) 上申请请勿打扰权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是请求免打扰许可的常用方式:

This is the usual way to request DND permission:

Intent intent = new Intent();
intent.setAction("android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS");
startActivityForResult(intent, NOTIFICATION_REQUEST_CODE);

但是在(至少一个)三星 SM-G800H 上,这会引发 ActivityNotFoundException.

However on (at least one) Samsung SM-G800H this throws ActivityNotFoundException.

显然在那个模型上,他们有一种叫做阻塞模式"的东西.任何人都知道正确的意图/如何处理该模型?见 https://www.cnet.com/uk/how-to/where-to-find-do-not-disturb-mode-on-the-galaxy-s5/

Apparently on that model they have something called 'Blocking Mode'. Anyone know the correct intent / how to handle on that model? See https://www.cnet.com/uk/how-to/where-to-find-do-not-disturb-mode-on-the-galaxy-s5/

设备详情:制造商:三星型号:SM-G800H主板:MSM8228安卓 API:23安卓操作系统:6.0.1品牌:三星内存:1.35GB方向:纵向

Device details: Manufacturer: Samsung Model: SM-G800H Board: Msm8228 Android API: 23 Android OS: 6.0.1 Brand: Samsung RAM: 1.35GB Orientation: Portrait

推荐答案

这可能不是三星相关的问题.根据官方文档,ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS 仅在 API 上可用23+(棉花糖).您正在测试的 S5 是否运行 Android 6 Marshmallow?如果没有,那是你的问题.

This might not be a Samsung related issue. According to the official docs, ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS is available only on API 23+ (Marshmallow). Does the S5 you're testing on have Android 6 Marshmallow running? If not, that's your problem.

由于即使在 Android 6 上,每个设备上也可能不存在此 Activity,因此您需要处理无法解析意图的情况.所以这样的事情可能是你想要的:

Since this Activity may not be present on each device even if they are on Android 6, you'll need to handle the case where the intent can't be resolved. So something like this might be what you want:

PackageManager packageManager = getActivity().getPackageManager();

Intent intent = new Intent();
intent.setAction("android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS");

if (intent.resolveActivity(packageManager) != null) {
    startActivityForResult(intent, NOTIFICATION_REQUEST_CODE);
} else {
    Log.d(TAG, "No Intent available to handle action");
}

这篇关于如何在三星 S5 (SM-G800H) 上申请请勿打扰权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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