I am trying to retrieve my current location on the button click in an editbox using gps or network..i have tried all possible methods which i found in tutorials and older posts.
Try this Code:
public CurrentLocation(Context ctx) {
this.context = ctx;
locationManager = (LocationManager) context
.getSystemService(Context.LOCATION_SERVICE);
@SuppressWarnings("unused")
List providers = locationManager.getAllProviders();
Criteria locationCritera = new Criteria();
String providerName = locationManager.getBestProvider(locationCritera,
true);
location = locationManager.getLastKnownLocation(providerName);
locationListener = new MyLocationListener();
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,
0, locationListener);
}