Fragment.RequestPermissions(String[], Int32) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Requests permissions to be granted to this application.
[Android.Runtime.Register("requestPermissions", "([Ljava/lang/String;I)V", "", ApiSince=23)]
public void RequestPermissions(string[] permissions, int requestCode);
[<Android.Runtime.Register("requestPermissions", "([Ljava/lang/String;I)V", "", ApiSince=23)>]
member this.RequestPermissions : string[] * int -> unit
Parameters
- permissions
- String[]
The requested permissions. Must me non-null and not empty.
- requestCode
- Int32
Application specific request code to match with a result
reported to #onRequestPermissionsResult(int, String[], int[]).
Should be >= 0.
- Attributes
Remarks
Requests permissions for this application. For runtime permission prompts, request permissions declared in your manifest with the dangerous protection level. Normal permissions are granted at install time when requested in the manifest. Signature permissions are granted at install time when requested in the manifest and the app's signature matches the signature of the app declaring the permissions.
Call ShouldShowRequestPermissionRationale(String) to check whether the system recommends showing a rationale before requesting a permission.
The host handles the request. An activity host may present UI and deliver the result to OnRequestPermissionsResult(Int32, String[], Permission[]). The default FragmentHostCallback does not implement permission requests.
Note that requesting a permission does not guarantee it will be granted and your app should be able to run without having this permission.
This method may start an activity allowing the user to choose which permissions to grant and which to reject. Hence, you should be prepared that your activity may be paused and resumed. Further, granting some permissions may require a restart of you application. In such a case, the system will recreate the activity stack before delivering the result to onRequestPermissionsResult(int,String[],int[]).
Use CheckSelfPermission(String) to check whether a permission is granted.
Requesting an already granted permission does not always show a prompt.
You cannot request a permission if your activity sets noHistory to true because in this case the activity would not receive result callbacks including onRequestPermissionsResult(int,String[],int[]).
Android reference for android.app.Fragment.requestPermissions.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.