问题描述
我目前正在开发使用 NotificationListenerService
的Android应用,该应用要求用户在 Setting->下启用我的应用的通知访问权限.安全->通知访问
.
I'm currently developing an app for Android that uses the NotificationListenerService
, which requires that the user will enable notification access for my app under Setting -> Security -> Notification Access
.
我的问题是,我可以将用户重定向到这个地方,以便他们启用它吗?到目前为止,我只设法将它们定向到 Setting->安全性
窗口.
My question is that can I redirect the user to this place so they will enable it? So far I only managed to direct them to Setting -> Security
window.
还可以先检查用户是否已经为我的应用启用了通知访问权限,然后才将其重定向?
Also, is it possible to first check if the user enabled notification access for my app already and only then redirect them?
推荐答案
您可以使用以下 Intent
打开 NotificationAccessSettingsActivity
,但是我不确定是否要检查查看他们是否已经启用了您的应用.
You can open the NotificationAccessSettingsActivity
by using the following Intent
, but I'm not sure about checking to see if they've already enabled your app.
startActivity(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"));
或者,对于API 22 +:
startActivity(new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS));
这篇关于重定向到通知访问设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!