java - 使用 Intent 打开 Waze GPS 导航或谷歌地图

标签 java android dictionary android-intent gps

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

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

最佳答案

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

可以做 Waze 和 Google 或多选导航

关于java - 使用 Intent 打开 Waze GPS 导航或谷歌地图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47496232/

相关文章:

c# - 如何在 C# 中使用 LINQ 从字典转换为 SortedDictionary?

java - 如果主应用程序最小化,则从 JDialog 中移除焦点

java - Android自定义View——适配不同屏幕

android - Material 设计 list : hiding app bar on scroll?

android 按钮 onClick 不转换到新 Activity

来自 java map 的 Javascript map

java - 如何使用 Spring Template + JDBCTemplate 发送日期列表作为 sql 查询的一部分

java - 全局设置 hibernate 'default-cascade' 属性

javascript - 如何在主页中获取wopi发现

Python字典: Assign value as variable to key