2016-11-18 9 views
0

Google Playサービスが利用可能かどうかを確認する共通の機能を作成しようとしています。私は共通の機能を作成しているので、参照番号Activityが必要なので、getErrorDialogを使用していません。getErrorResolutionPendingIntentを使用してGoogle Playサービスを確認する方法

私はそれに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; 

    } 

答えて

0

PendingIntent.sendです。ドキュメントからも

hasResolution()がtrueの場合、getResolution()が返されます。 そうでない場合、返されたPendingIntentは、Google Playサービスが古くなっていないか見つからない場合は Playストアに誘導し、デバイスでGoogle Playサービスが無効になっている場合は システム設定を行います。

+1

上記のコードで実装する方法 – Hunt

関連する問題