下面的代碼中的吐司消息似乎並沒有顯示,我不能確定爲什麼。我錯過了一個錯誤嗎?GPS位置不顯示吐司
MyCurrentLocation
是活動名稱
public class MyLocationListener implements LocationListener{
Geocoder gc = new Geocoder(MyCurrentLocation.this.getApplicationContext(), Locale.getDefault());
public void onLocationChanged(Location loc){
try{
loc.getLatitude();
loc.getLongitude();
List <Address> addr = gc.getFromLocation(loc.getLatitude(),loc.getLongitude(),1);
String results = "";
if (addr.size() > 0){
results += addr.get(0).getCountryName();
}
Toast.makeText(getApplicationContext(),results,Toast.LENGTH_LONG).show();
} catch(Exception e){
}
了權限? – 2012-07-24 12:05:51
它在Emulator上不適用於我。它適用於Device.Did,您可以嘗試在設備上進行測試? – Abhilasha 2012-07-24 12:07:08
您是否嘗試將GPS信息發佈到Logcat? – thegrinner 2012-07-24 12:07:11