作者nomeans (Walter)
看板java
标题[问题] android的onLocationChanged
时间Sat Mar 27 18:36:43 2010
1.最近在写android GPS的相关程式
其中一个需要的功能是当我经纬度改变时会跳出Toast
public void onLocationChanged(Location location) {
if(location!=null){
Toast.makeText(gps.this,location.toString(),Toast.LENGTH_SHORT);
}
else{
Toast.makeText(gps.this, "error", Toast.LENGTH_SHORT);
}
可是我在模拟器内
不管DDMS那边怎麽传经纬度给模拟器
我的程式都是没反应
2.另外一个问题是当我发现我没有开启GPS时
书上是这样写可以让程式跳到settings去开启GPS
可是我一执行就会强迫关闭
if(state.isProviderEnabled(LocationManager.GPS_PROVIDER)||mgr.isProviderEnabled(LocationManager.NETWORK_PROVIDER)){
gpsIndexWidget();
}
else{
Toast.makeText(gps.this,"test",Toast.LENGTH_SHORT);
startActivity(new Intent(Settings.ACTION_LOCALE_SETTINGS));
}
麻烦各位了
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.167.129.84
1F:推 johnlinvc:你有register LocationListener吗? 03/27 20:58
2F:→ nomeans:我耍笨了XDDD 第一个没有跳出toast是因为我没有.show() 03/27 21:44