我创建了一个由 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/