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, lng is 0 #20

Open jinesh08 opened 6 years ago

jinesh08 commented 6 years ago

In many phones its working perfect but in few phones lag lng is zero all the time. any solution?

ocram commented 6 years ago

What are these “few phones”? Which manufacturers, which Android versions?

Apart from that, how do you create and use the instance of this library? Can you show the code?

jinesh08 commented 6 years ago

// instance of this library @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView= inflater.inflate(R.layout.fragment_dispatch, container, false); location = new SimpleLocation(getActivity()); location.setListener(new SimpleLocation.Listener() { @Override public void onPositionChanged() { } });
bindViews(rootView);
return rootView; }

//then just called location.getLatitude(); and location.getLongitude() in few methods

//phones in which this code is not working moto e4 plus android 7.1.1 Jio lyf phone android 6.0.1 MI redmi note 4

on other phones same code is working

pls help

ocram commented 6 years ago
  1. Do you have one (or two) permissions set up correctly (and been granted them) as shown in the README?
  2. Can you check the return value of location.hasLocationEnabled()?
  3. I don't see any call to location.beginUpdates();.
  4. (I don't see any call to location.endUpdates();.)
  5. Try logging something in the onPositionChanged callback method.

Otherwise, can you move the instance and its creation to the parent Activity and then follow the README?