diff options
author | Svetoslav <svetoslavganov@google.com> | 2015-06-03 15:43:59 -0700 |
---|---|---|
committer | Svetoslav <svetoslavganov@google.com> | 2015-06-03 15:43:59 -0700 |
commit | a2011d232b96e24d97050c39515d14365f380378 (patch) | |
tree | e841e7f9296c3f621aa5f56b163ca994397f7d45 /core/java | |
parent | 981975a3e7b439324bdfbf4076f350f7655135d7 (diff) | |
download | frameworks_base-a2011d232b96e24d97050c39515d14365f380378.zip frameworks_base-a2011d232b96e24d97050c39515d14365f380378.tar.gz frameworks_base-a2011d232b96e24d97050c39515d14365f380378.tar.bz2 |
Adding missing permission API to fragment
Change-Id: I90309a23a08a82f0ab93eb4f6185db09e035aac1
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/app/Fragment.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/core/java/android/app/Fragment.java b/core/java/android/app/Fragment.java index 40c5c64..26d4fd4 100644 --- a/core/java/android/app/Fragment.java +++ b/core/java/android/app/Fragment.java @@ -1223,6 +1223,33 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene } /** + * Gets whether you should show UI with rationale for requesting a permission. + * You should do this only if you do not have the permission and the context in + * which the permission is requested does not clearly communicate to the user + * what would be the benefit from granting this permission. + * <p> + * For example, if you write a camera app, requesting the camera permission + * would be expected by the user and no rationale for why it is requested is + * needed. If however, the app needs location for tagging photos then a non-tech + * savvy user may wonder how location is related to taking photos. In this case + * you may choose to show UI with rationale of requesting this permission. + * </p> + * + * @param permission A permission your app wants to request. + * @return Whether you can show permission rationale UI. + * + * @see Context#checkSelfPermission(String) + * @see #requestPermissions(String[], int) + * @see #onRequestPermissionsResult(int, String[], int[]) + */ + public boolean shouldShowRequestPermissionRationale(@NonNull String permission) { + if (mHost != null) { + mHost.getContext().getPackageManager().shouldShowRequestPermissionRationale(permission); + } + return false; + } + + /** * @hide Hack so that DialogFragment can make its Dialog before creating * its views, and the view construction can use the dialog's context for * inflation. Maybe this should become a public API. Note sure. |