2

I want to create the only one instance of mGoogleApiClient for all the application and want to use enableAutoManage method or handle onConnectionFailed call backs out of the activity context, for example in the sevice.

But the enableAutoManage method requires a FragmentActivity parameter.

Also the activity context is needed to handle onConnectionFailed callback like that:

@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    if (!connectionResult.hasResolution()) {
        GoogleApiAvailability.getInstance().showErrorNotification(context, connectionResult);
             GoogleApiAvailability.getInstance().getErrorDialog(mFragmentActivity, connectionResult.getErrorCode(), 0).show();
        return;
    }
    try {
        connectionResult.startResolutionForResult(mFragmentActivity, RequestCode.REQUEST_CODE_RESOLUTION);
    } catch (IntentSender.SendIntentException e) {
        Log.e(TAG, "Exception while starting resolution activity", e);
    }
}

Is it possible to do it without this activity context?

0 Answers0