delight-im / Android-SimpleLocation

Utility class for easy access to the device location on Android
Apache License 2.0
200 stars 75 forks source link

Lat and Long both are 0.0 #9

Closed hiteshsahu closed 8 years ago

hiteshsahu commented 8 years ago

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());

    }

});

I am using Samsung A5 Android lollipop

ocram commented 8 years ago

Thanks for your question!

Do these related issues help?

ocram commented 8 years ago

https://github.com/delight-im/Android-SimpleLocation/issues/11 may be related as well