![](/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.