Android App not asking for permissions when installing
Asked Answered
E

4

24

I work in the IT department of my university and we work on an app that installs the correct setup for the eduroam WiFi (maybe you have heard of it).

However I have a problem running it on my own LG G4 with Android 6.0. When installing the compiled *.apk it doesn't ask for any permissions although they are set in the AndroidManifest.xml. It was working on all previous Android versions.

Is it mandatory now to ask for permissions at run time?

Englacial answered 29/2, 2016 at 14:14 Comment(3)
What is the targetSdkVersion of your app?Improbity
I thought it would only do that if your security settings were set to "unknown sources=false". Any time you install something from a known source, like Play, you won't see that.Clime
I just realized that Android doesn't ask for the Wi-Fi state permission when installing from apk instead of the Play Store. You can see the difference here: imgur.com/a/rg2IVEnglacial
Y
46

If your target SDK version is 23 then you need to ask for "dangerous" permissions at run time.

If this is the case then you should be able to see that no permissions have been granted if you go to Settings > Apps > "Your app" > Permissions.

If you don't want to do implement the new system yet then you can reduce your target sdk version to 22 to get the old permission system. You can still compile with sdk version 23 though.

See the documentation for more information.

Y answered 29/2, 2016 at 14:24 Comment(1)
Thanks for the advice, although we only use ACCESS_WIFI_STATE and CHANGE_WIFI_STATE, which are not listed as dangerous permissions. But I'll try setting target SDK to 22.Englacial
R
3

if you want to request permissions at runtime you should write a special request in your app. Something like this:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        createPermissions();
}
public void createPermissions(){
    String permission = Manifest.permission.READ_SMS;
    if (ContextCompat.checkSelfPermission(getContext(), permission) != PackageManager.PERMISSION_GRANTED){    
        if(!ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), permission)){
              requestPermissions(new String[]{permission}),
                        SMS_PERMISSION);
        }
    }
}
Rotund answered 29/2, 2016 at 14:52 Comment(0)
S
1

If the user is running Android 6.0 (API level 23) or later, the user has to grant your app its permissions while they are running the app. If you confront the user with a lot of requests for permissions at once, you may overwhelm the user and cause them to quit your app. Instead, you should ask for permissions as you need them.

In some cases, one or more permissions might be absolutely essential to your app. It might make sense to ask for all of those permissions as soon as the app launches. For example, if you make a photography app, the app would need access to the device camera. When the user launches the app for the first time, they won't be surprised to be asked for permission to use the camera. But if the same app also had a feature to share photos with the user's contacts, you probably should not ask for the READ_CONTACTS permission at first launch. Instead, wait until the user tries to use the "sharing" feature and ask for the permission then.

If your app provides a tutorial, it may make sense to request the app's essential permissions at the end of the tutorial sequence.

Source/ref https://developer.android.com/training/permissions/usage-notes

Swiger answered 29/1, 2020 at 21:40 Comment(1)
Yo have three options: 1.- Going to Settings->Applications->YourApp->Permissions and activate the permissions the app needs. 2.- To have the targetSdkVersion=22 (or less) and then you're somehow avoiding the need of asking for permissions. 3.- Implement the request of permissions in the app for Android 6.0 on upper (developer.android.com/training/permissions/requesting)Germanize
I
0

In my situation I had to ask location permissions without background first!

works

locationPermissionRequest.launch(arrayOf(
        Manifest.permission.ACCESS_FINE_LOCATION,
        Manifest.permission.ACCESS_COARSE_LOCATION))

does not work (does not ask for permissions when installed)

locationPermissionRequest.launch(arrayOf(
        Manifest.permission.ACCESS_FINE_LOCATION,
        Manifest.permission.ACCESS_BACKGROUND_LOCATION,
        Manifest.permission.ACCESS_COARSE_LOCATION))
Igbo answered 2/5 at 10:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.