Im new to android. but it's not returning the lat and longitude values. I tried this in emulator. i test and onLocationChanged method is not executing. i just need to get the gps coordinates of the current location
final TextView tv1 = (TextView) findViewById(R.id.textView1);
final TextView tv2 = (TextView) findViewById(R.id.textView2);
LocationManager manager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
LocationListener listener = 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) {
// TODO Auto-generated method stub
//String kk = "wefewfwef";
//tv1.setText(kk);
if(location != null){
latitude = location.getLatitude();
longitude = location.getLongitude();
int lat = (int) latitude;
int longi = (int) longitude;
tv1.setText(lat);
tv2.setText(longi);
}
}
};
manager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, listener);
}