下面的代码中的吐司消息似乎并没有显示,我不能确定为什么。我错过了一个错误吗?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