![](/img/trans.png)
[英]How to grant runtime permissions to an android application without prompting the user
[英]Android permissions not prompting the user in debug
我是Android开发的新手,正在开发需要NFC权限的应用程序。 由于某些原因,该应用在打开时或在NFC标签或终端附近时不会提示用户。 以下是我的AndroidManifest.xml。 谁能告诉我我在做什么错?
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.NFC"/>
<uses-feature android:name="android.hardware.nfc.hce" android:required="true" />
<uses-feature android:name="android.hardware.nfc" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".MyHostApduService" android:exported="true"
android:permission="android.permission.BIND_NFC_SERVICE">
<intent-filter>
<action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE"/>
</intent-filter>
<meta-data android:name="android.nfc.cardemulation.host_apdu_service"
android:resource="@xml/apduservice"/>
</service>
</application>
NFC权限分类为PROTECTION_NORMAL
(请参阅权限概述-普通权限 )。 因此,该权限不需要用户的明确同意,并且根本不应出现请求提示:
从权限概述-权限批准 :
如果您的应用在其清单中列出了正常权限(即,不会对用户的隐私或设备的操作造成太大风险的权限),则系统会自动将这些权限授予您的应用。
[...]
只有危险的权限需要用户同意。 [...]
顺便说一句。 如果您的意思是说应用程序根本不会触发NFC标签发现事件,则原因是您的清单中似乎没有用于NFC标签发现的任何意图过滤器。 有关如何注册标签发现的信息,请参见《 如何使用NFC ACTIONS 》。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.