【问题标题】:Open Waze GPS navigation or google map with Intent使用 Intent 打开 Waze GPS 导航或谷歌地图
【发布时间】:2018-05-09 19:46:31
【问题描述】:

我尝试通过单击按钮打开导航,在选择 gps 应用程序时,我使用 waze 和谷歌地图。当我点击谷歌地图时,导航会正确启动,但当我点击 waze 时,导航不会启动。我只是得到我的位置

Intent intent = new Intent(android.content.Intent.ACTION_VIEW,

Uri.parse("google.navigation:q=22+dizengoff+street+netanya"));
            startActivity(intent);

我所有的代码:

    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    getWindow().setSoftInputMode(
            WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); //Que le clavier soit par defaut ferme

    init();
}

public void init(){
    //Reglage des bouton par ID
    btnAdd = findViewById(R.id.maAddUser);
    btnMap = findViewById(R.id.maBtnMap);


    //On click sur les boutons
    btnAdd.setOnClickListener(this);
    btnMap.setOnClickListener(this);
}


@Override
public void onClick(View v) {
    switch (v.getId()){
        case R.id.maAddUser:
            //Redirection vers l'activity ADDUSER
            Intent goAddUser = new Intent(MainActivity.this, AddUserActivity.class);
            startActivity(goAddUser); //Redirection vers ADD USER
            break;
        case R.id.maBtnMap:
            Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
                    Uri.parse("google.navigation:q=22+dizengoff+street+netanya"));
            startActivity(intent);
            break;
    }
}

【问题讨论】:

  • 能否提供更多代码?
  • 看看我的代码

标签: java android dictionary android-intent gps


【解决方案1】:

这是一个老问题,但有一个新库https://github.com/pkitools/Android-Location-Navigator

这可以做位智和谷歌或多选导航

【讨论】:

    【解决方案2】:
    try {
        // Launch Waze
        String mapRequest = "https://waze.com/ul?q=" + latLng.latitude + "," + latLng.longitude + "&navigate=yes&zoom=17";
        Uri gmmIntentUri = Uri.parse(mapRequest);
        Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
        mapIntent.setPackage("com.waze");
        startActivity(mapIntent);
    
        } catch (ActivityNotFoundException e) {
        // If Waze is not installed, open it in Google Play
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.waze"));
        startActivity(intent);
        }
    
    【解决方案3】:

    也在为此苦苦挣扎。 看来你可以使用:

    String uri = "google.navigation:q=" + position.latitude + "," + position.longitude;
    

    开始在谷歌地图中导航,或

    String uri = "geo:0,0?q=" + position.latitude + "," + position.longitude;
    

    在位智中开始导航。我找不到在这两种情况下都能无缝工作的解决方案,但后者确实在谷歌地图上的位置显示了一个图钉,因此只需要一个额外的按钮点击即可获得方向(对我来说仍然是不可接受的用户体验)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-23
      • 2011-12-19
      • 2019-01-12
      • 2021-03-31
      • 2018-03-23
      • 2018-05-21
      • 1970-01-01
      相关资源
      最近更新 更多