Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android App not asking for permissions when installing

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?

like image 964
der_eismann Avatar asked Feb 29 '16 14:02

der_eismann


People also ask

How do I request permission for an Android app?

In your app's manifest file, declare the permissions that your app might need to request. Design your app's UX so that specific actions in your app are associated with specific runtime permissions. Users should know which actions might require them to grant permission for your app to access private user data.


3 Answers

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.

like image 131
StuStirling Avatar answered Oct 29 '22 18:10

StuStirling


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);
        }
    }
}
like image 43
Vanya Sakharovskiy Avatar answered Oct 29 '22 18:10

Vanya Sakharovskiy


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

like image 30
Smitha Avatar answered Oct 29 '22 20:10

Smitha