Sdílet prostřednictvím


TelephonyManager.SetDataEnabledForReason(Int32, Boolean) Method

Definition

Control of data connection and provide the reason triggering the data connection control.

[Android.Runtime.Register("setDataEnabledForReason", "(IZ)V", "GetSetDataEnabledForReason_IZHandler", ApiSince=31)]
[Android.Runtime.RequiresPermission("android.permission.MODIFY_PHONE_STATE")]
public virtual void SetDataEnabledForReason (int reason, bool enabled);
[<Android.Runtime.Register("setDataEnabledForReason", "(IZ)V", "GetSetDataEnabledForReason_IZHandler", ApiSince=31)>]
[<Android.Runtime.RequiresPermission("android.permission.MODIFY_PHONE_STATE")>]
abstract member SetDataEnabledForReason : int * bool -> unit
override this.SetDataEnabledForReason : int * bool -> unit

Parameters

reason
Int32

the reason the data enable change is taking place

enabled
Boolean

True if enabling the data, otherwise disabling.

        &lt;p&gt;Requires Permission:
        The calling app has carrier privileges (see <code data-dev-comment-type="c">#hasCarrierPrivileges</code>) if the reason is
        <code data-dev-comment-type="c">#DATA_ENABLED_REASON_USER</code> or <code data-dev-comment-type="c">#DATA_ENABLED_REASON_CARRIER</code> or the call app
        has <code data-dev-comment-type="c">android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE</code> irrespective of
        the reason.
Attributes

Remarks

Control of data connection and provide the reason triggering the data connection control. This can be called for following reasons <ol> <li>data limit is passed #DATA_ENABLED_REASON_POLICY<li>data disabled by carrier #DATA_ENABLED_REASON_CARRIER<li>data disabled by user #DATA_ENABLED_REASON_USER<li>data disabled due to thermal #DATA_ENABLED_REASON_THERMAL</ol> If any of the reason is off, then it will result in bypassing user preference and result in data to be turned off.

If this object has been created with #createForSubscriptionId, applies to the given subId. Otherwise, applies to SubscriptionManager#getDefaultDataSubscriptionId()

Java documentation for android.telephony.TelephonyManager.setDataEnabledForReason(int, boolean).

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