OSDN Git Service

Improve documentation of onRequestPermissionsResult
[android-x86/frameworks-base.git] / core / java / android / app / Fragment.java
index 5490fe7..82206ea 100644 (file)
@@ -1213,6 +1213,11 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
     /**
      * Callback for the result from requesting permissions. This method
      * is invoked for every call on {@link #requestPermissions(String[], int)}.
+     * <p>
+     * <strong>Note:</strong> It is possible that the permissions request interaction
+     * with the user is interrupted. In this case you will receive empty permissions
+     * and results arrays which should be treated as a cancellation.
+     * </p>
      *
      * @param requestCode The request code passed in {@link #requestPermissions(String[], int)}.
      * @param permissions The requested permissions. Never null.
@@ -1249,7 +1254,8 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
      */
     public boolean shouldShowRequestPermissionRationale(@NonNull String permission) {
         if (mHost != null) {
-            mHost.getContext().getPackageManager().shouldShowRequestPermissionRationale(permission);
+            return mHost.getContext().getPackageManager()
+                    .shouldShowRequestPermissionRationale(permission);
         }
         return false;
     }