다음을 통해 공유


TelephonyManager.RegisterTelephonyCallback Method

Definition

Overloads

RegisterTelephonyCallback(IExecutor, TelephonyCallback)

Registers a callback object to receive notification of changes in specified telephony states.

RegisterTelephonyCallback(Int32, IExecutor, TelephonyCallback)

Registers a callback object to receive notification of changes in specified telephony states.

RegisterTelephonyCallback(IExecutor, TelephonyCallback)

Registers a callback object to receive notification of changes in specified telephony states.

[Android.Runtime.Register("registerTelephonyCallback", "(Ljava/util/concurrent/Executor;Landroid/telephony/TelephonyCallback;)V", "GetRegisterTelephonyCallback_Ljava_util_concurrent_Executor_Landroid_telephony_TelephonyCallback_Handler", ApiSince=31)]
public virtual void RegisterTelephonyCallback (Java.Util.Concurrent.IExecutor executor, Android.Telephony.TelephonyCallback callback);
[<Android.Runtime.Register("registerTelephonyCallback", "(Ljava/util/concurrent/Executor;Landroid/telephony/TelephonyCallback;)V", "GetRegisterTelephonyCallback_Ljava_util_concurrent_Executor_Landroid_telephony_TelephonyCallback_Handler", ApiSince=31)>]
abstract member RegisterTelephonyCallback : Java.Util.Concurrent.IExecutor * Android.Telephony.TelephonyCallback -> unit
override this.RegisterTelephonyCallback : Java.Util.Concurrent.IExecutor * Android.Telephony.TelephonyCallback -> unit

Parameters

executor
IExecutor

The executor of where the callback will execute.

callback
TelephonyCallback

The TelephonyCallback object to register. The caller should hold a reference to the callback. The framework only holds a weak reference.

Attributes

Remarks

Registers a callback object to receive notification of changes in specified telephony states.

To register a callback, pass a TelephonyCallback which implements interfaces of events. For example, FakeServiceStateCallback extends TelephonyCallback implements TelephonyCallback.ServiceStateListener.

At registration, and when a specified telephony state changes, the telephony manager invokes the appropriate callback method on the callback object and passes the current (updated) values.

Note: Be aware of the permission requirements stated on the TelephonyCallback listeners you implement. Your application must be granted these permissions in order to register a TelephonyCallback which requires them; a SecurityException will be thrown if you do not hold the required permissions for all TelephonyCallback listeners you implement.

If this TelephonyManager object has been created with #createForSubscriptionId, applies to the given subId. Otherwise, applies to SubscriptionManager#getDefaultSubscriptionId(). To register events for multiple subIds, pass a separate callback object to each TelephonyManager object created with #createForSubscriptionId.

Note: if you call this method while in the middle of a binder transaction, you <b>must</b> call android.os.Binder#clearCallingIdentity() before calling this method. A SecurityException will be thrown otherwise.

This API should be used sparingly -- large numbers of callbacks will cause system instability. If a process has registered too many callbacks without unregistering them, it may encounter an IllegalStateException when trying to register more callbacks.

Java documentation for android.telephony.TelephonyManager.registerTelephonyCallback(java.util.concurrent.Executor, android.telephony.TelephonyCallback).

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

RegisterTelephonyCallback(Int32, IExecutor, TelephonyCallback)

Registers a callback object to receive notification of changes in specified telephony states.

[Android.Runtime.Register("registerTelephonyCallback", "(ILjava/util/concurrent/Executor;Landroid/telephony/TelephonyCallback;)V", "GetRegisterTelephonyCallback_ILjava_util_concurrent_Executor_Landroid_telephony_TelephonyCallback_Handler", ApiSince=33)]
public virtual void RegisterTelephonyCallback (int includeLocationData, Java.Util.Concurrent.IExecutor executor, Android.Telephony.TelephonyCallback callback);
[<Android.Runtime.Register("registerTelephonyCallback", "(ILjava/util/concurrent/Executor;Landroid/telephony/TelephonyCallback;)V", "GetRegisterTelephonyCallback_ILjava_util_concurrent_Executor_Landroid_telephony_TelephonyCallback_Handler", ApiSince=33)>]
abstract member RegisterTelephonyCallback : int * Java.Util.Concurrent.IExecutor * Android.Telephony.TelephonyCallback -> unit
override this.RegisterTelephonyCallback : int * Java.Util.Concurrent.IExecutor * Android.Telephony.TelephonyCallback -> unit

Parameters

includeLocationData
Int32

Specifies if the caller would like to receive location related information.

executor
IExecutor

The executor of where the callback will execute.

callback
TelephonyCallback

The TelephonyCallback object to register. The caller should hold a reference to the callback. The framework only holds a weak reference.

Attributes

Remarks

Registers a callback object to receive notification of changes in specified telephony states.

To register a callback, pass a TelephonyCallback which implements interfaces of events. For example, FakeServiceStateCallback extends TelephonyCallback implements TelephonyCallback.ServiceStateListener.

At registration, and when a specified telephony state changes, the telephony manager invokes the appropriate callback method on the callback object and passes the current (updated) values.

If this TelephonyManager object has been created with #createForSubscriptionId, applies to the given subId. Otherwise, applies to SubscriptionManager#getDefaultSubscriptionId(). To register events for multiple subIds, pass a separate callback object to each TelephonyManager object created with #createForSubscriptionId.

Note: if you call this method while in the middle of a binder transaction, you <b>must</b> call android.os.Binder#clearCallingIdentity() before calling this method. A SecurityException will be thrown otherwise.

This API should be used sparingly -- large numbers of callbacks will cause system instability. If a process has registered too many callbacks without unregistering them, it may encounter an IllegalStateException when trying to register more callbacks.

There's another way to renounce permissions with a custom context AttributionSource.Builder#setRenouncedPermissions(Set<String>) but only for system apps. To avoid confusion, calling this method supersede renouncing permissions with a custom context.

Java documentation for android.telephony.TelephonyManager.registerTelephonyCallback(int, java.util.concurrent.Executor, android.telephony.TelephonyCallback).

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