2017-01-07 14 views
9

Używam tutuorial do korzystania z usług lokalizacyjnych Google. Próbuję uzyskać lokalizację przy użyciu usługi Google API. Ale mam isGooglePlayServicesAvailable (ten) jest przestarzałym błędem. Czy ktoś może pomóc. Dzięki"isGooglePlayServicesAvailable" (to) jest przestarzałe.

Poniżej jest mój kod do sprawdzania, czy usługi odgrywają istnieje na urządzeniu:

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

Proszę po prostu użyć [Minimal, kompletne i weryfikowalne przykład] (http: //stackoverflow.com/help/mcve) – torkleyy

+3

Gdy ** zapoznałeś się z dokumentacją ** dla ['GooglePlayServicesUtil'] (https://developers.google.com/android/reference/com/google/android/gms/ common/GooglePlayServicesUtil # isGooglePlayServicesAvailable (android.content.Context)) (ty di tak, prawda?), następujące nie wydaje się oczywiste dla ciebie? * Ta metoda została uznana za przestarzałą. Zamiast tego użyj ['GoogleApiAvailability.isGooglePlayServicesAvailable (Kontekst)'] (https://developers.google.com/android/reference/com/google/android/gms/common/GoogleApiAvailability#isGooglePlayServicesAvailable (android.content.Context) *. – Andreas

Odpowiedz

Powiązane problemy