Android意图打开Waze和Google地图 [英] Android intent for opening both Waze and Google maps

查看:169
本文介绍了Android意图打开Waze和Google地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有几个类似的帖子,但我找不到确切的一个。基本上,我想以相同的意图打开Goog​​le地图和Waze。起初我试过这个:

  final String uri = String.format(Locale.ENGLISH,geo:%f,%f ,纬度,经度); 
final Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse(uri));
startActivity(intent);

Waze直接导航到正确的位置并且Google地图打开了正确的位置。那么我意识到Google地图不会在地点上放置一个针,所以用户很难知道它的确切位置。所以我环顾四周,意识到谷歌地图需要?q = ..(标签)......我将uri结构改为:

  final String uri = String.format(Locale.ENGLISH,geo:%f,%f?q =%f,%f(%s),纬度,经度,纬度,经度,名称); 

然后Waze做了两件事:导航到正确的位置并在标签上运行搜索。这需要用户点击后退按钮关闭搜索结果屏幕,并保持导航到正确的地方。



我到处寻找答案,但未能找到一个解决方案,将实现两个。
起初我认为这是不可能的,而Waze有一个bug ......但后来我注意到Facebook Messenger正在做我想要的东西。当点击带有位置的邮件时,它将打开这两个应用程序:Google地图将会有一个pin(带有标签),Waze将直接导航到该位置而不运行搜索。



关于上述问题的几个问题:
1.(当然)我怎么能做到这一点?
2.我怎么知道Facebook Messenger的意图是如何构建的? (无论如何,我可以捕捉它)
3.标签只与?q = ..背后的原因是什么?



谢谢 p>

解决方案

没关系。我可以用下面的应用程序拦截Facebook Messenger,并认为URI应如下所示:

  String.format( Locale.ENGLISH,geo:0,0?q =)+ android.net.Uri.encode(String.format(%s @%f,%f,label,latitude,longitude),UTF-8 ); 

应用程式:
https://play.google.com/store/apps/details?id=uk.co .ashtonbrsc.android.intentintercept& feature = search_result#?t = W251bGwsMSwyLDEsInVrLmNvLmFzaHRvbmJyc2MuYW5kcm9pZC5pbnRlbnRpbnRlcmNlcHQiXQ

谢谢

There are a few similar posts but I couldn't find an exact one. basically, I want to open both Google maps and Waze with the same intent. At first I tried this:

final String uri = String.format(Locale.ENGLISH, "geo:%f,%f", latitude, longitude);
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(intent);

Waze navigated directly to the right location and Google maps opened the right place. then I realized that Google maps doesn't put a pin on the location so it's hard for the user to know where it is exactly. So I looked around and realized that Google maps requires the "?q=..(label)" for that... I changed the uri construction to:

final String uri = String.format(Locale.ENGLISH, "geo:%f,%f?q=%f,%f (%s)", latitude, longitude, latitude, longitude, name);

But then Waze did 2 things: navigated to the right place AND run a search on the label. This required the user to click the back button to close the search results screen and remain with the navigation to the right place.

I looked everywhere for an answer but failed to find a solution that will achieve both. At first I thought that it's not possible and Waze has a bug... but then I noticed that Facebook messenger is doing exactly what I want. when clicking on a message with a location it will open both apps: Google maps will have a pin (with a label) and Waze will navigate straight to that location without running a search.

Few questions about the above: 1. (Of course) How can I achieve that? 2. How can I know how the Facebook messenger's intent being built? (Can I catch it in anyway) 3. What's the reason behind having the label only with the "?q=.."?

Thanks

解决方案

Never mind. I was able to intercept the Facebook messenger with the below app and figured that the URI should be as follows:

String.format(Locale.ENGLISH, "geo:0,0?q=") + android.net.Uri.encode(String.format("%s@%f,%f", label, latitude, longitude), "UTF-8");

The app: https://play.google.com/store/apps/details?id=uk.co.ashtonbrsc.android.intentintercept&feature=search_result#?t=W251bGwsMSwyLDEsInVrLmNvLmFzaHRvbmJyc2MuYW5kcm9pZC5pbnRlbnRpbnRlcmNlcHQiXQ..

Thanks

这篇关于Android意图打开Waze和Google地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆