I heard that miui phone also ask for permission as marshmallow so I created some code for it.
It works well on other phones but when I tested it on MIUI devices it returns 0 wether I accept permission or denied permission.
Below I put my code which check permission
if ( android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M )
{
checkAndRequestPermissions(); // this method first check for permisison if not granted then call ActivityCompact.checkSelfPermisison(context,permisison);
}
else
{
int permission = PermissionChecker.checkSelfPermission(MainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
Log.d("Permission status","Status"+permission);
}
this is the sample code for marshmallow and above versions:
public static class Utility { public static final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 123;
this is a method that checks for permission for reading external storage. please refer the code and manipulate accordingly. Hope this helps you out.
also add this code in onCreate method
boolean result = Utility.checkPermission(MainActivity.this);