简体   繁体   English

安装时未请求 Android 权限

[英]Android permissions not requested on installation

I've searched for similar questions before posting here and I didn't find a answer solving my issue.我在这里发帖之前搜索过类似的问题,但没有找到解决我问题的答案。 My manifest.xml file seems correct, I'd like the user to be asked for permissions on installation (not runtime, it already works with my code).我的 manifest.xml 文件似乎是正确的,我希望用户被要求获得安装权限(不是运行时,它已经可以与我的代码一起使用)。 I don't know why the parameters I put doens't work:我不知道为什么我放的参数不起作用:

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:name="VILES" android:versionCode="1" android:versionName="0.0.1" package="fr.nc.delegue.referendum" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:usesCleartextTraffic="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-feature android:name="android.hardware.telephony" android:required="false" />
    <uses-permission android:name="android.permission.RECEIVE_WAP_PUSH" />
    <uses-permission android:name="android.permission.RECEIVE_MMS" />
    <uses-permission android:name="android.permission.READ_SMS" />
    <uses-permission android:name="android.permission.WRITE_SMS" />
    <uses-permission android:name="android.permission.SEND_SMS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.RECEIVE_SMS" />
</manifest>

I use Cordova (and Quasar) to build my app, the app is working great, but I still have this problem of permissions not being requested on installation... Can anyboy tell me what I'm doing wrong here?我使用 Cordova(和 Quasar)来构建我的应用程序,该应用程序运行良好,但我仍然遇到安装时没有请求权限的问题......任何人都可以告诉我我在这里做错了什么吗? Thanks in advance :)提前致谢 :)

You are not doing anything wrong, other than expecting something that is no longer available.除了期待不再可用的东西之外,您没有做错任何事情。 Apps with a targetSdkVersion of 23 or higher operate purely off of runtime permissions — there is no way to force the Play Store or Android to prompt the user for permission at install time. targetSdkVersion23或更高版本的应用完全没有运行时权限——无法强制 Play 商店或 Android 在安装时提示用户授予权限。 And you cannot distribute your app on the Play Store (and on some other distribution channels) with that old of a targetSdkVersion .并且您不能使用旧的targetSdkVersion在 Play 商店(以及其他一些分发渠道)上分发您的应用程序。

You can make a try to add a Splash Activity (the first screen) when you will ask for permission .当您请求许可时,您可以尝试添加一个 Splash Activity(第一个屏幕)。 When user first install app he will see a screen , let s say setup screen or introduction screen where he will be asked for permission.当用户第一次安装应用程序时,他会看到一个屏幕,比如说设置屏幕或介绍屏幕,他会在那里被要求许可。 After you will set a property and won t show this screen again .在您设置一个属性后,将不再显示此屏幕。

Add this in your main activity, on create method.将此添加到您的主要活动中,在 create 方法上。

/*all permision need for this app*/
        int PERMISSION_ALL = 1;
        String[] PERMISSIONS = {
                Manifest.permission.READ_EXTERNAL_STORAGE,
        };


        /*check if the there is permission that is needed*/

        if (!hasPermissions(this, PERMISSIONS)) {
            ActivityCompat.requestPermissions(this, PERMISSIONS, PERMISSION_ALL);
        }

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

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