2015-12-14 91 views
2

我正在使用位置服務(使用Google位置服務)在我的應用上實施位置管理器,並且正在尋找一種方法來檢查設備系統上的位置是否已激活設置)。我正在像這樣連接到位置服務器:Android位置服務 - 檢查位置是否已激活

private synchronized void buildGoogleApiClient() { 
    mGoogleApiClient = new GoogleApiClient.Builder(mAppContext) 
      .addConnectionCallbacks(this) 
      .addOnConnectionFailedListener(this) 
      .addApi(LocationServices.API) 
      .build(); 
    createLocationRequest(); 
} 

private void createLocationRequest() { 
    mLocationRequest = new LocationRequest(); 
    mLocationRequest.setInterval(INTERVAL); 
    mLocationRequest.setFastestInterval(FASTEST_INTERVAL); 
    mLocationRequest.setSmallestDisplacement(SMALLEST_DISPLACEMENT); 
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); 
} 

有沒有辦法檢查系統的可用性位置設置?

回答

0

可能這有助於

LocationManager locateManager=(LocationManager)getSystemService(LOCATION_SERVICE); 
boolean enabled = locateManager.isProviderEnabled(LocationManager.GPS_PROVIDER); 
// check if enabled and if not send user to the GPS settings 
if (!enabled) { 
    Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); 
    startActivity(intent); 
} // Better solution would be to display a dialog and suggesting to go to the settings 
相關問題