TetheringManager


open class TetheringManager
kotlin.Any
   ↳ android.net.TetheringManager

This class provides the APIs to control the tethering service.

The primary responsibilities of this class are to provide the APIs for applications to start tethering, stop tethering, query configuration and query status.

Summary

Nested classes
abstract

Callback for use with startTethering to find out whether tethering succeeded.

abstract

Callback for use with stopTethering to find out whether stop tethering succeeded.

abstract

Callback for use with registerTetheringEventCallback to find out tethering upstream status.

Use with startTethering to specify additional parameters when starting tethering.

Constants
static Int

Indicates that this tethering connection will provide connectivity beyond this device (e.g., global Internet access).

static Int

Wifi tethering type.

static Int

static Int

static Int

static Int

static Int

static Int

static Int

static Int

static Int

static Int

static Int

static Int

static Int

static Int

static Int

static Int

static Int

static Int

static Int

Public methods
open Unit

Start listening to tethering change events.

open Unit

Starts tethering and runs tether provisioning for the given type if needed.

open Unit

Stops tethering for the given request.

open Unit

Remove tethering event callback previously registered with registerTetheringEventCallback.

Constants

CONNECTIVITY_SCOPE_GLOBAL

static val CONNECTIVITY_SCOPE_GLOBAL: Int

Indicates that this tethering connection will provide connectivity beyond this device (e.g., global Internet access).

Value: 1

TETHERING_WIFI

static val TETHERING_WIFI: Int

Wifi tethering type.

Value: 0

See Also

    TETHER_ERROR_DHCPSERVER_ERROR

    static val TETHER_ERROR_DHCPSERVER_ERROR: Int
    Value: 12

    TETHER_ERROR_DISABLE_FORWARDING_ERROR

    static val TETHER_ERROR_DISABLE_FORWARDING_ERROR: Int
    Value: 9

    TETHER_ERROR_DUPLICATE_REQUEST

    static val TETHER_ERROR_DUPLICATE_REQUEST: Int
    Value: 18

    TETHER_ERROR_ENABLE_FORWARDING_ERROR

    static val TETHER_ERROR_ENABLE_FORWARDING_ERROR: Int
    Value: 8

    TETHER_ERROR_ENTITLEMENT_UNKNOWN

    static val TETHER_ERROR_ENTITLEMENT_UNKNOWN: Int
    Value: 13

    TETHER_ERROR_IFACE_CFG_ERROR

    static val TETHER_ERROR_IFACE_CFG_ERROR: Int
    Value: 10

    TETHER_ERROR_INTERNAL_ERROR

    static val TETHER_ERROR_INTERNAL_ERROR: Int
    Value: 5

    TETHER_ERROR_NO_ACCESS_TETHERING_PERMISSION

    static val TETHER_ERROR_NO_ACCESS_TETHERING_PERMISSION: Int
    Value: 15

    TETHER_ERROR_NO_CHANGE_TETHERING_PERMISSION

    static val TETHER_ERROR_NO_CHANGE_TETHERING_PERMISSION: Int
    Value: 14

    TETHER_ERROR_NO_ERROR

    static val TETHER_ERROR_NO_ERROR: Int
    Value: 0

    TETHER_ERROR_PROVISIONING_FAILED

    static val TETHER_ERROR_PROVISIONING_FAILED: Int
    Value: 11

    TETHER_ERROR_SERVICE_UNAVAIL

    static val TETHER_ERROR_SERVICE_UNAVAIL: Int
    Value: 2

    TETHER_ERROR_TETHER_IFACE_ERROR

    static val TETHER_ERROR_TETHER_IFACE_ERROR: Int
    Value: 6

    TETHER_ERROR_UNAVAIL_IFACE

    static val TETHER_ERROR_UNAVAIL_IFACE: Int
    Value: 4

    TETHER_ERROR_UNKNOWN_IFACE

    static val TETHER_ERROR_UNKNOWN_IFACE: Int
    Value: 1

    TETHER_ERROR_UNKNOWN_REQUEST

    static val TETHER_ERROR_UNKNOWN_REQUEST: Int
    Value: 17

    TETHER_ERROR_UNKNOWN_TYPE

    static val TETHER_ERROR_UNKNOWN_TYPE: Int
    Value: 16

    TETHER_ERROR_UNSUPPORTED

    static val TETHER_ERROR_UNSUPPORTED: Int
    Value: 3

    TETHER_ERROR_UNTETHER_IFACE_ERROR

    static val TETHER_ERROR_UNTETHER_IFACE_ERROR: Int
    Value: 7

    Public methods

    registerTetheringEventCallback

    open fun registerTetheringEventCallback(
        executor: Executor,
        callback: TetheringManager.TetheringEventCallback
    ): Unit

    Start listening to tethering change events. Any new added callback will receive the last tethering status right away. If callback is registered, android.net.TetheringManager.TetheringEventCallback#onUpstreamChanged will immediately be called. If tethering has no upstream or disabled, the argument of callback will be null. The same callback object cannot be registered twice.
    Requires android.Manifest.permission#ACCESS_NETWORK_STATE

    Parameters
    executor Executor: the executor on which callback will be invoked. This value cannot be null.
    callback TetheringManager.TetheringEventCallback: the callback to be called when tethering has change events. This value cannot be null.

    startTethering

    open fun startTethering(
        request: TetheringManager.TetheringRequest,
        executor: Executor,
        callback: TetheringManager.StartTetheringCallback
    ): Unit

    Starts tethering and runs tether provisioning for the given type if needed. If provisioning fails, stopTethering will be called automatically.

    Parameters
    request TetheringManager.TetheringRequest: a TetheringRequest which can specify the preferred configuration. This value cannot be null.
    executor Executor: Executor to specify the thread upon which the callback of TetheringRequest will be invoked. This value cannot be null.
    callback TetheringManager.StartTetheringCallback: A callback that will be called to indicate the success status of the tethering start request. This value cannot be null.

    stopTethering

    open fun stopTethering(
        request: TetheringManager.TetheringRequest,
        executor: Executor,
        callback: TetheringManager.StopTetheringCallback
    ): Unit

    Stops tethering for the given request. Operation will fail with TETHER_ERROR_UNKNOWN_REQUEST if there is no request that matches it.

    Parameters
    request TetheringManager.TetheringRequest: This value cannot be null.
    executor Executor: This value cannot be null.
    callback TetheringManager.StopTetheringCallback: This value cannot be null.

    unregisterTetheringEventCallback

    open fun unregisterTetheringEventCallback(callback: TetheringManager.TetheringEventCallback): Unit

    Remove tethering event callback previously registered with registerTetheringEventCallback.
    Requires android.Manifest.permission#TETHER_PRIVILEGED or android.Manifest.permission#ACCESS_NETWORK_STATE

    Parameters
    callback TetheringManager.TetheringEventCallback: previously registered callback. This value cannot be null.