Permissions for Android 6.0 - Where to post permission requests?

With the new Androids permission system, I was wondering how to implement it correctly. The tutorials on how and when to use permissions seem pretty clear. However, I do not know who is requesting permissions and where to request them.

So basically, my question is: should an Activity that launches another activity request in advance, or should an Activity that requires permission place a request?

If this requires a request that requires permission, should I call requestForPermissioninternally onCreateor in onStart?

Although these seem to be very simple questions, I did not find any hints in the documentation.

Thanks.

+4
source share
3 answers

Ideally, you can call a permission check immediately before making a method call that requires permission. For example, you can create a wrapper for your function, which needs permission to contact and always call that wrapper instead of the actual method.

Read more http://inthecheesefactory.com/blog/things-you-need-to-know-about-android-m-permission-developer-edition/en

also check out http://hotchemi.imtqy.com/PermissionsDispatcher/ to reduce the number of permissions.

+1
source

should an Activity that will launch another activity request for permission in advance, or should an Activity that requires permission place a request?

. , , :

  • , - , , , , , , .

    /li >
  • - , - , , ListView, , .

( " ? ?" " ?"?).

+2

X - "Y" , . onCreate onStart.

"Y" , Android M . Android M. , , i.e/data/data/ // , . , , "Y" .

As for activity, your task must be performed on some fragment or activity so that this activity processes the results of onRequestPermission.

0
source

Source: https://habr.com/ru/post/1619535/


All Articles