Freigeben über


SubscriptionManager.SetOpportunistic(Boolean, Int32) Method

Definition

Set whether a subscription is opportunistic, that is, whether the network it connects to has limited coverage.

[Android.Runtime.Register("setOpportunistic", "(ZI)Z", "GetSetOpportunistic_ZIHandler", ApiSince=29)]
[Android.Runtime.RequiresPermission("android.permission.MODIFY_PHONE_STATE")]
public virtual bool SetOpportunistic (bool opportunistic, int subId);
[<Android.Runtime.Register("setOpportunistic", "(ZI)Z", "GetSetOpportunistic_ZIHandler", ApiSince=29)>]
[<Android.Runtime.RequiresPermission("android.permission.MODIFY_PHONE_STATE")>]
abstract member SetOpportunistic : bool * int -> bool
override this.SetOpportunistic : bool * int -> bool

Parameters

opportunistic
Boolean

whether it’s opportunistic subscription.

subId
Int32

the unique SubscriptionInfo index in database

Returns

true if the operation is succeed, false otherwise.

Attributes

Remarks

Set whether a subscription is opportunistic, that is, whether the network it connects to has limited coverage. For example, CBRS. Setting a subscription opportunistic has following impacts: 1) Even if it's active, it will be dormant most of the time. The modem will not try to scan or camp until it knows an available network is nearby to save power. 2) Telephony relies on system app or carrier input to notify nearby available networks. See TelephonyManager#updateAvailableNetworks(List, Executor, Consumer) for more information. 3) In multi-SIM devices, when the network is nearby and camped, system may automatically switch internet data between it and default data subscription, based on carrier recommendation and its signal strength and metered-ness, etc.

Caller will either have android.Manifest.permission#MODIFY_PHONE_STATE or carrier privilege permission of the subscription.

Java documentation for android.telephony.SubscriptionManager.setOpportunistic(boolean, int).

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