Question: We have Spring Boot Application (Application 1 , which runs on Spring Boot 1.5 and Java 1.8 , and we are trying to use dependency Spring Boot Admin Client 2.0).
Now we have another application (Application 2 , which is on Spring Boot 2.0 , Java 1.8 and Spring Boot Admin Server 2.0 .) We need to set up communication between both of them. We tried tweaking few things but the client fails to register with server. (Application 1 fails to get register with Application 2). Any help would be appreciated . We cannot upgrade to Spring Boot 2.0 for our spring client (Application 1) but wanted to use new Spring Boot Admin server to display stats.

Answer: 
Here is a class, with a method asking for storage permission 

```
public class PermissionManager {
public static boolean checkPermissionREAD_EXTERNAL_STORAGE(final Context context) {
    int currentAPIVersion = Build.VERSION.SDK_INT;
    if (currentAPIVersion >= android.os.Build.VERSION_CODES.M) {
        if (ContextCompat.checkSelfPermission(context,
                Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
            if (ActivityCompat.shouldShowRequestPermissionRationale(
                    (Activity) context,
                    Manifest.permission.READ_EXTERNAL_STORAGE)) {
                showDialog("External storage", context,
                        Manifest.permission.READ_EXTERNAL_STORAGE);

            } else {
                ActivityCompat
                        .requestPermissions(
                                (Activity) context,
                                new String[] { Manifest.permission.READ_EXTERNAL_STORAGE },
                                101);
            }
            return false;
        } else {
            return true;
        }

    } else {
        return true;
    }
}
}

```

Used in your activity:

```
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    switch (requestCode) {
        case 101:
            if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                Toast.makeText(this, "Permission given",
                        Toast.LENGTH_SHORT).show();
                //saveImage(finalBitmap, image_name); <- or whatever you want to do after permission was given . For instance, open gallery or something 
            } else {
                Toast.makeText(this, "Permission Denied",
                        Toast.LENGTH_SHORT).show();
            }
            break;
        default:
            super.onRequestPermissionsResult(requestCode, permissions,
                    grantResults);
    }
}

```

In your case, you'll also check for it before saving the file 

```
if (PermissionManager.checkPermissionREAD_EXTERNAL_STORAGE(this)){
        saveImage(finalBitmap, image_name);
    }

```
You can use [PermissionDispatcher](https://github.com/codepath/android_guides/wiki/Managing-Runtime-Permissions-with-PermissionsDispatcher) to handle it very gently AFAIK it works in all versions. 

Hope this will help you