Added in API level 31

TelephonyCallback.CallStateListener


public static interface TelephonyCallback.CallStateListener

android.telephony.TelephonyCallback.CallStateListener


Interface for call state listener.

Summary

Public methods

abstract void onCallStateChanged(int state)

Callback invoked when device call state changes.

Public methods

onCallStateChanged

Added in API level 31
public abstract void onCallStateChanged (int state)

Callback invoked when device call state changes.

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

Note: the registration subscription ID comes from TelephonyManager object which registers TelephonyCallback by TelephonyManager#registerTelephonyCallback(Executor, TelephonyCallback). If this TelephonyManager object was created with TelephonyManager#createForSubscriptionId(int), then the callback applies to the subscription ID. 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 Manifest.permission.READ_PHONE_STATE

Parameters
state int: the current call state Value is TelephonyManager.CALL_STATE_IDLE, TelephonyManager.CALL_STATE_RINGING, or TelephonyManager.CALL_STATE_OFFHOOK