简体   繁体   English

Android应用程式侦错APK不要求某些装置的权限

[英]Android app debug apk does not ask for permissions on some devices

On some devices, the app correctly asks permissions while sidloading. 在某些设备上,该应用在sidloading时会正确询问权限。 On others (Android 6.0), it does not ask permissions while sideloading at all. 在其他版本(Android 6.0)上,它在侧加载时根本不会询问权限。 The permissions are listed in the manifest.xml (below) and work perfectly for some devices (Android 5.0). 权限在manifest.xml(如下所示)中列出,并且对于某些设备(Android 5.0)可以完美使用。 On other devices (Android 4.0, 6.0.1), it asks permissions as it should but does not seem to incorporate all of them. 在其他设备(Android 4.0、6.0.1)上,它会按原样询问权限,但似乎并未合并所有权限。 The popup below is an example of what happens when a button to send an sms is clicked. 下面的弹出窗口是单击发送短信按钮时发生的示例。

I have only had limited testing and the problems seems to be a little different depending on which android version the device is running. 我仅进行了有限的测试,并且问题似乎有所不同,具体取决于设备所运行的Android版本。 That being said, it could be stemming from something different, I wouldn't know. 话虽这么说,可能是因为其他原因,我不知道。

Does anyone know why this is happening? 有人知道为什么会这样吗?

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.catalizeapp.catalize_ss25">

<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="Catalize"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name=".LoginActivity"
        android:label="Catalize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SEARCH" />
        </intent-filter>

        <meta-data
            android:name="android.app.default_searchable"
            android:value="Contacts" />
        <meta-data
            android:name="android.app.searchable"
            android:resource="@xml/searchable" />
    </activity>
    <activity android:name=".Contacts" />

    <activity android:name=".Account"
        android:theme="@style/SuperCoolAppBarActivity"/>
        <meta-data android:name = "android.support.PARENT_ACTIVITY"
            android:value= ".Contacts"/>

    <activity android:name=".ReportBug">
        <meta-data android:name = "android.support.PARENT_ACTIVITY"
            android:value=".Contacts"/>
    </activity>
</application></manifest>

(IMAGE) When a button that should send a text message is clicked, this pops up instead of executing the action of the button (图像)单击应发送文本消息的按钮时,将弹出而不执行按钮的操作

According to the documentation: 根据文档:

If the device is running Android 6.0 or higher, and your app's target SDK is 23 or higher: The app has to list the permissions in the manifest, and it must request each dangerous permission it needs while the app is running. 如果设备运行的是Android 6.0或更高版本,并且您的应用程序的目标SDK是23或更高版本:该应用程序必须在清单中列出权限,并且在运行该应用程序时,它必须请求所需的每个危险权限。 The user can grant or deny each permission, and the app can continue to run with limited capabilities even if the user denies a permission request. 用户可以授予或拒绝每个许可,即使用户拒绝许可请求,应用程序也可以继续以有限的功能运行。 That's the reason why althought you have declared the permissions in your manifest file you still need to ask for them at runtime. 这就是为什么尽管您已在清单文件中声明了权限,但仍需要在运行时要求它们的原因。

As a workaround you can set a minSdkVersion < 23, but also as the documentation says: 作为解决方法,您可以将minSdkVersion设置为<23,也可以按照文档中的说明进行设置:

Note: Beginning with Android 6.0 (API level 23), users can revoke permissions from any app at any time, even if the app targets a lower API level. 注意:从Android 6.0(API级别23)开始,即使该应用程序定位于较低的API级别,用户也可以随时从任何应用程序撤消权限。 You should test your app to verify that it behaves properly when it's missing a needed permission, regardless of what API level your app targets. 无论您的应用程序面向哪个API级别,都应测试您的应用程序以验证其在缺少所需权限时是否能够正常运行。 Also, according to the Permissions Best Practices you should test against both permission models to provide a better user experience. 另外,根据“权限最佳实践”,您应该针对两种权限模型进行测试,以提供更好的用户体验。

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

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