2016-05-09 9 views
0

Googleドキュメントで重要なドキュメントが見落とされていることがよくわかりません。私はすでに禿げていない場合、私は私の髪を摘発していただろう。Google Playサービスを確認する

private void checkGooglePlayServices() { 
    int errorCode = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this); 
    boolean isErrorResolvable = GoogleApiAvailability.getInstance().isUserResolvableError(errorCode); 

    if (isErrorResolvable) { 
    GoogleApiAvailability.getInstance().getErrorDialog(this, errorCode, REQUEST_CODE_GOOGLE_PLAY_SERVICES).show(); 
    } else { 
    if (errorCode == ConnectionResult.SUCCESS) { 
     launchApplication(); 
    } 
    } 
} 

上記のコードが持っているというダイアログボックスが表示され、ボタンの読みGET Google Playのサービス

@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
    super.onActivityResult(requestCode, resultCode, data); 
    if (requestCode == REQUEST_CODE_GOOGLE_PLAY_SERVICES) { 

    } 
} 

今私がここで何をすべき?再生サービスのアップデートを入手するには、ユーザーをプレイストアにどのように誘導する必要がありますか?ここでは、 getErrorResolutionPendingIntentを使用するとしていますが、これについてどうやって行くのかは分かりません。

私を助けてください。

if (checkPlayServices()) { 
    // Do your calculation here. 
} 

private boolean checkPlayServices() { 
    GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); 
    int resultCode = apiAvailability.isGooglePlayServicesAvailable(this); 
    if (resultCode != ConnectionResult.SUCCESS) { 
     if (apiAvailability.isUserResolvableError(resultCode)) { 
      apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST) 
        .show(); 
     } else { 
      Log.i(TAG, "This device is not supported."); 
      finish(); 
     } 
     return false; 
    } 
    return true; 
} 

これは、Googleのプレイをチェックするのに役立ちます:

try { 
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE))); 
} catch (android.content.ActivityNotFoundException anfe) { 
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE))); 
} 

答えて

2

あなたは、GoogleがApp Storeでサービスのページを再生開くには、このコードを使用することができますサービス。

+0

ありがとうございました。これが私を悩ましていたものです。 –

3

あなたは、Googleがこれでサービスを再生確認することができます。

+0

ありがとうございます。それが有用であれば、答えを受け入れる。 – Dhruv

+0

これは私の問題には対処しません。私もあなたが上で提案したことを達成しました。私はGoogleの再生サービスの関連ページにプレイストアを開く方法を知らない。今すぐ「Google Playサービスを利用する」を押すと、onactivityresultが呼び出されます –

関連する問題