I am having receiving connection callbacks for GoogleApiClient
in ConnectionCallbackListener#onConnected()
. As I understand GoogleApiClient.Builder#setHandler() determines the Handler
which will receive these callbacks. If not specified it is on the main thread.
However, I am specifically using a GcmTaskService
which abstracts the threading for me. This service creates the GoogleApiClient
whereby I should set the handler. However, I do not know how to get the handler from this service. Any ideas?
Within my custom GcmTaskService#onRunTask()
:
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(mContext)
.addApi(Fitness.RECORDING_API)
.addApi(Fitness.HISTORY_API)
.addApi(Fitness.SENSORS_API)
.addApi(Fitness.CONFIG_API)
.addScope(new Scope(Scopes.FITNESS_ACTIVITY_READ_WRITE))
.setHandler(handler)
.addConnectionCallbacks(this);