Mock Location data in android
<p>I just want to receive the location data in my Activity which I am sending from Emulator Control. Following is the code i am using in my main activity:</p>

<pre><code>public class LocationAlert extends Activity {

TextView txtMessage;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    txtMessage = (TextView)findViewById(R.id.txtMsg);

    LocationManager lm = (LocationManager)getSystemService(LOCATION_SERVICE);

    lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 0, mLocListener);


    if (lm.getLastKnownLocation(LocationManager.GPS_PROVIDER) != null){
        txtMessage.setText(String.valueOf(lm.getLastKnownLocation(LocationManager.GPS_PROVIDER).getLatitude()));
    }

}

LocationListener mLocListener = new LocationListener() {

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onProviderEnabled(String provider) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onProviderDisabled(String provider) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onLocationChanged(Location location) {

        if (location != null){
            txtMessage.setText("Latitude: " + String.valueOf(location.getLatitude()) + ", Longitude: " + String.valueOf(location.getLongitude()));
        }

    }
};
</code></pre>

<p>}</p>

<p>but i don't get any data and all the processes running in the emulator closes one by one which i can see in the Devices tab. What's wrong with the above code?</p>
