I am developing an android application. I need to find the location of the user as soon as he/she logs in to the application. I do not want maps to be displayed, the location should be identified without the user's knowledge. Is it possible to do this using the Google maps API? or is there any other way to do this?
Thanks
The best way to do this is to use the PASSIVE
location provider like so:
LocationManager lm = (LocationManager)yourActivityContext.getSystemService(Context.LOCATION_SERVICE);
Location lastKnown = lm.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER);
This returns the last known location received by the operating system, so this may be stale, but you can check when the location was retrieved, and by which provider by querying the location object.
In conclusion, the user will have no idea that you've gotten a location except that your app will require the proper location permission(s).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With