2017-12-27 5 views
2

누락되었을 때 나는 플레이 서비스가 평소와 같이 사용할 수 있는지 여부를 확인하는 코드를 구현 한 ConnectionResult.SUCCESS를 반환isGooglePlayServicesAvailable는() 서비스가

mGooglePlayServicesAvailable = false; 
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); 
int resultCode = apiAvailability.isGooglePlayServicesAvailable(this); 
if (resultCode == ConnectionResult.SUCCESS) { 
    mGooglePlayServicesAvailable = true; 
} 
else if (apiAvailability.isUserResolvableError(resultCode)) { 
    apiAvailability.getErrorDialog(this, resultCode, RC_AVAILABILITY).show(); 
} 

내 문제의 resultCode이 경우에도 ConnectionResult.SUCCESS 것 같다입니다 서비스가 누락되었습니다. 많은 기기에서 안드로이드 앱이 다운됩니다.

P. logcat에서 다음 줄을 볼 수 있습니다. 다소 이상합니다.

E/GooglePlayServicesUtil(12419): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included. 

이 동작을 일으킬 수있는 것에 대한 아이디어가 있습니까? 아니면 게임을 사용할 수 있는지 확인하는 더 좋은 방법이 있습니까?

미리 감사드립니다.

답변

0

일부 연구를 통해 ConnectionResult.SUCCESS의 이유는 'Google Play 서비스'가 실제로 사용 가능하고 최신 상태임을 알게되었습니다. 비활성화 된 응용 프로그램은 '구글이 게임을 플레이', 그래서 난 그냥 더이 상황을 처리하기 위해 내 코드를 조금 확장했다 :

mGooglePlayGamesAvailable = false; 
try { 
    int status = getPackageManager().getApplicationEnabledSetting("com.google.android.play.games"); 
    switch(status) { 
     case PackageManager.COMPONENT_ENABLED_STATE_DEFAULT: 
     case PackageManager.COMPONENT_ENABLED_STATE_ENABLED: 
      // check if play services are up to date 
      GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); 
      int resultCode = apiAvailability.isGooglePlayServicesAvailable(this); 
      if (resultCode == ConnectionResult.SUCCESS) { 
       mGooglePlayGamesAvailable = true; 
      } 
      else if (apiAvailability.isUserResolvableError(resultCode)) { 
       apiAvailability.getErrorDialog(this, resultCode, RC_AVAILABILITY).show(); 
      } 
      break; 
    } 

} catch(IllegalArgumentException e) {} 

나는 이것이 당신의 관심과 행복 코딩 사람이 많은 덕분에 도움이되기를 바랍니다.

P. 이 솔루션이 충분히 우아하지 않다고 생각한다면 의견을 보내주십시오.

관련 문제