Home How do I recognize GRANTED and UNACCEPTED of permissions?
Reply: 0

How do I recognize GRANTED and UNACCEPTED of permissions?

user1194 Published in May 20, 2018, 10:13 am

I use this code to recognize permissions in onCreate:

     requestPermissions(new String[]{Manifest.permission.READ_PHONE_STATE}, 100);

And in activity I use this code snippet to check, allow or deny the permissions :

public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
  switch (requestCode) {
     case 100: {
         if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED)
             Toast.makeText(getApplicationContext(), "Ok", Toast.LENGTH_SHORT).show();
             Toast.makeText(getApplicationContext(), "No", Toast.LENGTH_SHORT).show();

and in Manifest.xml :

<!-- *****  Uses Permission  ***** -->
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>

But it always returns the value of zero in the code, both when it is verified and when it is rejected.

How do I tell if the user has verified or denied?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.390534 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO