我可以推出在Android浏览器中使用只有JavaScript的意图是什么? [英] Can I launch an intent using only javascript in an Android browser?

查看:101
本文介绍了我可以推出在Android浏览器中使用只有JavaScript的意图是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HTML页面,显示从当前位置的方向一定的地址

I have a html page that shows the directions from the current location to a certain address.

我愿做相同的,但用的不是显示在浏览器中它的地图应用程序。

I would like to do the same but use the map app instead of showing it in a browser.

当我使用:

<script>
    document.location = "geo:0,0?q=myaddress";
</script>

这工作正常,但不显示我的路线。

That works fine but does not show me the route.

我从这个读什么:<一href=\"http://stackoverflow.com/questions/2853017/android-google-directions-service-usable-natively-with-wrapper-framework-publi\">Android谷歌地图服务可用本机?与包装框架?公交/自行车路线?

应该使用这个code可以:

It should be possible using this code :

String url = "http://maps.google.com/maps?saddr=some+address&daddr=another+Address"
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,  Uri.parse(url));

我可以做只是使用JavaScript一样吗?

Can I do the same just using javascript ?

推荐答案

Android是能够检测浏览器链接到谷歌地图和重定向意图本机谷歌地图应用程序,如果它被设置为默认应用程序。然而,有没有办法强迫用户使用谷歌地图应用。点击链接也可以显示他在浏览器中的活动选择器或打开谷歌地图。这也可能打开一个注册到处理相同意图的第三方应用程序。在code片段你贴的行为完全一样了。

Android is capable of detecting links to Google Maps in the browser and redirect the Intent to the native Google Maps app, if it is set as the default app. There is, however, no way to force the user to use the Google Maps app. Clicking the link can also show him the activity chooser or open Google Maps in the browser. It might also open a third-party app that is registered to handle the same Intent. The code snippet you posted will behave exactly like that, too.

此不仅从浏览器的工作原理,但与系统中的所有链接。比如,我给你发布的链接通过电子邮件对自己和点击它在我的手机。我可以用我的Goolge地图应用程序打开它。所以实在没有必要为JavaScript,你可以使用一个简单的HTML链接发送意图

This not only works from the browser, but with all links in the system. For example, I sent the link you posted via e-mail to myself and clicked it on my phone. I could open it with my Goolge Maps app. So there is really no need for JavaScript, you can just use a simple HTML link to send the Intent.

这篇关于我可以推出在Android浏览器中使用只有JavaScript的意图是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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