Udostępnij za pośrednictwem


PhoneStateListener.OnCallStateChanged(CallState, String) Method

Definition

Callback invoked when device call state changes.

[Android.Runtime.Register("onCallStateChanged", "(ILjava/lang/String;)V", "GetOnCallStateChanged_ILjava_lang_String_Handler")]
[Android.Runtime.RequiresPermission("android.permission.READ_PHONE_STATE")]
public virtual void OnCallStateChanged (Android.Telephony.CallState state, string? phoneNumber);
[<Android.Runtime.Register("onCallStateChanged", "(ILjava/lang/String;)V", "GetOnCallStateChanged_ILjava_lang_String_Handler")>]
[<Android.Runtime.RequiresPermission("android.permission.READ_PHONE_STATE")>]
abstract member OnCallStateChanged : Android.Telephony.CallState * string -> unit
override this.OnCallStateChanged : Android.Telephony.CallState * string -> unit

Parameters

state
CallState

call state

phoneNumber
String

call phone number. If application does not have android.Manifest.permission#READ_CALL_LOG READ_CALL_LOG permission or carrier privileges (see TelephonyManager#hasCarrierPrivileges), an empty string will be passed as an argument.

Attributes

Remarks

Callback invoked when device call state changes.

Reports the state of Telephony (mobile) calls on the device for the registered subscription.

Note: the registration subId comes from TelephonyManager object which registers PhoneStateListener by TelephonyManager#listen(PhoneStateListener, int). If this TelephonyManager object was created with TelephonyManager#createForSubscriptionId(int), then the callback applies to the subId. Otherwise, this callback applies to SubscriptionManager#getDefaultSubscriptionId().

Note: The state returned here may differ from that returned by TelephonyManager#getCallState(). Receivers of this callback should be aware that calling TelephonyManager#getCallState() from within this callback may return a different state than the callback reports.

Requires Permission: android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE for applications targeting API level 31+.

This member is deprecated. Use TelephonyCallback.CallStateListener instead.

Java documentation for android.telephony.PhoneStateListener.onCallStateChanged(int, 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