This is how I am doing but I am always getting Lat and Long values 0.0
// construct a new instance of SimpleLocation
location = new SimpleLocation(this);
// if we can't access the location yet
if (!location.hasLocationEnabled()) {
// ask the user to enable location access
SimpleLocation.openSettings(this);
}
findViewById(R.id.someview).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final double latitude = location.getLatitude();
final double longitude = location.getLongitude();
mLatitudeText.setText("Lat " +
"" + location.getLatitude());
mLongitudeText.setText("Long " +
"" + location.getLongitude());
}
});
// construct a new instance of SimpleLocation
location = new SimpleLocation(this);
// if we can't access the location yet
if (!location.hasLocationEnabled()) {
// ask the user to enable location access
SimpleLocation.openSettings(this);
}
findViewById(R.id.someview).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final double latitude = location.getLatitude();
final double longitude = location.getLongitude();
mLatitudeText.setText("Lat " +
"" + location.getLatitude());
mLongitudeText.setText("Long " +
"" + location.getLongitude());
}
});
This is how I am doing but I am always getting Lat and Long values 0.0
I am using Samsung A5 Android lollipop