Google地图导航 - 在Android应用程序中使用Google导航 [英] Google Maps Navigation - Using Google Navigation in Android Application
问题描述
我正在通过打开URL实现Google导航 -
$ b我的Android应用程序中实现Google导航时遇到了一个非常奇怪的问题。$ b
https://maps.google。 co.in/maps?saddr=xxxxxxxxxxxxxxxxxx&daddr=xxxxxxxxxxxxx
其中xxxx表示源地址和目标地址。
使用隐含的意图。我成功地通过在桌面上打开网址来获得导航。
但是当我尝试在设备上运行应用程序时,网址会重定向到谷歌搜索页面。当我按回按钮时,我从当前位置(按照谷歌地图)获取导航路线,到使用反向地理编码获得的当前位置。简而言之,上面提到的网址并不能满足它的要求。
请帮我解决问题。如果谷歌导航实施是错误的,请帮助我。
预先致谢
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse(http://ditu.google.cn/maps? f = d& source = s_d+
& saddr = 31.249351,121.45905& daddr = 31.186371,121.489885& hl = zh& t = m& dirflg = d))
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK& Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
intent.setClassName(com.google.android.apps.maps,com.google.android.maps.MapsActivity);
startActivity(intent);
您可以使用该代码启动Google地图应用以进行导航!
ps:dirflg = d;您可以更改参数d表示驾驶汽车,w表示通过巴士或其他方式步行r。
I am facing a very strange problem while implementing Google navigation in my Android application.
I am implementing Google navigation by opening the URL -
https://maps.google.co.in/maps?saddr=xxxxxxxxxxxxxxxxxx&daddr=xxxxxxxxxxxxx
where xxxx means source address and destination address.
Using an implicit intent. I am successfully able to get the navigation to the place by opening the web url in desktop.
But when i try to run the application on the device, the url redirects itself to google search page. And when i press back button, i get a navigation route from current location (as per google map), to current location obtained using Reverse Geocoding. In short the url above mentioned does't serve its purpose.
Please help me solve the problem. If the Google navigation implementation is wrong, please help me out in that as well.
Thanks in advance
Intent intent = new Intent( Intent.ACTION_VIEW,
Uri.parse("http://ditu.google.cn/maps?f=d&source=s_d" +
"&saddr=31.249351,121.45905&daddr=31.186371,121.489885&hl=zh&t=m&dirflg=d"));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK&Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
you can use the code to start the google map app to navigate! ps: dirflg= d; you can change the parameter "d" means driving car, "w" means walking "r" means by bus or others.
这篇关于Google地图导航 - 在Android应用程序中使用Google导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!