2015-05-09 178 views
1

我想使用谷歌播放服務的位置,但每次我用下面的代碼:isGooglePlayServicesAvailable始終返回false

resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); 

我會回來虛假僅作爲一個結果。當然,當我想初始化一個新的位置客戶端(我知道它已經過時)

mLocationClient = new LocationClient(this, this, this); 

我只得到虛假回來。 我的錯誤在哪裏?是否需要在手機上更新Google Play服務?我已經檢查過系統更新,其中有最新的一個。這是一個銀河S5迷你,如果這可能有所幫助。

回答

0

有幾種可能性,你得到的是錯誤

  • 服務已經過時
  • 服務被禁用/刪除
  • 另一個三星相關的bug

我已經使用這個功能檢查服務是否足夠新,否則我會得到一個對話框,並重定向到谷歌播放更新它們

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 { 
      finish(); 
     } 
     return false; 
    } 
    return true; 
} 

它會顯示錯誤。