Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid emulator, Finding mock user location coordinates. Having problems
    text
    copied!<p>Hey guys, I'm having trouble trying to find the user's longitude and location as I run my program and set the telnet command for geo fix for the mock location. While the emulator is running, I set the mock coordinates only for the emulator to become unresponsive and have my program fail in detecting the input coordinates.</p> <pre><code>import android.app.Activity; import android.content.Context; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.location.LocationProvider; import android.os.Bundle; import android.widget.TextView; import android.widget.Toast; public class LBSact extends Activity{ /** Called when the activity is first created. */ public double longitude; public double latitude; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); longitude = 0; latitude = 0; //Creating the listener and manager LocationManager LManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); LocationListener createListen = new LocationListener(){ @Override public void onLocationChanged(Location location) { //longitude = location.getLongitude(); //latitude = location.getLatitude(); String printout1 = "My current location is: " + "Latitude = " + location.getLatitude() + "Longitude = " + location.getLongitude(); Toast.makeText(getApplicationContext(),printout1,Toast.LENGTH_LONG).show(); } @Override public void onProviderDisabled(String provider) { Toast.makeText(getApplicationContext(), "GPS disabled", Toast.LENGTH_LONG).show(); } @Override public void onProviderEnabled(String provider) { Toast.makeText(getApplicationContext(), "GPS enabled", Toast.LENGTH_LONG).show(); } @Override public void onStatusChanged(String provider, int status, Bundle extras) { } }; //Cant use Network with emulator, can only use GPS mock locations //Toast.makeText(getApplicationContext(), "Does this work?", Toast.LENGTH_LONG).show(); LManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, createListen); } } </code></pre>
 

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