I’m using this code to find my current location. But if I’m at home it can’t locate me. But google maps and another similar applications can locate me although I’m at home. What is difference?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re using the GPS_Provider, make sure that you have the following permission in your app manifest:
But usually GPS only works with a free sky (not indoors very well). Therefore while Google Maps might show the last known location, maybe your app doesn’t. So you might want to initially call
getLastKnowLocationinitially to set the initial marker.Even though GPS cannot get a fix, you could still show the last known location known to the device, i.e. when you were outdoors last time.
Alternatively or additionally to GPS_Provider, you could also use the
instead,which is based on Wifi and/or GMS, is less accurate than GPS but works indoors.
For this, you need the permission
in your manifest.