Note that there are some explanatory texts on larger screens.

plurals
  1. POcurrent location is not working in android emulator
    text
    copied!<p>I am following a tutorial to get my current location. I wrote exactly what the tutorial said, but i just do not get my lat/lon. I am using a wifi connection. I tried:<br> geo fix -77.036519 38.896143<br> still do not get the lat/lon. My code is as follows;</p> <pre><code>import java.util.List; import android.app.Activity; import android.content.Context; import android.location.Location; import android.location.LocationManager; import android.location.LocationListener; import android.os.Bundle; import android.widget.TextView; public class TestProviderController extends Activity { LocationManager locationManager; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); String location_context=Context.LOCATION_SERVICE; locationManager=(LocationManager)getSystemService(location_context); testProvider(); } public void testProvider(){ TextView tv = (TextView)findViewById(R.id.myTextView); StringBuilder sb = new StringBuilder("Enabled Providers:"); List&lt;String&gt; providers = locationManager.getProviders(true); for (String provider : providers) { locationManager.requestLocationUpdates(provider, 1000, 0, new LocationListener() { public void onLocationChanged(Location location) {} public void onProviderDisabled(String provider){} public void onProviderEnabled(String provider){} public void onStatusChanged(String provider, int status, Bundle extras){} }); sb.append("\n").append(provider).append(":"); Location location = locationManager.getLastKnownLocation(provider); if (location != null) { double lat = location.getLatitude(); double lng = location.getLongitude(); sb.append(lat).append(",").append(lng); } else { sb.append("No Location"); } } tv.setText(sb); } } </code></pre> <p>Can anybody please help about what went wrong?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload