HoldingConnectionClient

public class HoldingConnectionClient


A client which keeps the ServiceConnection to the IAdvertisingIdService.

Summary

Public constructors

Public methods

@NonNull long

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

@NonNull IAdvertisingIdService

Gets the connected IAdvertisingIdService.

@NonNull String

Gets the connected service's package name.

@NonNull boolean

Gets whether the client is connected to the IAdvertisingIdService.

@NonNull boolean
tryFinish(@NonNull long connectionId)

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

Public constructors

HoldingConnectionClient

@WorkerThread
public HoldingConnectionClient(@NonNull Context context)

Public methods

askConnectionId

@NonNull
public long askConnectionId()

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

Returns
long

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

getIdService

@NonNull
public IAdvertisingIdService getIdService()

Gets the connected IAdvertisingIdService.

getPackageName

@NonNull
public String getPackageName()

Gets the connected service's package name.

isConnected

@NonNull
public boolean isConnected()

Gets whether the client is connected to the IAdvertisingIdService.

tryFinish

@NonNull
public boolean tryFinish(@NonNull long connectionId)

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

Returns
boolean

true if this client is disconnected after this method returns.