I want to set a point as current location in emulator? I use location controls in DDMS, but It doesn't work! Any body know how to solve this? Thanks in advance!!
Asked
Active
Viewed 128 times
-3
-
You tried this way ah: http://www.helloandroid.com/tutorials/how-set-location-emulator – Ponmalar May 14 '12 at 11:57
-
0_0, some links are blocked in china, maythe link www.helloandroid.com is included!!! – john jiang May 14 '12 at 12:03
-
Ok, Follow the Steps, 1. go to your android/tools directory, and launch the DDMS tool 2. select the Emulator Control Tab 3. fill the Location Controls fields with the longitude and latitude values 4.press the Send button – Ponmalar May 14 '12 at 12:05
-
I tried DDMS's location control and telnet, but both are failed! – john jiang May 14 '12 at 12:08
1 Answers
0
Try this,
public class NL extends Activity {
private LocationManager locmgr = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.nl);
locmgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
// Define a listener that responds to location updates
LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location loc) {
// Called when a new location is found by the network location provider.
Log.i("NOTIFICATION","onLocationChenged Triggered");
Toast msg = Toast.makeText(NetworkLocator.this, "Lon: " + Double.toString(loc.getLongitude()) + " Lat: " + Double.toString(loc.getLatitude()), Toast.LENGTH_SHORT);
msg.show();
}
public void onStatusChanged(String provider, int status, Bundle extras) {}
public void onProviderEnabled(String provider) {}
public void onProviderDisabled(String provider) {}
};
// Register the listener with the Location Manager to receive location updates
locmgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
}
}
Reffered from Android - Unable to get the gps location on the emulator