android:geo使用intent的位置 [英] android :geo Location using intent
本文介绍了android:geo使用intent的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个ListView,当我点击一个项目时,它会进入单项视图。在每个单项视图页面中都有一个位置按钮。我需要在点击位置按钮时去谷歌地图
I have a ListView and when i click a single item it goes to single item view . in each single item view page there is a location button .I need to go to google map when click the location button
longtitute和纬度保存在数据库中这个 。
我想在每个CELL OF THE COLUMN中动态调用
,数据存储如下,
数据存储为解析数据库中的对象,而不是字符串
{ lat:25.1250241,lng:55.3752069}
{"lat":25.1250241,"lng":55.3752069}
有谁知道请告诉我如何从中获取数据?
anyone knows please tell how can i get data from this?
btn = (Button) findViewById(R.id.button5) ;
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
btn = (Button) findViewById(R.id.button56) ;
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
String data = String.format("geo:%s,%s", latitude, longitude);
intent.setData(Uri.parse(data));
startActivity(intent);
}
});
推荐答案
终于找到了方法..
这是我用来获取坐标的代码
this is the code i use to get only the coordinates
showCorporate = (Button) findViewById(R.id.individualEmail);
showCorporate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String[] location = corporateLocation.split(",");
double lat, lng;
try{
lat = fetchDouble(location[0], true);
lng = fetchDouble(location[1], false);
Log.d("Co-Ordinates",""+lat+", "+lng);
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
String data = String.format("geo:%s,%s", lat, lng);
intent.setData(Uri.parse(data));
startActivity(intent);
}catch (NullPointerException npe){
Toast.makeText(SingleCorporate.this, "Sorry No Location Available!", Toast.LENGTH_SHORT).show();
}
}
});
这篇关于android:geo使用intent的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文