Let's say I'm trying to save a bitmap image to a png
public void save() {
  String filename = "file.png";
        File sd = Environment.getExternalStorageDirectory();
        File dest = new File(sd, filename);
        try {
            FileOutputStream out = new FileOutputStream(dest);
            fBitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
            out.flush();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
}
If I use Android 6.0 and above, I need to ask for runtime permissions
void validatePermissions() {
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
            if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
            } else {
                ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
            }
        }
  }
I have a few questions:
The above code successfully asks for permissions, however I have to re-start the app, How do I porperly halt the code until permissions are either granted or not granted?
Below Android 6.0, permissions are granted on install by the manifest file. How does android 5 or lower handle runtime permissions code?
Thanks
 
     
     
     
     
    