为什么
getAddress(geoLng,geoLat);
address = coder.getFromLocation(mlat, mLon, 3);
给了我这个例外
07-27 00:21:14.655: E/AndroidRuntime(1228): java.lang.NullPointerException
下面是代码:
@Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
if (location != null) {
Double geoLat = location.getLatitude();
Double geoLng = location.getLongitude();
String str = ("location:(" + geoLng + "," + geoLat + ")");
getAddress(geoLng,geoLat);
}
}
//
public void getAddress(final double mlat, final double mLon) {
Thread t = new Thread(new Runnable() {
public void run() {
try {
address = coder.getFromLocation(mlat, mLon, 3);
if (address != null || address.size() > 0) {
/*handler.sendMessage(Message.obtain(handler,
Constants.GEOCODER_RESULT));*/
}
}catch (AMapException e) {
// TODO Auto-generated catch block
handler.sendMessage(Message
.obtain(handler, Constants.ERROR));
}}});
t.start();
}