Reputation: 2828
hi iwant to check lat long of current position in android emulator how to achive this..??it is possible to get current position latitude and longitude on emulator???if yes then what setting is required in emulator?
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
LocationListener ll = new Mylocationlistener();
boolean isGPS = lm
.isProviderEnabled(LocationManager.GPS_PROVIDER);
// If GPS is not enable then it will be on
if(!isGPS)
{
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", true);
sendBroadcast(intent);
}
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll);
}
private class Mylocationlistener implements LocationListener {
@Override
public void onLocationChanged(Location location) {
if (location != null) {
Log.d("LOCATION CHANGED", location.getLatitude() + "");
Log.d("LOCATION CHANGED", location.getLongitude() + "");
float speed = location.getSpeed();
double altitude = location.getAltitude();
Toast.makeText(currentlatlong.this,"Latitude = "+
location.getLatitude() + "" +"Longitude = "+ location.getLongitude()+"Altitude = "+altitude+"Speed = "+speed,
Toast.LENGTH_LONG).show();
}
}
@Override
public void onProviderDisabled(String provider) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
}
Upvotes: 3
Views: 7056
Reputation: 3739
You can also using telnet to set the emulator's location
open a command shell
conect to the emulator with the command: telnet localhost
to enter a fixed location execute the command:
geo fix longitude latitude
Upvotes: 1
Reputation: 37729
go to eclipse DDMS perspective,Via
Windows>Open Perspective > other > DDMS (You can type to filter the list)
find Emulator Control tab
then inside Location Control box
You can send lat, long to emulator to simulate gps changes.
if you cannot find Emulator Control, just open it via:
Windows > show view > other > Emulator Control (You can type to filter the list)
Upvotes: 3
Reputation: 13960
You'll find this window in the DDMS perspective in Eclipse. This way you can test your application with various location values.
Upvotes: 6