Issue
The docs don't explain much on how to use GoogleMap.CancelableCallback
. Can I use it to notify my app that navigation has been cancelled using this callback? Can someone give me an example? Since the navigation is a separate app I learned it is hard to know if the user has cancelled the navigation or finished the navigation based on this SO answer but there is gotta be a way because Uber driver app has the ability to cancel the trip based on the passenger's request. I am very frustrated at this question, please help is badly needed.
Solution
The GoogleMap.CancelableCallback
notifies you when a map task has successfully completed or it has been cancelled by the user.
In a GoogleMap
, you can attach this callback to the animateCamera
(documentation) to know if the user has cancelled the animateCamera
task.
You can implement it like this:
map.animateCamera(yourCameraUpdate, new GoogleMap.CancelableCallback() {
@Override
public void onFinish() {
// Code to execute when the animateCamera task has finished
}
@Override
public void onCancel() {
// Code to execute when the user has canceled the animateCamera task
}
});
As you see, this callback doesn't provide the functionality you are looking for, and as Can i detect if a user canceled navigation from Google Maps App says, if you use Google Maps to perform your navigation, since Google Maps is a different app there is no way you can know if the user has canceled the navigation.
As @tyczj states in the comments of Can i detect if a user canceled navigation from Google Maps App, you can use Google Directions API taking into account the usage limits.
Answered By - antonio
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.