admin管理员组文章数量:1414908
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.
When I use :
<script>
document.location = "geo:0,0?q=myaddress";
</script>
That works fine but does not show me the route.
What I read from this : Android Google Directions Service usable natively? with wrapper framework? Public transit/biking directions available?
It should be possible using this code :
String url = "+address&daddr=another+Address"
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url));
Can I do the same just using javascript ?
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.
When I use :
<script>
document.location = "geo:0,0?q=myaddress";
</script>
That works fine but does not show me the route.
What I read from this : Android Google Directions Service usable natively? with wrapper framework? Public transit/biking directions available?
It should be possible using this code :
String url = "http://maps.google./maps?saddr=some+address&daddr=another+Address"
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url));
Can I do the same just using javascript ?
Share Improve this question edited May 23, 2017 at 11:44 CommunityBot 11 silver badge asked Mar 5, 2013 at 14:09 PhDJPhDJ 3131 gold badge5 silver badges16 bronze badges2 Answers
Reset to default 3Android 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.
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
.
Just simply call the function from JavaScript to Android , and inside the function you can call the android intent.
you can find out the tutorial how to call android function from JavaScript:
http://android-er.blogspot.in/2011/10/call-javascript-inside-webview-from.html
and call the map using Google V3 library .
https://developers.google./maps/articles/android_v3
本文标签: Can I launch an intent using only javascript in an Android browserStack Overflow
版权声明:本文标题:Can I launch an intent using only javascript in an Android browser? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745160995a2645438.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论