다음을 통해 공유


Context.EnforceCallingPermission(String, String) Method

Definition

If the calling process of an IPC you are handling has not been granted a particular permission, throw a SecurityException.

[Android.Runtime.Register("enforceCallingPermission", "(Ljava/lang/String;Ljava/lang/String;)V", "GetEnforceCallingPermission_Ljava_lang_String_Ljava_lang_String_Handler")]
public abstract void EnforceCallingPermission (string permission, string? message);
[<Android.Runtime.Register("enforceCallingPermission", "(Ljava/lang/String;Ljava/lang/String;)V", "GetEnforceCallingPermission_Ljava_lang_String_Ljava_lang_String_Handler")>]
abstract member EnforceCallingPermission : string * string -> unit

Parameters

permission
String

The name of the permission being checked.

message
String

A message to include in the exception if it is thrown.

Attributes

Remarks

If the calling process of an IPC you are handling has not been granted a particular permission, throw a SecurityException. This is basically the same as calling #enforcePermission(String, int, int, String) 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 throw the SecurityException. This is done to protect against accidentally leaking permissions; you can use #enforceCallingOrSelfPermission to avoid this protection.

Java documentation for android.content.Context.enforceCallingPermission(java.lang.String, 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