启动 google 导航并返回我的应用程序 android

start google navigation and go back to my app android

我正在尝试从我的应用打开 google 导航,然后单击 "back" 返回我的应用。 我正在使用此代码:

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

但是当按下 "back" 时 google 导航刷新。

如果我使用 startActivityForResult(intent, 1); google 导航打不开。

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

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);

希望这会有所帮助!!