Google Navigation intent

2019-02-14 23:10发布

I'm trying to launch Google Navigation directly from my application such that it would navigate me from a start address to a destination address. So I have the Latitude and Longitude coordinates for both start and destination address and would like to get the navigation for those. But I can't figure out how to provide a start address. Navigation only uses my GPS to obtain my current info. This is how I launch the intent:

        String mLat = "46.849861";
        String mLong ="-120.541992";
        String dLat = "38.062419";
        String dLong = "-99.173584";
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=" +dLat+","+dLong));
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);

1条回答
家丑人穷心不美
2楼-- · 2019-02-15 00:08

You can do it this way

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);
查看更多
登录 后发表回答