问题描述
我正在使用 Intent 启动 Google 导航:
I'm using intents to launch Google Navigation:
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=" + location));
startActivity(i);
location
是一个带有 GPS 坐标的字符串.
location
is a string with GPS coordinates.
Google Navigation 会很好地弹出并绘制路线图.当用户到达目的地时,他们可以返回某种类型的回调吗?有什么方法可以实现 startActivityForResult()
?
Google Navigation pops up nicely and plots the route. Can they return some type of callback when the user has reached their destination? Any way of implementing startActivityForResult()
?
如果不是,我最好的选择是什么?我一直在考虑在后台运行一项服务,该服务会密切关注位置并结束 Google 导航,并在 GPS 记录它在目的地附近时返回我的应用程序(因为我知道纬度/经度).
If not, what would be my best bet? I've been considering running a service in the background that keeps tabs on the location and ending Google Navigation and returning to my app when the GPS registers that it's near the destination (because I know the latitude/longitude).
谢谢大家
推荐答案
我想发布我是如何设法让它工作的.我没有使用活动回调,但我正在启动一个带有 LocationManager
的服务.当用户接近目的地坐标时,我只是终止 Google Navigation 并重新开始我的活动.
I wanted to post how I managed to get this to work. I'm not using activity callbacks, but I am starting a service with a LocationManager
hanging out in it. When the user gets close to the destination coordinates, I just terminate Google Navigation and start my activity back up.
这篇关于Google Navigation (Android 1.6) 意图回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!