Merge "Make it clear that checking shouldShowPermissionRationale is recommended" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
8083336a88
@@ -5151,6 +5151,10 @@ public class Activity extends ContextThemeWrapper
|
||||
* the signature of the app declaring the permissions.
|
||||
* </p>
|
||||
* <p>
|
||||
* Call {@link #shouldShowRequestPermissionRationale(String)} before calling this API to
|
||||
* check if the system recommends to show a rationale UI before asking for a permission.
|
||||
* </p>
|
||||
* <p>
|
||||
* If your app does not have the requested permissions the user will be presented
|
||||
* with UI for accepting them. After the user has accepted or rejected the
|
||||
* requested permissions you will receive a callback on {@link
|
||||
@@ -5240,20 +5244,10 @@ public class Activity extends ContextThemeWrapper
|
||||
}
|
||||
|
||||
/**
|
||||
* 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>
|
||||
* Gets whether you should show UI with rationale before requesting a permission.
|
||||
*
|
||||
* @param permission A permission your app wants to request.
|
||||
* @return Whether you can show permission rationale UI.
|
||||
* @return Whether you should show permission rationale UI.
|
||||
*
|
||||
* @see #checkSelfPermission(String)
|
||||
* @see #requestPermissions(String[], int)
|
||||
|
||||
@@ -1179,6 +1179,10 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
|
||||
* the signature of the app declaring the permissions.
|
||||
* </p>
|
||||
* <p>
|
||||
* Call {@link #shouldShowRequestPermissionRationale(String)} before calling this API
|
||||
* to check if the system recommends to show a rationale UI before asking for a permission.
|
||||
* </p>
|
||||
* <p>
|
||||
* If your app does not have the requested permissions the user will be presented
|
||||
* with UI for accepting them. After the user has accepted or rejected the
|
||||
* requested permissions you will receive a callback on {@link
|
||||
@@ -1213,29 +1217,6 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
|
||||
* <code>true</code> because in this case the activity would not receive
|
||||
* result callbacks including {@link #onRequestPermissionsResult(int, String[], int[])}.
|
||||
* </p>
|
||||
* <p>
|
||||
* A sample permissions request looks like this:
|
||||
* </p>
|
||||
* <code><pre><p>
|
||||
* private void showContacts() {
|
||||
* if (getActivity().checkSelfPermission(Manifest.permission.READ_CONTACTS)
|
||||
* != PackageManager.PERMISSION_GRANTED) {
|
||||
* requestPermissions(new String[]{Manifest.permission.READ_CONTACTS},
|
||||
* PERMISSIONS_REQUEST_READ_CONTACTS);
|
||||
* } else {
|
||||
* doShowContacts();
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public void onRequestPermissionsResult(int requestCode, String[] permissions,
|
||||
* int[] grantResults) {
|
||||
* if (requestCode == PERMISSIONS_REQUEST_READ_CONTACTS
|
||||
* && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
* doShowContacts();
|
||||
* }
|
||||
* }
|
||||
* </code></pre></p>
|
||||
*
|
||||
* @param permissions The requested permissions. Must me non-null and not empty.
|
||||
* @param requestCode Application specific request code to match with a result
|
||||
@@ -1275,20 +1256,10 @@ 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>
|
||||
* Gets whether you should show UI with rationale before requesting a permission.
|
||||
*
|
||||
* @param permission A permission your app wants to request.
|
||||
* @return Whether you can show permission rationale UI.
|
||||
* @return Whether you should show permission rationale UI.
|
||||
*
|
||||
* @see Context#checkSelfPermission(String)
|
||||
* @see #requestPermissions(String[], int)
|
||||
|
||||
Reference in New Issue
Block a user