Android 活动上下文之外的GoogleAppClient
我希望为所有应用程序创建唯一一个mGoogleApiClient实例,并希望使用enableAutoManage方法或处理活动上下文之外的onConnectionFailed回调,例如在服务中 但是enableautomanagement方法需要一个FragmentActivity参数 还需要活动上下文来处理onConnectionFailed回调,如下所示:Android 活动上下文之外的GoogleAppClient,android,android-googleapiclient,Android,Android Googleapiclient,我希望为所有应用程序创建唯一一个mGoogleApiClient实例,并希望使用enableAutoManage方法或处理活动上下文之外的onConnectionFailed回调,例如在服务中 但是enableautomanagement方法需要一个FragmentActivity参数 还需要活动上下文来处理onConnectionFailed回调,如下所示: @Override public void onConnectionFailed(@NonNull ConnectionResult c
@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);
}
}
是否可以在没有此活动上下文的情况下执行此操作