gpt4 book ai didi

android - 启动谷歌导航并返回我的应用程序 android

转载 作者:行者123 更新时间:2023-11-30 02:23:29 25 4
gpt4 key购买 nike

我正在尝试从我的应用程序中打开谷歌导航,然后单击“返回”返回我的应用程序。我正在使用这段代码:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=" + destination));
startActivity(intent);

但是当按下“后退”时谷歌导航刷新。

如果我正在使用 startActivityForResult(intent, 1);谷歌导航打不开。

最佳答案

你没有在你的 Intent 中设置一个标志,试试这个工作代码:

Intent navigation = new Intent( Intent.ACTION_VIEW, 
Uri.parse("http://maps.google.com/maps?f=d&source=s_d" +
"&saddr=xx.xxxxx,yy.yyyyy&daddr=xx.xxxxx,yy.yyyyy"));
navigation.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK&Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
navigation.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(navigation);

希望这会有所帮助!!

关于android - 启动谷歌导航并返回我的应用程序 android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28140378/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com