Skip to main content

Posts

Showing posts from May, 2017

Android 6.0(Marshmallow) Runtime Permissions

Android 6.0 Runtime permissions :

1) For read phone state

Request Permission :
 ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE}, 1);

Check Permission :
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.READ_PHONE_STATE)
                        != PackageManager.PERMISSION_GRANTED) {

                    ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.READ_PHONE_STATE}, 1);

                } else {

                  //call your method
                }


2) For Read and Write External storage

Request Permission :
 ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_CODE);

 ActivityCompat.requestPermissions((this, new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE},READ_STORAGE);

Check Permission :
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
 != PackageManager.REQUEST_CODE)…