How to get rights using ActivityCompat.requestPermissions from the service, you need to get it from Actyvity as I understood

Need to get rights directly with a command with a link to the activation or call a method in the activation?

ActivityCompat.requestPermissions(???, Manifest.permission.SYSTEM_ALERT_WINDOW); 

    2 answers 2

    Directly in any way. Possible bypass mechanism:

    1. In the service, check if there is a permishn.
    2. If not, create a local push.
    3. When you click on the push, you open the Activity , where you can already request perm.
    • So how do you create anything at all if you don't have rights? - Vladimir Alexandrov
    • @Vladimir Aleksandrov for additional local rights right is it really necessary? - Suvitruf
     ActivityCompat.requestPermissions(getApplication(), Manifest.permission.SYSTEM_ALERT_WINDOW); 
    • Impossible to bring android.app.Aplication to android.app.Activity - Vladimir Alexandrov
    • Then, in any case, you need to wake up the activation, in general, it is strange that you need to get the rights in the service. As for me, bad practice. As for me, it is best to use eventbus for this purpose, for example, the Otto library, subscribe to activations, publish an event from the service, and get rights directly to the activations. - Andrei Alexandru
    • I'm trying to get permissions in the ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1); Nothing happens at all ... Can you tell me what's wrong? - Vladimir Alexandrov
    • @Vladimir Aleksandrov Android version on the phone what? - Suvitruf 8:50 pm
    • onRequestPermissionsResult well and yes, show the onRequestPermissionsResult handler onRequestPermissionsResult . - Suvitruf