Share via


TelephonyManager.SetPreferredOpportunisticDataSubscription Method

Definition

Set preferred opportunistic data subscription id.

[Android.Runtime.Register("setPreferredOpportunisticDataSubscription", "(IZLjava/util/concurrent/Executor;Ljava/util/function/Consumer;)V", "GetSetPreferredOpportunisticDataSubscription_IZLjava_util_concurrent_Executor_Ljava_util_function_Consumer_Handler", ApiSince=29)]
public virtual void SetPreferredOpportunisticDataSubscription (int subId, bool needValidation, Java.Util.Concurrent.IExecutor? executor, Java.Util.Functions.IConsumer? callback);
[<Android.Runtime.Register("setPreferredOpportunisticDataSubscription", "(IZLjava/util/concurrent/Executor;Ljava/util/function/Consumer;)V", "GetSetPreferredOpportunisticDataSubscription_IZLjava_util_concurrent_Executor_Ljava_util_function_Consumer_Handler", ApiSince=29)>]
abstract member SetPreferredOpportunisticDataSubscription : int * bool * Java.Util.Concurrent.IExecutor * Java.Util.Functions.IConsumer -> unit
override this.SetPreferredOpportunisticDataSubscription : int * bool * Java.Util.Concurrent.IExecutor * Java.Util.Functions.IConsumer -> unit

Parameters

subId
Int32

which opportunistic subscription SubscriptionManager#getOpportunisticSubscriptions is preferred for cellular data. Pass SubscriptionManager#DEFAULT_SUBSCRIPTION_ID to unset the preference

needValidation
Boolean

whether validation is needed before switch happens.

executor
IExecutor

The executor of where the callback will execute.

callback
IConsumer

Callback will be triggered once it succeeds or failed. See TelephonyManager.SetOpportunisticSubscriptionResult for more details. Pass null if don't care about the result.

Attributes

Remarks

Set preferred opportunistic data subscription id.

Switch internet data to preferred opportunistic data subscription id. This api can result in lose of internet connectivity for short period of time while internet data is handed over.

Requires that the calling app has carrier privileges on both primary and secondary subscriptions (see #hasCarrierPrivileges), or has permission android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE.

Java documentation for android.telephony.TelephonyManager.setPreferredOpportunisticDataSubscription(int, boolean, java.util.concurrent.Executor, java.util.function.Consumer<java.lang.Integer>).

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