am 597059d5: Merge "Adding missing permission API to fragment" into mnc-dev

* commit '597059d535278323ddce9ff5229e063f5a6d6ebf':
  Adding missing permission API to fragment
This commit is contained in:
Svetoslav
2015-06-03 22:58:28 +00:00
committed by Android Git Automerger
3 changed files with 29 additions and 0 deletions

View File

@@ -4384,6 +4384,7 @@ package android.app {
method public void setSharedElementReturnTransition(android.transition.Transition);
method public void setTargetFragment(android.app.Fragment, int);
method public void setUserVisibleHint(boolean);
method public boolean shouldShowRequestPermissionRationale(java.lang.String);
method public void startActivity(android.content.Intent);
method public void startActivity(android.content.Intent, android.os.Bundle);
method public void startActivityForResult(android.content.Intent, int);

View File

@@ -4480,6 +4480,7 @@ package android.app {
method public void setSharedElementReturnTransition(android.transition.Transition);
method public void setTargetFragment(android.app.Fragment, int);
method public void setUserVisibleHint(boolean);
method public boolean shouldShowRequestPermissionRationale(java.lang.String);
method public void startActivity(android.content.Intent);
method public void startActivity(android.content.Intent, android.os.Bundle);
method public void startActivityForResult(android.content.Intent, int);

View File

@@ -1222,6 +1222,33 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
/* callback - do nothing */
}
/**
* 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