Projet Sin
Projet Sin

Reputation: 357

Permission not asked

I'd like to know why my permission are not asked when I'm launching my app, here's my manifest permissions :

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

And when I go through the param of my phone, I only have the "position" permission (and it's disabled).

Upvotes: 0

Views: 1414

Answers (4)

K327
K327

Reputation: 318

for marshmallow(API 23) and above you should get permission for location, phone states and other dangerous permissions not only in your manifest but in your code (Run Time Permission).for other permissions, manifest is enough.

see this video also you can find your solution in this Q&A

Upvotes: 0

Janeviemus
Janeviemus

Reputation: 41

If you are targeting SDK 26+, then you need to check for permissions in code like this:

if (ContextCompat.checkSelfPermission(thisActivity, Manifest.permission.ACCESS_FINE_LOCATION)
    != PackageManager.PERMISSION_GRANTED) {
// Permission is not granted
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
        Manifest.permission.ACCESS_FINE_LOCATION)) {
    // Show an explanation to the user *asynchronously* -- don't block
    // this thread waiting for the user's response! After the user
    // sees the explanation, try again to request the permission.
} else {
    // No explanation needed, we can request the permission.
    ActivityCompat.requestPermissions(thisActivity,
            arrayOf(Manifest.permission.ACCESS_FINE_LOCATION),
            MY_PERMISSIONS_ACCESS_FINE_LOCATION)

    // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
    // app-defined int constant. The callback method gets the
    // result of the request.
}
} else {
// Permission has already been granted - or running on old Android
}

It is described in Request App Permissions

Upvotes: 0

AvidRP
AvidRP

Reputation: 383

If by permission not asked you mean that the user isn't being prompted to allow internet permission then that is normal. Internet is in the normal permissions list so it is auto granted. For more information about normal permissions take a look at: https://developer.android.com/guide/topics/permissions/normal-permissions.html

Also, adding permissions is a two step process; once you have declared the permission you need in your manifest, you will also have to do some setup in your java file. Take a look at https://developer.android.com/training/permissions/requesting

Additionally, if you are looking for easier ways to deal with permissions then there are libraries out there for that too such as RxPermissions: https://github.com/tbruyelle/RxPermissions

Hopefully this helps!

Upvotes: 2

Caspar Geerlings
Caspar Geerlings

Reputation: 1061

You should ask for a Runtime Permission Please see the documentation: Request App Permissions

Upvotes: 1

Related Questions