The second Android 11 Developer Preview is now available, test it out and share your feedback.

HoldingConnectionClient

open class HoldingConnectionClient
kotlin.Any
   ↳ androidx.ads.identifier.internal.HoldingConnectionClient

A client which keeps the ServiceConnection to the IAdvertisingIdService.

Summary

Public constructors

<init>(@NonNull context: Context)

Public methods

open Long

Gets a connection ID before using this client which prevents race condition with the auto disconnection task.

open IAdvertisingIdService

Gets the connected IAdvertisingIdService.

open String

Gets the connected service's package name.

open Boolean

Gets whether the client is connected to the IAdvertisingIdService.

open Boolean
tryFinish(connectionId: Long)

Tries to close the connection to the Advertising ID Provider Service if no one is using the client.

Public constructors

<init>

HoldingConnectionClient(@NonNull context: Context)

Public methods

askConnectionId

open fun askConnectionId(): Long

Gets a connection ID before using this client which prevents race condition with the auto disconnection task.

Return
Long connection ID, >= 0 indicates this client is connected, otherwise this client has already been disconnected.

getIdService

@NonNull open fun getIdService(): IAdvertisingIdService

Gets the connected IAdvertisingIdService.

getPackageName

@NonNull open fun getPackageName(): String

Gets the connected service's package name.

isConnected

open fun isConnected(): Boolean

Gets whether the client is connected to the IAdvertisingIdService.

tryFinish

open fun tryFinish(connectionId: Long): Boolean

Tries to close the connection to the Advertising ID Provider Service if no one is using the client.

Return
Boolean true if this client is disconnected after this method returns.