2017-01-07 16 views
9

私はGoogleの位置情報サービスを使用するための教訓に従っています。だから、私はGoogle APIサービスを使って位置情報を取得しようとしています。しかし、私はisGooglePlayServicesAvailable(これ)は廃止されました。誰も助けることができます。おかげで以下'googlePlayServicesAvailable'(これ)は推奨されていません

をチェックするための私のコードでプレイサービスがデバイス上に存在する場合:

private boolean checkPlayServices(){ 
    int resultCode = GooglePlayServicesUtil 
      .isGooglePlayServicesAvailable(this); 
    if(resultCode != ConnectionResult.SUCCESS){ 
     if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)){ 
      GooglePlayServicesUtil.getErrorDialog(resultCode, this, 
        PLAY_SERVICES_RESOLUTION_REQUEST).show(); 
     }else { 
      Toast.makeText(getApplicationContext(), 
        "This device is not supported", Toast.LENGTH_LONG) 
        .show(); 
      finish(); 
     } 
     return false; 
    } 
    return true; 
} 
+0

してくださいちょうど[、最小完全、かつ検証例]を使用します(http: //stackoverflow.com/help/mcve) – torkleyy

+3

** ['GooglePlayServicesUtil'](** https://developers.google.com/android/reference/com/google/android/gms/)のドキュメント**をご覧になり、共通/ GooglePlayServicesUtil#isGooglePlayServicesAvailable(android.content.Context))(あなたはdi d、そう?)、次のことは明らかではありませんでしたか? *このメソッドは廃止されました。代わりに、['GoogleApiAvailability.isGooglePlayServicesAvailable(Context)'](https://developers.google.com/android/reference/com/google/android/gms/common/GoogleApiAvailability#isGooglePlayServicesAvailable(android.content.Context))を使用してください。* – Andreas

答えて