Android 权限不在调试中提示用户
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
(参见Permissions overview - Normal permissions)。因此,该权限不需要明确的用户同意,根本不应该有请求提示:
来自Permissions overview - Permission approval:
If your app lists normal permissions in its manifest (that is, permissions that don't pose much risk to the user's privacy or the device's operation), the system automatically grants those permissions to your app.
[...]
Only dangerous permissions require user agreement. [...]
顺便说一句。如果您的意思是您的应用程序根本不会触发 NFC 标签发现事件,原因是您的清单中似乎没有任何用于 NFC 标签发现的意图过滤器。请参阅 如何注册标签发现。
我是 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
(参见Permissions overview - Normal permissions)。因此,该权限不需要明确的用户同意,根本不应该有请求提示:
来自Permissions overview - Permission approval:
If your app lists normal permissions in its manifest (that is, permissions that don't pose much risk to the user's privacy or the device's operation), the system automatically grants those permissions to your app.
[...]
Only dangerous permissions require user agreement. [...]
顺便说一句。如果您的意思是您的应用程序根本不会触发 NFC 标签发现事件,原因是您的清单中似乎没有任何用于 NFC 标签发现的意图过滤器。请参阅