Partager via


Context.CheckCallingPermission(String) Method

Definition

Determine whether the calling process of an IPC you are handling has been granted a particular permission.

[Android.Runtime.Register("checkCallingPermission", "(Ljava/lang/String;)I", "GetCheckCallingPermission_Ljava_lang_String_Handler")]
public abstract Android.Content.PM.Permission CheckCallingPermission (string permission);
[<Android.Runtime.Register("checkCallingPermission", "(Ljava/lang/String;)I", "GetCheckCallingPermission_Ljava_lang_String_Handler")>]
abstract member CheckCallingPermission : string -> Android.Content.PM.Permission

Parameters

permission
String

The name of the permission being checked.

Returns

PackageManager#PERMISSION_GRANTED if the calling pid/uid is allowed that permission, or PackageManager#PERMISSION_DENIED if it is not.

Attributes

Remarks

Determine whether the calling process of an IPC you are handling has been granted a particular permission. This is basically the same as calling #checkPermission(String, int, int) with the pid and uid returned by android.os.Binder#getCallingPid and android.os.Binder#getCallingUid. One important difference is that if you are not currently processing an IPC, this function will always fail. This is done to protect against accidentally leaking permissions; you can use #checkCallingOrSelfPermission to avoid this protection.

Java documentation for android.content.Context.checkCallingPermission(java.lang.String).

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.

Applies to

See also

  • <xref:Android.Content.PM.PackageManager.CheckPermission(System.String%2c+System.String)>
  • <xref:Android.Content.Context.CheckPermission(System.String%2c+System.Int32%2c+System.Int32)>
  • CheckCallingOrSelfPermission(String)