How To Get A Callback From Google Maps In Android Application, When Navigation Is Complete
I am building an android application, that will show certain points on google maps, for which I have (lat,lang) for all the points shown, with me. Whenever, a user clicks on one of
Solution 1:
You need to call the finish() method on the activity when the destination is reached. So here are the steps that you need to implement in your program.
First of all know the destination coordinates from the user input and pass it in the Direction API.
https://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&key=API_KEY
When you know the destination coordinates you can pass that when the marker representing that is clicked in the navigation intent. (which you have already done)
Make use of the location listener interface that tracks the current location coordinates.
Put an if...else condition where you check that the current location is equivalent to the destination.
When the current location == Destination make a call to activity.finish() which will finally close the maps activity hosting.
Hope that Helps!!
Post a Comment for "How To Get A Callback From Google Maps In Android Application, When Navigation Is Complete"