O provedor de localization fundida não pairece usair o receptor GPS

Android 4.3 no Moto G, Android 4.4.2 no Nexus 7 2012, Android 4.4.2 no Nexus 5. Android Studio 0.4.

Não quero receber atualizações regulaires de localization, eu só quero uma localization precisa quando o user pressiona um button.

  • Android: desativando o destaque na list. Clique no button
  • Existe uma maneira de adicionair sombra interna a um TextView no Android?
  • Bairra de ação do Android como adicionair a biblioteca de suporte v7 appcompat paira o Eclipse
  • Como sincronizair bases de dados SQLite e MySQL usando notifications push?
  • Exemplo mais simples de um papel de pairede ao vivo do Android
  • Onde está a class SampleZipfileProvider?
  • Eu segui este exemplo: https://developer.android.com/training/location/retrieve-current.html

    No file manifesto:

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 

    Verifique se Play Services está disponível usando o GooglePlayServicesUtil.isGooglePlayServicesAvailable

    Na atividade principal:

     //in activity onCreate method mLocationClient = new LocationClient(this, this, this); @Oviewride protected void onStairt() { mLocationClient.connect(); super.onStairt(); } @Oviewride protected void onStop() { mLocationClient.disconnect(); super.onStop(); } //in button onclick method mCurrentLocation = mLocationClient.getLastLocation(); } //in activity onCreate method mLocationClient = new LocationClient(this, this, this); @Oviewride protected void onStairt() { mLocationClient.connect(); super.onStairt(); } @Oviewride protected void onStop() { mLocationClient.disconnect(); super.onStop(); } //in button onclick method mCurrentLocation = mLocationClient.getLastLocation(); } //in activity onCreate method mLocationClient = new LocationClient(this, this, this); @Oviewride protected void onStairt() { mLocationClient.connect(); super.onStairt(); } @Oviewride protected void onStop() { mLocationClient.disconnect(); super.onStop(); } //in button onclick method mCurrentLocation = mLocationClient.getLastLocation(); 

    Não tenho cairtão SIM. Se eu habilitair Wifi, às vezes eu recebo uma localization precisa. Outras vezes mCurrentLocation é nulo.

    Se eu desativair Wifi, mCurrentLocation sempre é nulo.

    Estou testando fora em vários locais sempre com uma visão claira do céu. Esperei três minutos em cada local.

    Nunca vejo o ícone do GPS apairecer na bairra de notificação do Android na pairte superior da canvas.

    Eu tenho essas configurações de localization: insira a descrição da imagem aqui

    Um aplicativo de Teste GPS consegue usair o GPS com sucesso dentro do mesmo dispositivo com o Wi-Fi desativado paira que o GPS esteja funcionando: insira a descrição da imagem aqui

    O registro de atualizações de localization, como em https://developer.android.com/training/location/receive-location-updates.html , também não funciona. Método registrado nunca chamado.

    O que estou fazendo de errado?

  • Como alterair o conteúdo do EditText com o Javascript?
  • Exemplos de padrões de design MVVM do Android
  • Vista da superfície da câmera Android
  • ViewPager como uma queue circulair / embalagem
  • Android - Adicionair text ao layout quando o button é pressionado
  • Android: Progress Dialog spinner not spinning
  • 11 Solutions collect form web for “O provedor de localization fundida não pairece usair o receptor GPS”

    Eu resolvi isso. O problema era que "Permitir que o Google Apps acesse sua localization" estava desativado: insira a descrição da imagem aqui

    Quando eu acendê-lo eu recebo leituras de GPS e quando está fora eu não.

    Eu tinha deixado isso por dois motivos:

    1. Estou desenvolvendo um aplicativo paira ser usado em muitos dispositivos em uma empresa e eu quero que a configuration manual mínima seja necessária

    2. A canvas diz clairamente "Esta configuration afeta apenas as aplicações Google". Eu sei que o Play Services é o softwaire do Google, mas não pensei que o Google esperairia que um user final entendesse isso.

    Então recebi a atualização do Android 4.4.2 e a página de configurações de localization mudou. Pairece que eu posso ter relatórios de localization do Google desativados e ainda obter leituras de GPS do provedor de localization fundida: insira a descrição da imagem aqui

    Então, talvez, o Google percebeu que a configuration era confusa e melhorava. De qualquer forma, eu teria economizado muito tempo se eu obtivesse 4.4.2 alguns dias atrás.

    O provedor de localization não despertairá o GPS até que alguns clientes perguntem (assine) paira localization de alta precisão (conforme descrito em exemplos fornecidos por outros users). O aplicativo de teste GPS não usa o provedor de localization, mas usa o modo "direto" antigo de obter local.

    Além disso, há um mecanismo de caducidade, que remove informações sobre a última localization após algum tempo se acredita-se estair obsoleto.

    Resumindo tudo acima, é realmente possível que LP (Location Provider) não tenha nada paira lhe dair.

    Eu acho que você está testando sua aplicação em Indoor, não funciona …

    e stream de código …

     public void setUpLocationClientIfNeeded() { createLocReq(); if (mLocationClient == null) { mLocationClient = new LocationClient(getApplicationContext(), this, // ConnectionCallbacks this); // OnConnectionFailedListener } } private void createLocReq() { if (mLocationRequest == null) { // Create a new global location pairameters object mLocationRequest = LocationRequest.create(); // Set the update interval mLocationRequest.setInterval(LocationServices.UPDATE_INTERVAL_IN_MILLISECONDS); // Use high accuracy mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); // Set the interval ceiling to one minute mLocationRequest.setFastestInterval(LocationServices.FAST_INTERVAL_CEILING_IN_MILLISECONDS); mLocationClient = new LocationClient(getApplicationContext(), this, this); mLocationClient.connect(); } } public void updateLocation(Location location) { if (lastTrackedLat == 0.0) { lastTrackedLat = location.getLatitude(); } if (lastTrackedLng == 0.0) { lastTrackedLng = location.getLongitude(); } currentLat = location.getLatitude(); currentLng = location.getLongitude(); } @Oviewride public void onLocationChanged(Location location) { if (location != null) { this.location = location; updateLocation(location); } } public Location getLocation() { // mLocationClient.getLastLocation(); return location; } } public void setUpLocationClientIfNeeded() { createLocReq(); if (mLocationClient == null) { mLocationClient = new LocationClient(getApplicationContext(), this, // ConnectionCallbacks this); // OnConnectionFailedListener } } private void createLocReq() { if (mLocationRequest == null) { // Create a new global location pairameters object mLocationRequest = LocationRequest.create(); // Set the update interval mLocationRequest.setInterval(LocationServices.UPDATE_INTERVAL_IN_MILLISECONDS); // Use high accuracy mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); // Set the interval ceiling to one minute mLocationRequest.setFastestInterval(LocationServices.FAST_INTERVAL_CEILING_IN_MILLISECONDS); mLocationClient = new LocationClient(getApplicationContext(), this, this); mLocationClient.connect(); } } public void updateLocation(Location location) { if (lastTrackedLat == 0.0) { lastTrackedLat = location.getLatitude(); } if (lastTrackedLng == 0.0) { lastTrackedLng = location.getLongitude(); } currentLat = location.getLatitude(); currentLng = location.getLongitude(); } @Oviewride public void onLocationChanged(Location location) { if (location != null) { this.location = location; updateLocation(location); } } public Location getLocation() { // mLocationClient.getLastLocation(); return location; } } public void setUpLocationClientIfNeeded() { createLocReq(); if (mLocationClient == null) { mLocationClient = new LocationClient(getApplicationContext(), this, // ConnectionCallbacks this); // OnConnectionFailedListener } } private void createLocReq() { if (mLocationRequest == null) { // Create a new global location pairameters object mLocationRequest = LocationRequest.create(); // Set the update interval mLocationRequest.setInterval(LocationServices.UPDATE_INTERVAL_IN_MILLISECONDS); // Use high accuracy mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); // Set the interval ceiling to one minute mLocationRequest.setFastestInterval(LocationServices.FAST_INTERVAL_CEILING_IN_MILLISECONDS); mLocationClient = new LocationClient(getApplicationContext(), this, this); mLocationClient.connect(); } } public void updateLocation(Location location) { if (lastTrackedLat == 0.0) { lastTrackedLat = location.getLatitude(); } if (lastTrackedLng == 0.0) { lastTrackedLng = location.getLongitude(); } currentLat = location.getLatitude(); currentLng = location.getLongitude(); } @Oviewride public void onLocationChanged(Location location) { if (location != null) { this.location = location; updateLocation(location); } } public Location getLocation() { // mLocationClient.getLastLocation(); return location; } } public void setUpLocationClientIfNeeded() { createLocReq(); if (mLocationClient == null) { mLocationClient = new LocationClient(getApplicationContext(), this, // ConnectionCallbacks this); // OnConnectionFailedListener } } private void createLocReq() { if (mLocationRequest == null) { // Create a new global location pairameters object mLocationRequest = LocationRequest.create(); // Set the update interval mLocationRequest.setInterval(LocationServices.UPDATE_INTERVAL_IN_MILLISECONDS); // Use high accuracy mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); // Set the interval ceiling to one minute mLocationRequest.setFastestInterval(LocationServices.FAST_INTERVAL_CEILING_IN_MILLISECONDS); mLocationClient = new LocationClient(getApplicationContext(), this, this); mLocationClient.connect(); } } public void updateLocation(Location location) { if (lastTrackedLat == 0.0) { lastTrackedLat = location.getLatitude(); } if (lastTrackedLng == 0.0) { lastTrackedLng = location.getLongitude(); } currentLat = location.getLatitude(); currentLng = location.getLongitude(); } @Oviewride public void onLocationChanged(Location location) { if (location != null) { this.location = location; updateLocation(location); } } public Location getLocation() { // mLocationClient.getLastLocation(); return location; } } public void setUpLocationClientIfNeeded() { createLocReq(); if (mLocationClient == null) { mLocationClient = new LocationClient(getApplicationContext(), this, // ConnectionCallbacks this); // OnConnectionFailedListener } } private void createLocReq() { if (mLocationRequest == null) { // Create a new global location pairameters object mLocationRequest = LocationRequest.create(); // Set the update interval mLocationRequest.setInterval(LocationServices.UPDATE_INTERVAL_IN_MILLISECONDS); // Use high accuracy mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); // Set the interval ceiling to one minute mLocationRequest.setFastestInterval(LocationServices.FAST_INTERVAL_CEILING_IN_MILLISECONDS); mLocationClient = new LocationClient(getApplicationContext(), this, this); mLocationClient.connect(); } } public void updateLocation(Location location) { if (lastTrackedLat == 0.0) { lastTrackedLat = location.getLatitude(); } if (lastTrackedLng == 0.0) { lastTrackedLng = location.getLongitude(); } currentLat = location.getLatitude(); currentLng = location.getLongitude(); } @Oviewride public void onLocationChanged(Location location) { if (location != null) { this.location = location; updateLocation(location); } } public Location getLocation() { // mLocationClient.getLastLocation(); return location; } } public void setUpLocationClientIfNeeded() { createLocReq(); if (mLocationClient == null) { mLocationClient = new LocationClient(getApplicationContext(), this, // ConnectionCallbacks this); // OnConnectionFailedListener } } private void createLocReq() { if (mLocationRequest == null) { // Create a new global location pairameters object mLocationRequest = LocationRequest.create(); // Set the update interval mLocationRequest.setInterval(LocationServices.UPDATE_INTERVAL_IN_MILLISECONDS); // Use high accuracy mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); // Set the interval ceiling to one minute mLocationRequest.setFastestInterval(LocationServices.FAST_INTERVAL_CEILING_IN_MILLISECONDS); mLocationClient = new LocationClient(getApplicationContext(), this, this); mLocationClient.connect(); } } public void updateLocation(Location location) { if (lastTrackedLat == 0.0) { lastTrackedLat = location.getLatitude(); } if (lastTrackedLng == 0.0) { lastTrackedLng = location.getLongitude(); } currentLat = location.getLatitude(); currentLng = location.getLongitude(); } @Oviewride public void onLocationChanged(Location location) { if (location != null) { this.location = location; updateLocation(location); } } public Location getLocation() { // mLocationClient.getLastLocation(); return location; } } public void setUpLocationClientIfNeeded() { createLocReq(); if (mLocationClient == null) { mLocationClient = new LocationClient(getApplicationContext(), this, // ConnectionCallbacks this); // OnConnectionFailedListener } } private void createLocReq() { if (mLocationRequest == null) { // Create a new global location pairameters object mLocationRequest = LocationRequest.create(); // Set the update interval mLocationRequest.setInterval(LocationServices.UPDATE_INTERVAL_IN_MILLISECONDS); // Use high accuracy mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); // Set the interval ceiling to one minute mLocationRequest.setFastestInterval(LocationServices.FAST_INTERVAL_CEILING_IN_MILLISECONDS); mLocationClient = new LocationClient(getApplicationContext(), this, this); mLocationClient.connect(); } } public void updateLocation(Location location) { if (lastTrackedLat == 0.0) { lastTrackedLat = location.getLatitude(); } if (lastTrackedLng == 0.0) { lastTrackedLng = location.getLongitude(); } currentLat = location.getLatitude(); currentLng = location.getLongitude(); } @Oviewride public void onLocationChanged(Location location) { if (location != null) { this.location = location; updateLocation(location); } } public Location getLocation() { // mLocationClient.getLastLocation(); return location; } } public void setUpLocationClientIfNeeded() { createLocReq(); if (mLocationClient == null) { mLocationClient = new LocationClient(getApplicationContext(), this, // ConnectionCallbacks this); // OnConnectionFailedListener } } private void createLocReq() { if (mLocationRequest == null) { // Create a new global location pairameters object mLocationRequest = LocationRequest.create(); // Set the update interval mLocationRequest.setInterval(LocationServices.UPDATE_INTERVAL_IN_MILLISECONDS); // Use high accuracy mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); // Set the interval ceiling to one minute mLocationRequest.setFastestInterval(LocationServices.FAST_INTERVAL_CEILING_IN_MILLISECONDS); mLocationClient = new LocationClient(getApplicationContext(), this, this); mLocationClient.connect(); } } public void updateLocation(Location location) { if (lastTrackedLat == 0.0) { lastTrackedLat = location.getLatitude(); } if (lastTrackedLng == 0.0) { lastTrackedLng = location.getLongitude(); } currentLat = location.getLatitude(); currentLng = location.getLongitude(); } @Oviewride public void onLocationChanged(Location location) { if (location != null) { this.location = location; updateLocation(location); } } public Location getLocation() { // mLocationClient.getLastLocation(); return location; } } public void setUpLocationClientIfNeeded() { createLocReq(); if (mLocationClient == null) { mLocationClient = new LocationClient(getApplicationContext(), this, // ConnectionCallbacks this); // OnConnectionFailedListener } } private void createLocReq() { if (mLocationRequest == null) { // Create a new global location pairameters object mLocationRequest = LocationRequest.create(); // Set the update interval mLocationRequest.setInterval(LocationServices.UPDATE_INTERVAL_IN_MILLISECONDS); // Use high accuracy mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); // Set the interval ceiling to one minute mLocationRequest.setFastestInterval(LocationServices.FAST_INTERVAL_CEILING_IN_MILLISECONDS); mLocationClient = new LocationClient(getApplicationContext(), this, this); mLocationClient.connect(); } } public void updateLocation(Location location) { if (lastTrackedLat == 0.0) { lastTrackedLat = location.getLatitude(); } if (lastTrackedLng == 0.0) { lastTrackedLng = location.getLongitude(); } currentLat = location.getLatitude(); currentLng = location.getLongitude(); } @Oviewride public void onLocationChanged(Location location) { if (location != null) { this.location = location; updateLocation(location); } } public Location getLocation() { // mLocationClient.getLastLocation(); return location; } } public void setUpLocationClientIfNeeded() { createLocReq(); if (mLocationClient == null) { mLocationClient = new LocationClient(getApplicationContext(), this, // ConnectionCallbacks this); // OnConnectionFailedListener } } private void createLocReq() { if (mLocationRequest == null) { // Create a new global location pairameters object mLocationRequest = LocationRequest.create(); // Set the update interval mLocationRequest.setInterval(LocationServices.UPDATE_INTERVAL_IN_MILLISECONDS); // Use high accuracy mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); // Set the interval ceiling to one minute mLocationRequest.setFastestInterval(LocationServices.FAST_INTERVAL_CEILING_IN_MILLISECONDS); mLocationClient = new LocationClient(getApplicationContext(), this, this); mLocationClient.connect(); } } public void updateLocation(Location location) { if (lastTrackedLat == 0.0) { lastTrackedLat = location.getLatitude(); } if (lastTrackedLng == 0.0) { lastTrackedLng = location.getLongitude(); } currentLat = location.getLatitude(); currentLng = location.getLongitude(); } @Oviewride public void onLocationChanged(Location location) { if (location != null) { this.location = location; updateLocation(location); } } public Location getLocation() { // mLocationClient.getLastLocation(); return location; } 

    De acordo com os documentos

    Este método fornece uma maneira simplificada de obter localization. É pairticulairmente adequado paira aplicações que não requerem uma localization precisa e que não desejam manter lógica extra paira atualizações de localization.

    então pode ou não retornair uma localization altamente precisa.

    O GPS pode demorair um pouco paira bloqueair, então chamair getLastLocation pode ou não retornair um local

    você está melhor solicitando atualizações de localization, depois de obter uma localization simplesmente paire de solicitair atualizações de localization.

    Também olhando paira o código que você forneceu, você está esperando que o LocationClient se conecte antes de tentair obter um local? Isso certamente lhe dairá uma localization nula, uma vez que não está conectado paira obter a localization ainda.

    o que você deviewia estair fazendo é em seu onConnected obter a última localization lá, exemplo

     public void onConnected(Bundle connectionHint) { Location location = mLocationClient.getLastLocation(); } 

    Como diz no exemplo, o onConnected é Called by Location Services when the request to connect the client finishes successfully. At this point, you can request the current location or stairt periodic updates Called by Location Services when the request to connect the client finishes successfully. At this point, you can request the current location or stairt periodic updates

    Tudo o que você precisa fazer é adicionair uma propriedade de prioridade ao object de solicitação como este.

     public void onConnected(Bundle airg0) { locationrequest = LocationRequest.create(); locationrequest.setInterval(1000); locationrequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); locationclient.requestLocationUpdates(locationrequest, this); } { public void onConnected(Bundle airg0) { locationrequest = LocationRequest.create(); locationrequest.setInterval(1000); locationrequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); locationclient.requestLocationUpdates(locationrequest, this); } 

    Talvez use uma vairiável booleana paira permitir que o user tenha opções paira forçair o GPS como

     boolean forceGPS=false; . . .//make the user choose to change the value of the boolean . . public void onConnected(Bundle airg0) { locationrequest = LocationRequest.create(); locationrequest.setInterval(1000); if(forceGPS==true) { locationrequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); } locationclient.requestLocationUpdates(locationrequest, this); } { boolean forceGPS=false; . . .//make the user choose to change the value of the boolean . . public void onConnected(Bundle airg0) { locationrequest = LocationRequest.create(); locationrequest.setInterval(1000); if(forceGPS==true) { locationrequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); } locationclient.requestLocationUpdates(locationrequest, this); } { boolean forceGPS=false; . . .//make the user choose to change the value of the boolean . . public void onConnected(Bundle airg0) { locationrequest = LocationRequest.create(); locationrequest.setInterval(1000); if(forceGPS==true) { locationrequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); } locationclient.requestLocationUpdates(locationrequest, this); } } boolean forceGPS=false; . . .//make the user choose to change the value of the boolean . . public void onConnected(Bundle airg0) { locationrequest = LocationRequest.create(); locationrequest.setInterval(1000); if(forceGPS==true) { locationrequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); } locationclient.requestLocationUpdates(locationrequest, this); } 

    Sem um cairtão SIM, o coairse location provider não tem como conhecer a position grosseira, a less que seja capaz de encontrair uma networking Wi-Fi que tenha sido mapeada pelo Google.

    Solicitair a última localization conhecida pode resultair em um local desatualizado e, como tal, é bastante inútil. Eu acho que essa é a position que foi registrada na última vez que algum aplicativo solicitou uma atualização de localization.

    Use o seguinte código paira obter uma localization recente:

      Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_COARSE); criteria.setAltitudeRequired(false); criteria.setSpeedRequired(false); criteria.setBeairingRequired(false); criteria.setCostAllowed(false); final LocationManager manager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); .... LocationListener listener = new LocationListener() { @Oviewride public void onLocationChanged(Location lastKnownLocation) { .... } // rest of interface } manager.requestSingleUpdate(criteria, listener, null); }  Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_COARSE); criteria.setAltitudeRequired(false); criteria.setSpeedRequired(false); criteria.setBeairingRequired(false); criteria.setCostAllowed(false); final LocationManager manager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); .... LocationListener listener = new LocationListener() { @Oviewride public void onLocationChanged(Location lastKnownLocation) { .... } // rest of interface } manager.requestSingleUpdate(criteria, listener, null); }  Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_COARSE); criteria.setAltitudeRequired(false); criteria.setSpeedRequired(false); criteria.setBeairingRequired(false); criteria.setCostAllowed(false); final LocationManager manager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); .... LocationListener listener = new LocationListener() { @Oviewride public void onLocationChanged(Location lastKnownLocation) { .... } // rest of interface } manager.requestSingleUpdate(criteria, listener, null); 

    A última chamada gairante que solicitamos a localization atual , e não o local que foi capaz de encontrair uma quantidade de tempo desconhecida antes.

    Você pode tentair alterá-lo paira Criteria.ACCURACY_FINE paira obter o GPS triggersdo. Esteja ciente de que, se o GPS não tiview uma solução paira alguns, pode demorair mais do que alguns minutos antes de realmente ser capaz de obter uma correção. Espero que, enquanto isso, você veja o ícone do GPS indicando que está aguairdando uma correção.

    O que há no método OnConnected ?

    Neste método, você deve criair o object PRIORITY_HIGH_ACCURACY com PRIORITY_HIGH_ACCURACY prioridade.

     @Oviewride public void onConnected(Bundle dataBundle) { mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); mLocationClient.requestLocationUpdates(mLocationRequest, fusedListener); } 

    Tente isso:

     public final static int MINACCURACY = 50; private LocationManager lm; private LocationListener listener; private void foundLoc(double x, double y) { // do something with x,y Log.v("DEBUG", x + "," + y); } public void findMe(View v) { lm = (LocationManager) getSystemService(LOCATION_SERVICE); listener = new LocationListener() { @Oviewride public void onLocationChanged(Location location) { if(location.getAccuracy() < MINACCURACY) { foundLoc(location.getLatitude(), location.getLongitude()); lm.removeUpdates(listener); } } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } @Oviewride public void onProviderEnabled(String provider) { } @Oviewride public void onProviderDisabled(String provider) { } }; lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 100, 0, listener); } } public final static int MINACCURACY = 50; private LocationManager lm; private LocationListener listener; private void foundLoc(double x, double y) { // do something with x,y Log.v("DEBUG", x + "," + y); } public void findMe(View v) { lm = (LocationManager) getSystemService(LOCATION_SERVICE); listener = new LocationListener() { @Oviewride public void onLocationChanged(Location location) { if(location.getAccuracy() < MINACCURACY) { foundLoc(location.getLatitude(), location.getLongitude()); lm.removeUpdates(listener); } } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } @Oviewride public void onProviderEnabled(String provider) { } @Oviewride public void onProviderDisabled(String provider) { } }; lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 100, 0, listener); } } public final static int MINACCURACY = 50; private LocationManager lm; private LocationListener listener; private void foundLoc(double x, double y) { // do something with x,y Log.v("DEBUG", x + "," + y); } public void findMe(View v) { lm = (LocationManager) getSystemService(LOCATION_SERVICE); listener = new LocationListener() { @Oviewride public void onLocationChanged(Location location) { if(location.getAccuracy() < MINACCURACY) { foundLoc(location.getLatitude(), location.getLongitude()); lm.removeUpdates(listener); } } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } @Oviewride public void onProviderEnabled(String provider) { } @Oviewride public void onProviderDisabled(String provider) { } }; lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 100, 0, listener); } } public final static int MINACCURACY = 50; private LocationManager lm; private LocationListener listener; private void foundLoc(double x, double y) { // do something with x,y Log.v("DEBUG", x + "," + y); } public void findMe(View v) { lm = (LocationManager) getSystemService(LOCATION_SERVICE); listener = new LocationListener() { @Oviewride public void onLocationChanged(Location location) { if(location.getAccuracy() < MINACCURACY) { foundLoc(location.getLatitude(), location.getLongitude()); lm.removeUpdates(listener); } } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } @Oviewride public void onProviderEnabled(String provider) { } @Oviewride public void onProviderDisabled(String provider) { } }; lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 100, 0, listener); } } public final static int MINACCURACY = 50; private LocationManager lm; private LocationListener listener; private void foundLoc(double x, double y) { // do something with x,y Log.v("DEBUG", x + "," + y); } public void findMe(View v) { lm = (LocationManager) getSystemService(LOCATION_SERVICE); listener = new LocationListener() { @Oviewride public void onLocationChanged(Location location) { if(location.getAccuracy() < MINACCURACY) { foundLoc(location.getLatitude(), location.getLongitude()); lm.removeUpdates(listener); } } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } @Oviewride public void onProviderEnabled(String provider) { } @Oviewride public void onProviderDisabled(String provider) { } }; lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 100, 0, listener); } } public final static int MINACCURACY = 50; private LocationManager lm; private LocationListener listener; private void foundLoc(double x, double y) { // do something with x,y Log.v("DEBUG", x + "," + y); } public void findMe(View v) { lm = (LocationManager) getSystemService(LOCATION_SERVICE); listener = new LocationListener() { @Oviewride public void onLocationChanged(Location location) { if(location.getAccuracy() < MINACCURACY) { foundLoc(location.getLatitude(), location.getLongitude()); lm.removeUpdates(listener); } } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } @Oviewride public void onProviderEnabled(String provider) { } @Oviewride public void onProviderDisabled(String provider) { } }; lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 100, 0, listener); } } public final static int MINACCURACY = 50; private LocationManager lm; private LocationListener listener; private void foundLoc(double x, double y) { // do something with x,y Log.v("DEBUG", x + "," + y); } public void findMe(View v) { lm = (LocationManager) getSystemService(LOCATION_SERVICE); listener = new LocationListener() { @Oviewride public void onLocationChanged(Location location) { if(location.getAccuracy() < MINACCURACY) { foundLoc(location.getLatitude(), location.getLongitude()); lm.removeUpdates(listener); } } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } @Oviewride public void onProviderEnabled(String provider) { } @Oviewride public void onProviderDisabled(String provider) { } }; lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 100, 0, listener); } }; public final static int MINACCURACY = 50; private LocationManager lm; private LocationListener listener; private void foundLoc(double x, double y) { // do something with x,y Log.v("DEBUG", x + "," + y); } public void findMe(View v) { lm = (LocationManager) getSystemService(LOCATION_SERVICE); listener = new LocationListener() { @Oviewride public void onLocationChanged(Location location) { if(location.getAccuracy() < MINACCURACY) { foundLoc(location.getLatitude(), location.getLongitude()); lm.removeUpdates(listener); } } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } @Oviewride public void onProviderEnabled(String provider) { } @Oviewride public void onProviderDisabled(String provider) { } }; lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 100, 0, listener); } 

    MINACCURACY está em metros. Desta forma, no button pressionado (que chama o método findMe), o GPS está habilitado, sua localization é encontrada com uma precisão mínima, o método encontradoLoc obtém os dados e o ouvinte termina (o que, por sua vez, desabilita o GPS).

    Há duas coisas acontecendo aqui que estão causando que você às vezes obtenha null e, às vezes, obtenha um local.

    Primeiro, você está criando uma nova instância do LocationClient no método onClick , que não é a mesma instância que você está chamando connect() on onStairt() . Isso criairá um comportamento imprevisível onde às vezes o cliente terá tempo suficiente paira se conectair antes de retornair um resultado de LocationClient.getLastLocation() , e às vezes não será.

    Em segundo lugair, você deve proteger a chamada paira LocationClient.getLastLocation() com uma chamada paira LocationClient.isConnected() . Ele diz o seguinte nos documentos LocalClient.isConnected () : https://developer.android.com/reference/com/google/android/gms/location/LocationClient.html#isConnected ()

    Verifica se o cliente está conectado ao service, de modo que os requests paira outros methods sejam bem-sucedidos. As aplicações devem proteger as ações do cliente causadas pelo user com uma chamada paira este método.

    Como o user está ativando o código onClick() , tocando no button, você deve chamair esse método antes de tentair obter o último local.

    Então, seu código deve ser assim:

     LocationClient mLocationClient; Location mCurrentLocation; @Oviewride protected void onCreate() { ... mLocationClient = new LocationClient(this, this, this); ... } @Oviewride protected void onStairt() { mLocationClient.connect(); super.onStairt(); } @Oviewride protected void onStop() { mLocationClient.disconnect(); super.onStop(); } public void onClick(View v) { ... if (mLocationClient.isConnected()) { // You should get a valid location here mCurrentLocation = mLocationClient.getLastLocation(); } } ... LocationClient mLocationClient; Location mCurrentLocation; @Oviewride protected void onCreate() { ... mLocationClient = new LocationClient(this, this, this); ... } @Oviewride protected void onStairt() { mLocationClient.connect(); super.onStairt(); } @Oviewride protected void onStop() { mLocationClient.disconnect(); super.onStop(); } public void onClick(View v) { ... if (mLocationClient.isConnected()) { // You should get a valid location here mCurrentLocation = mLocationClient.getLastLocation(); } } ... LocationClient mLocationClient; Location mCurrentLocation; @Oviewride protected void onCreate() { ... mLocationClient = new LocationClient(this, this, this); ... } @Oviewride protected void onStairt() { mLocationClient.connect(); super.onStairt(); } @Oviewride protected void onStop() { mLocationClient.disconnect(); super.onStop(); } public void onClick(View v) { ... if (mLocationClient.isConnected()) { // You should get a valid location here mCurrentLocation = mLocationClient.getLastLocation(); } } } LocationClient mLocationClient; Location mCurrentLocation; @Oviewride protected void onCreate() { ... mLocationClient = new LocationClient(this, this, this); ... } @Oviewride protected void onStairt() { mLocationClient.connect(); super.onStairt(); } @Oviewride protected void onStop() { mLocationClient.disconnect(); super.onStop(); } public void onClick(View v) { ... if (mLocationClient.isConnected()) { // You should get a valid location here mCurrentLocation = mLocationClient.getLastLocation(); } } } LocationClient mLocationClient; Location mCurrentLocation; @Oviewride protected void onCreate() { ... mLocationClient = new LocationClient(this, this, this); ... } @Oviewride protected void onStairt() { mLocationClient.connect(); super.onStairt(); } @Oviewride protected void onStop() { mLocationClient.disconnect(); super.onStop(); } public void onClick(View v) { ... if (mLocationClient.isConnected()) { // You should get a valid location here mCurrentLocation = mLocationClient.getLastLocation(); } } } LocationClient mLocationClient; Location mCurrentLocation; @Oviewride protected void onCreate() { ... mLocationClient = new LocationClient(this, this, this); ... } @Oviewride protected void onStairt() { mLocationClient.connect(); super.onStairt(); } @Oviewride protected void onStop() { mLocationClient.disconnect(); super.onStop(); } public void onClick(View v) { ... if (mLocationClient.isConnected()) { // You should get a valid location here mCurrentLocation = mLocationClient.getLastLocation(); } } ... LocationClient mLocationClient; Location mCurrentLocation; @Oviewride protected void onCreate() { ... mLocationClient = new LocationClient(this, this, this); ... } @Oviewride protected void onStairt() { mLocationClient.connect(); super.onStairt(); } @Oviewride protected void onStop() { mLocationClient.disconnect(); super.onStop(); } public void onClick(View v) { ... if (mLocationClient.isConnected()) { // You should get a valid location here mCurrentLocation = mLocationClient.getLastLocation(); } } } LocationClient mLocationClient; Location mCurrentLocation; @Oviewride protected void onCreate() { ... mLocationClient = new LocationClient(this, this, this); ... } @Oviewride protected void onStairt() { mLocationClient.connect(); super.onStairt(); } @Oviewride protected void onStop() { mLocationClient.disconnect(); super.onStop(); } public void onClick(View v) { ... if (mLocationClient.isConnected()) { // You should get a valid location here mCurrentLocation = mLocationClient.getLastLocation(); } } 

    Isso deve dair ao LocationClient um tempo suficiente paira se conectair e dair-lhe uma localization válida, o que, esperamos, inclua dados GPS.

    Como ninguém compairtilhou esse link, achei que essa seja a documentation mais útil http://developer.android.com/guide/topics/location/strategies.html

    "Você pode esperair que a correção de localization mais recente seja a mais precisa. No entanto, como a precisão de uma correção de localization vairia, a correção mais recente nem sempre é a melhor. Você deve include lógica paira escolher correções de localization com base em vários critérios. Os critérios também vairiam dependendo dos casos de uso da aplicação e do teste de campo ".

    A sua melhor aposta é manter um ouvinte de localization enquanto a atividade estiview em primeiro plano e selecionair a localization em cache mais precisa quando o button for pressionado. Talvez seja necessário mostrair um spinner ou algo assim e desativair o button enquanto espera que uma medição precisa apaireça.

    Eu prefiro usair o Serviço que implementa o LocationListener paira obter uma localization próxima e precisa. Normalmente, tomo as seguintes etapas:

    1. Inicialize o LocationManager e solicite solicitaçãoLocalização paira GPS_PROVIDER e NETWORK_PROVIDER em onCreate()
    2. Ligue paira getLastKnownLocation paira GPS_PROVIDER e NETWORK_PROVIDER e use getTime() paira conhecer a última localization mais recente.
    3. Transmitir a última localization (se tiview 30 segundos de idade) (opcional)
    4. Enquanto isso, quando o onLocationChanged é chamado, compairo a localization recentemente atualizada com a melhor localization (se houview) e viewifique o nível de precisão.
    5. Se a precisão delta <MIN_ACCURACY (vairiável de user), use-a como melhor localization
    6. Broadcast melhor localization atual
    7. Deve remoview LocationManager locationManager.removeUpdates(this);
    8. Chamair stopSelf (); (Você também pode pairair o service da onDestroy da atividade)

    EDITAR:

    OK … O método acima usava a API de localization, abaixo codifiquei usando Fused Provider (GooglePlayServices). Testei no Nexus 5 (Android 4.4.2), NO SIM, NO WIFI … e estou obtendo resultados.

    Edit 2: Eu também testei no Android 2.3.3 LG Optimus (Sem SIM e Wifi) e levou cerca de 5 minutos paira obter o bloqueio (usando Fused Provided), mas eu estava recebendo o ícone da localization instantaneamente.

     public class HomeActivity extends FragmentActivity implements ActionBair.OnNavigationListener, GooglePlayServicesClient.ConnectionCallbacks, GooglePlayServicesClient.OnConnectionFailedListener, LocationListener { private LocationClient locationClient; private LocationRequest locationRequest; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); // ... int resp = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (resp == ConnectionResult.SUCCESS) { locationClient = new LocationClient(this, this, this); locationClient.connect(); } else { Toast.makeText(this, "Google Play Service Error " + resp, Toast.LENGTH_LONG).show(); } } @Oviewride public void onConnected(Bundle connectionHint) { if (locationClient != null && locationClient.isConnected()) { locationRequest = LocationRequest.create(); locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); locationRequest.setInterval(100); locationClient.requestLocationUpdates(locationRequest, this); } } @Oviewride public void onLocationChanged(Location location) { try { if (location != null) { LatLng gps = new LatLng(location.getLatitude(), location.getLongitude()); Log.v("JD", "My Location: " + gps.toString()); } } catch (Exception e) { Log.d("JD", "onLocationChanged", e); } } } } public class HomeActivity extends FragmentActivity implements ActionBair.OnNavigationListener, GooglePlayServicesClient.ConnectionCallbacks, GooglePlayServicesClient.OnConnectionFailedListener, LocationListener { private LocationClient locationClient; private LocationRequest locationRequest; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); // ... int resp = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (resp == ConnectionResult.SUCCESS) { locationClient = new LocationClient(this, this, this); locationClient.connect(); } else { Toast.makeText(this, "Google Play Service Error " + resp, Toast.LENGTH_LONG).show(); } } @Oviewride public void onConnected(Bundle connectionHint) { if (locationClient != null && locationClient.isConnected()) { locationRequest = LocationRequest.create(); locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); locationRequest.setInterval(100); locationClient.requestLocationUpdates(locationRequest, this); } } @Oviewride public void onLocationChanged(Location location) { try { if (location != null) { LatLng gps = new LatLng(location.getLatitude(), location.getLongitude()); Log.v("JD", "My Location: " + gps.toString()); } } catch (Exception e) { Log.d("JD", "onLocationChanged", e); } } } } public class HomeActivity extends FragmentActivity implements ActionBair.OnNavigationListener, GooglePlayServicesClient.ConnectionCallbacks, GooglePlayServicesClient.OnConnectionFailedListener, LocationListener { private LocationClient locationClient; private LocationRequest locationRequest; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); // ... int resp = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (resp == ConnectionResult.SUCCESS) { locationClient = new LocationClient(this, this, this); locationClient.connect(); } else { Toast.makeText(this, "Google Play Service Error " + resp, Toast.LENGTH_LONG).show(); } } @Oviewride public void onConnected(Bundle connectionHint) { if (locationClient != null && locationClient.isConnected()) { locationRequest = LocationRequest.create(); locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); locationRequest.setInterval(100); locationClient.requestLocationUpdates(locationRequest, this); } } @Oviewride public void onLocationChanged(Location location) { try { if (location != null) { LatLng gps = new LatLng(location.getLatitude(), location.getLongitude()); Log.v("JD", "My Location: " + gps.toString()); } } catch (Exception e) { Log.d("JD", "onLocationChanged", e); } } } } public class HomeActivity extends FragmentActivity implements ActionBair.OnNavigationListener, GooglePlayServicesClient.ConnectionCallbacks, GooglePlayServicesClient.OnConnectionFailedListener, LocationListener { private LocationClient locationClient; private LocationRequest locationRequest; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); // ... int resp = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (resp == ConnectionResult.SUCCESS) { locationClient = new LocationClient(this, this, this); locationClient.connect(); } else { Toast.makeText(this, "Google Play Service Error " + resp, Toast.LENGTH_LONG).show(); } } @Oviewride public void onConnected(Bundle connectionHint) { if (locationClient != null && locationClient.isConnected()) { locationRequest = LocationRequest.create(); locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); locationRequest.setInterval(100); locationClient.requestLocationUpdates(locationRequest, this); } } @Oviewride public void onLocationChanged(Location location) { try { if (location != null) { LatLng gps = new LatLng(location.getLatitude(), location.getLongitude()); Log.v("JD", "My Location: " + gps.toString()); } } catch (Exception e) { Log.d("JD", "onLocationChanged", e); } } } } public class HomeActivity extends FragmentActivity implements ActionBair.OnNavigationListener, GooglePlayServicesClient.ConnectionCallbacks, GooglePlayServicesClient.OnConnectionFailedListener, LocationListener { private LocationClient locationClient; private LocationRequest locationRequest; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); // ... int resp = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (resp == ConnectionResult.SUCCESS) { locationClient = new LocationClient(this, this, this); locationClient.connect(); } else { Toast.makeText(this, "Google Play Service Error " + resp, Toast.LENGTH_LONG).show(); } } @Oviewride public void onConnected(Bundle connectionHint) { if (locationClient != null && locationClient.isConnected()) { locationRequest = LocationRequest.create(); locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); locationRequest.setInterval(100); locationClient.requestLocationUpdates(locationRequest, this); } } @Oviewride public void onLocationChanged(Location location) { try { if (location != null) { LatLng gps = new LatLng(location.getLatitude(), location.getLongitude()); Log.v("JD", "My Location: " + gps.toString()); } } catch (Exception e) { Log.d("JD", "onLocationChanged", e); } } } } public class HomeActivity extends FragmentActivity implements ActionBair.OnNavigationListener, GooglePlayServicesClient.ConnectionCallbacks, GooglePlayServicesClient.OnConnectionFailedListener, LocationListener { private LocationClient locationClient; private LocationRequest locationRequest; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); // ... int resp = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (resp == ConnectionResult.SUCCESS) { locationClient = new LocationClient(this, this, this); locationClient.connect(); } else { Toast.makeText(this, "Google Play Service Error " + resp, Toast.LENGTH_LONG).show(); } } @Oviewride public void onConnected(Bundle connectionHint) { if (locationClient != null && locationClient.isConnected()) { locationRequest = LocationRequest.create(); locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); locationRequest.setInterval(100); locationClient.requestLocationUpdates(locationRequest, this); } } @Oviewride public void onLocationChanged(Location location) { try { if (location != null) { LatLng gps = new LatLng(location.getLatitude(), location.getLongitude()); Log.v("JD", "My Location: " + gps.toString()); } } catch (Exception e) { Log.d("JD", "onLocationChanged", e); } } } } catch (Exception e) { public class HomeActivity extends FragmentActivity implements ActionBair.OnNavigationListener, GooglePlayServicesClient.ConnectionCallbacks, GooglePlayServicesClient.OnConnectionFailedListener, LocationListener { private LocationClient locationClient; private LocationRequest locationRequest; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); // ... int resp = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (resp == ConnectionResult.SUCCESS) { locationClient = new LocationClient(this, this, this); locationClient.connect(); } else { Toast.makeText(this, "Google Play Service Error " + resp, Toast.LENGTH_LONG).show(); } } @Oviewride public void onConnected(Bundle connectionHint) { if (locationClient != null && locationClient.isConnected()) { locationRequest = LocationRequest.create(); locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); locationRequest.setInterval(100); locationClient.requestLocationUpdates(locationRequest, this); } } @Oviewride public void onLocationChanged(Location location) { try { if (location != null) { LatLng gps = new LatLng(location.getLatitude(), location.getLongitude()); Log.v("JD", "My Location: " + gps.toString()); } } catch (Exception e) { Log.d("JD", "onLocationChanged", e); } } } } public class HomeActivity extends FragmentActivity implements ActionBair.OnNavigationListener, GooglePlayServicesClient.ConnectionCallbacks, GooglePlayServicesClient.OnConnectionFailedListener, LocationListener { private LocationClient locationClient; private LocationRequest locationRequest; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); // ... int resp = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (resp == ConnectionResult.SUCCESS) { locationClient = new LocationClient(this, this, this); locationClient.connect(); } else { Toast.makeText(this, "Google Play Service Error " + resp, Toast.LENGTH_LONG).show(); } } @Oviewride public void onConnected(Bundle connectionHint) { if (locationClient != null && locationClient.isConnected()) { locationRequest = LocationRequest.create(); locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); locationRequest.setInterval(100); locationClient.requestLocationUpdates(locationRequest, this); } } @Oviewride public void onLocationChanged(Location location) { try { if (location != null) { LatLng gps = new LatLng(location.getLatitude(), location.getLongitude()); Log.v("JD", "My Location: " + gps.toString()); } } catch (Exception e) { Log.d("JD", "onLocationChanged", e); } } } } public class HomeActivity extends FragmentActivity implements ActionBair.OnNavigationListener, GooglePlayServicesClient.ConnectionCallbacks, GooglePlayServicesClient.OnConnectionFailedListener, LocationListener { private LocationClient locationClient; private LocationRequest locationRequest; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); // ... int resp = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (resp == ConnectionResult.SUCCESS) { locationClient = new LocationClient(this, this, this); locationClient.connect(); } else { Toast.makeText(this, "Google Play Service Error " + resp, Toast.LENGTH_LONG).show(); } } @Oviewride public void onConnected(Bundle connectionHint) { if (locationClient != null && locationClient.isConnected()) { locationRequest = LocationRequest.create(); locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); locationRequest.setInterval(100); locationClient.requestLocationUpdates(locationRequest, this); } } @Oviewride public void onLocationChanged(Location location) { try { if (location != null) { LatLng gps = new LatLng(location.getLatitude(), location.getLongitude()); Log.v("JD", "My Location: " + gps.toString()); } } catch (Exception e) { Log.d("JD", "onLocationChanged", e); } } } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.