我正在开发一个 android 应用程序。在我的活动中,我使用以下代码。
LocationResult locationResult = new LocationResult(){
@Override
public void gotLocation(Location location){
//Got the location!
Drawable marker = getResources().getDrawable(
R.drawable.currentlocationmarker);//android.R.drawable.btn_star_big_on
int markerWidth = marker.getIntrinsicWidth();
int markerHeight = marker.getIntrinsicHeight();
marker.setBounds(0, markerHeight, markerWidth, 0);
MyItemizedOverlay myItemizedOverlay = new MyItemizedOverlay(marker);
currentmarkerPoint = new GeoPoint((int) (location.getLatitude() * 1E6),
(int) (location.getLongitude() * 1E6));
currLocation = location;
mBlippcoordinate = currentmarkerPoint;
mBlippLocation = location;
myItemizedOverlay.addItem(currentmarkerPoint, "", "");
mBlippmapview.getOverlays().add(myItemizedOverlay);
animateToCurrentLocation(currentmarkerPoint);
}
};
MyLocation myLocation = new MyLocation();
myLocation.getLocation(this, locationResult);
我正在使用上面的代码从 gps 或网络中查找位置。该animateToCurrentLocation(currentmarkerPoint);
方法包含一个异步任务。所以我得到
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
提前致谢。