Answer the question
In order to leave comments, you need to log in
How to request permission from a background task (service, worker, thread...)?
Google teaches to request permissions only at the moment before use,
imagine a service that takes a long time to count something and sometimes wants to write to a card,
pre-checking permissions is not an option, the service is background, the user can minimize the application and revoke the permission.
Interested in the logic of the solution.
Answer the question
In order to leave comments, you need to log in
int permissionCheck = ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.SOME_PERMISSION);
I did so.
at the time of the first launch, I
display Press the button - a request for rights will be made.
On the settings page. If the permission is not given, Notification and button give.
If the service ran into an error due to permission. Work stop.
Output NotGrantPermActivity
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question