看板 java 關於我們 聯絡資訊
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
johnlinvc:你有register LocationListener嗎? 03/27 20:58
nomeans:我耍笨了XDDD 第一個沒有跳出toast是因為我沒有.show() 03/27 21:44