Using the pre-installed Google Maps instead of an own activity by using Intents?

时间秒杀一切 提交于 2019-12-06 10:50:40
Dan Lew

The documentation on Google Intents is here: https://developer.android.com/guide/appendix/g-app-intents.html

Unfortunately, it is (to my knowledge) currently limited to simply displaying a location, not a route. The user could then use that location to plot their own route, though.

There is a way, but you would need to get the coordinates of your current location by yourself (setting up a location listener). Once you have your location and your destination coordinates, fire this intent (this will let the user choose between Google Maps or Browser):

Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
Uri.parse("http://maps.google.com/maps?saddr=20.344,34.34&daddr=20.5666,45.345"));
startActivity(intent);

IF THIS IS POSSIBLE, is it also possible to ask google maps to calculate the route by my CURRENT POSITION?

No. The only documented Intents simply open a map on a point. There are no documented Intents at this time to launch straight into the navigation portion of the app.

Sorry!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!