Tracking the location in android - android

I got the current location latitude and longitude while giving on in a switch button in android and displaying the location in google map. But I need the latitude and longitude changes automatically wherever the device moves and the location on the map should change with respect to the position. How is it possible? Can anyone give me a way?

You could have a look at GoogleApiClient.
You can use requestLocationUpdates(...) to get the users position in a given intervall.
You can find more Info here
But honestly you could have find the answer on your own if you googled a bit.

Related

LastKnownLocation is reset everytime

I would have thought that requesting the "lastKnownLocation" would return a saved coordinate (GeoPoint) that points to the last known location of the device (from when it last had access to the GPS functionalities).
According to some tests (made on OSMDroid's GpsMyLocationProvider), it seems like requesting that location returns a NullPointer.
GpsMyLocationProvider provider = new GpsMyLocationProvider(MainActivity.mainActivity);
provider.addLocationSource(LocationManager.NETWORK_PROVIDER);
locationOverlay = new MyLocationNewOverlay(provider, map);
I've been trying to set up default GeoPoint for centering the map when it is first launched, and then recentering the map where the GPS now has confirmed a position.
The problem is that provider.getLastKnownLocation() returns a NullPointer exception unless it is given time to actually get the current location from the GPS.
What am I getting wrong here? Shouldn't the "last known location" be a GeoPoint that is saved in memory on the phone and always have something there, unless the phone never ever had access to GPS localization ?
Please see https://developer.android.com/training/location/retrieve-current
You must set the permissions correctly too. Note that at the bottom they describe why the location may be null so see these for troubleshooting.
If you're using an emulator see How to emulate GPS location in the Android Emulator?

Notification regarding your location in Android app

I want to create an android app which asks user for a location input and runs in the background. Whenever user is within 1km radius of the location the app will display a notification “Within 1 km of xyz location”..
If nor the same,can anyone suggest me similar solution.
Thank you.
Step : 1 Firstly get latitude and longitude
this Url help you.
How can I find the latitude and longitude from address?
Step :2 Save the latitude and longitude
Step :3 By the onLocationChanged method you can get the required distance, after that you can generate notification.
May be this help you.

Compare Location coordinates on Android

We want our application to get location data when user opens the Activity and check if it's inside a certain boundary of location.
We are able to get the Coordinates of the current phone location now we want to compare it that if it is inside a building location or not. How do we check if the coordinates (lat Long) of the phone is inside a specific radius range?
thanks
You can use google's Geofence API.
new Geofence.Builder().setCircularRegion(latitude,longitude,radius);
https://developer.android.com/training/location/geofencing.html

How to get in-line location using google-maps in android?

There is a problem with getting my in-line position in google-maps. Method "getLastKnownLocation" isn't suitable for me.
I just need to turn on GPS and find my location in the same way as it is in google map programm.
Is there some another ways how to do that?

Google Maps V2 setLocationSource removes blue MyLocation icon

I'm working on an indoor GPS application and I have my own location provider that will give me lat and long. I have google maps v2 working with my location provider by using
mMap.setMyLocationEnabled(true);
mMap.setLocationSource(myLocationProvider);
My problem is as I set the location source to my custom provider, the little blue icon that displays onscreen location no longer functions. Is this expected? Shouldn't google maps just use the lat/long to display the current location, no matter where it comes from?
The blue dot should still be visible.
If you are sure your LocationSource is implemented properly, and after you call OnLocationChangedListener callback method the blue dot does not appear in the location you send, I suggest creating a simple working example to show the issue and post it on gmaps-api-issues.
I would start with a test call in activate:
Location location = new Location("myProvider");
location.setLatitude(30.0);
location.setLongitude(30.0);
listener.onLocationChanged(location);

Categories

Resources