0
我想创建一个通用函数来检查谷歌播放服务是否可用。当我创建一个通用功能时,我不使用getErrorDialog
,因为它需要参考Activity
。如何使用getErrorResolutionPendingIntent来检查谷歌播放服务
我已经看到了几个更多的选项,如getErrorResolutionPendingIntent
,但我不知道如何使用它。
这里是代码
public static boolean isGooglePlayServiceAvailable(Activity activity){
GoogleApiAvailability googleService = GoogleApiAvailability.getInstance();
int result = googleService.isGooglePlayServicesAvailable(getContext());
if(result != ConnectionResult.SUCCESS){
if(googleService.isUserResolvableError(result)){
PendingIntent pendingResults = googleService.getErrorResolutionPendingIntent(getContext(), new ConnectionResult(result));
}else{
Log.e(TAG , "Device not supported");
}
return false;
}
return true;
}
如何使用它,如果我想在上面的代码中实现它 – Hunt