android - 从sqlite获取经纬度打开waze

标签 android sqlite google-maps android-studio

我创建了一个由 ListView 和 map 组成的应用程序。当用户从 ListView 中选择时, map 将自动转到该位置。位置的配置文件也会显示。由按钮组成的配置文件,当用户点击时,它将指向位智并获取经度纬度。我不知道我的代码有什么问题,因为它无法获取位置的纬度和经度。我认为我的问题出在字符串 url 中,我无法获取纬度和经度,但我不知道获取它的正确代码。

        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

              LatLng latLngtofocus = new LatLng(Double.parseDouble(GetLocation.get(i).getlatitude()),  Double.parseDouble(GetLocation.get(i).getlatitude()));

                    map.animateCamera(CameraUpdateFactory.newLatLngZoom(latlngtofocus, 17.0f));
                }


    LocationListView = findViewById(R.id.locationlayout);
                    ViewGroup parent = (ViewGroup) LocationListView.getParent();
                    parent.removeView(LocationListView);
                    // inflate your profile view (or get the reference to it if it's already inflated)
                    LocationProfileView = getLayoutInflater().inflate(R.layout.profile_location, parent, false);
                    // add it to the parent
                    parent.addView(LocationProfileView);

btnwaze = (Button) findViewById(R.id.waze);
                btnwaze.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        try
                        {
                            String url = "waze://?q=(Double.parseDouble(GetLocation.get(i).getlatitude()), Double.parseDouble(GetLocation.get(i).getlongitude()))";
                            Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse( url ) );
                            startActivity( intent );
                        }
                        catch ( ActivityNotFoundException ex  )
                        {
                            Intent intent =
                                    new Intent( Intent.ACTION_VIEW, Uri.parse( "market://details?id=com.waze" ) );
                            startActivity(intent);
                        }
                    }
                });
  });

最佳答案

设置为 final int i 并将之前的代码更改为 String url = "waze://?ll="+GetLocation.get(i).getlatitude()+","+ GetLocation.get(i).getlongitude( )+"&navigate=yes";

关于android - 从sqlite获取经纬度打开waze,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33471856/

相关文章:

android - 在 Android 应用程序上为 "offline viewing"的在线服务保留用户数据

sqlite - 在 SQLite 数据库浏览器中创建外键

javascript - 更改新 Google 标记的颜色(Google JS API v3)

java - Android - OnClick 在子类中而不是 super 中使用

android - 为什么我使用相机传递结果 ResultInfo 失败?

android - 将来自服务器的数据以 JSON 形式存储到 Android Sqlite 数据库中

java - 如何在android中定义地理围栏的矩形

android - 在谷歌地图中显示路线/ map 按钮

java - 何时调用 editor.apply?

android - 如何从Android程序将SQLite数据库文件上传到FTP服务器