简体   繁体   English

Android权限未提示用户进行调试

[英]Android permissions not prompting the user in debug

I'm new to Android development and I'm working on an app that will require NFC permissions. 我是Android开发的新手,正在开发需要NFC权限的应用程序。 For some reason, the app is not prompting the user when it opens or when I hold it near an NFC tag or terminal. 由于某些原因,该应用在打开时或在NFC标签或终端附近时不会提示用户。 Below is my AndroidManifest.xml. 以下是我的AndroidManifest.xml。 Can anyone tell me what I'm doing wrong here? 谁能告诉我我在做什么错?

<?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>

The NFC permission is classified as PROTECTION_NORMAL (see Permissions overview - Normal permissions ). NFC权限分类为PROTECTION_NORMAL (请参阅权限概述-普通权限 )。 Consequently, that permission does not require explicit user consent and there should not be a request prompt at all: 因此,该权限不需要用户的明确同意,并且根本不应出现请求提示:

From 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. 只有危险的权限需要用户同意。 [...] [...]


Btw. 顺便说一句。 if you meant that your app simply does not trigger for NFC tag discovery events, the reason for this is that you don't seem to have any intent filter for NFC tag discovery in your manifest. 如果您的意思是说应用程序根本不会触发NFC标签发现事件,则原因是您的清单中似乎没有用于NFC标签发现的任何意图过滤器。 See, eg, How to use NFC ACTIONS on how to register for tag discovery. 有关如何注册标签发现的信息,请参见《 如何使用NFC ACTIONS 》。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM