The F? Tterung emulator starts latitude and L? Ngengrad

I am trying to get latitude and longitude of user. I created a basic app. When I run it and feed latitude and longitude it restarts the OS in emulator. How can I fix this?

Here is my code

public class MGeolocationActivity extends Activity {
TextView tvLat;
TextView tvLong;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    tvLat = (TextView)findViewById(R.id.tvLat);
    tvLong = (TextView)findViewById(R.id.tvLong);

    LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
    LocationListener ll = new myLocationListener();
    lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll);
}

class myLocationListener implements LocationListener {

    @Override
    public void onLocationChanged(Location location) {
        if(location != null) {
            double pLong = location.getLongitude();
            double pLat = location.getLatitude();
            tvLat.setText(Double.toString(pLat));
            tvLong.setText(Double.toString(pLong));
        }
    }

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

    }

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

    }

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

    }

}
}
This entry was posted in Codes & Scripts and tagged , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>