在地图上标记当前位置,机器人 [英] Marking Current Location on Map, Android
问题描述
我跟着一些教程创建示出了具有标记在地图上的用户的当前位置的应用程序。但因为某些原因,我不能去上班了标记的一部分?其他部分正常工作,但每当我添加了标记code中的应用程序崩溃。
这里是code:
公共类LocationActivity扩展MapActivity {
私人图形页面图形页面;
私人LocationManager流明;
私人LocationListener的LL;
私人MapController MC;
的GeoPoint P = NULL;
可绘制defaultMarker = NULL;
@覆盖
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.main);
图形页面=(图形页面)findViewById(R.id.mapView);
//显示放大/缩小按钮
mapView.setBuiltInZoomControls(真正的);
//地图的标准视图(图/坐)
mapView.setSatellite(假);
//获取地图的控制器,用于放大/缩小
MC = mapView.getController();
//缩放级别
mc.setZoom(18);
MyLocationOverlay myLocationOverlay =新MyLocationOverlay();
名单<覆盖>表=调用MapView.getOverlays();
list.add(myLocationOverlay);
LM =(LocationManager)getSystemService(Context.LOCATION_SERVICE);
LL =新MyLocationListener();
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,LL);
//获取初创型的当前位置
的GeoPoint initGeoPoint =新的GeoPoint((INT)(lm.getLastKnownLocation(
LocationManager.GPS_PROVIDER).getLatitude()* 1000000)
(INT)(lm.getLastKnownLocation(LocationManager.GPS_PROVIDER)
.getLongitude()* 1000000));
mc.animateTo(initGeoPoint);
}
保护类MyLocationOverlay扩展com.google.android.maps.Overlay {
@覆盖
公共布尔平局(画布油画,图形页面图形页面,布尔阴影,
时长){
涂料粉刷=新的油漆();
super.draw(帆布,图形页面,阴影);
//转换纬度/经度,指向我们在屏幕上的坐标。
点myScreenCoords =新的点();
MapView.getProjection()在toPixels(对,myScreenCoords)。
paint.setStrokeWidth(1);
paint.setARGB(255,255,255,255);
paint.setStyle(Paint.Style.STROKE);
BMP位= BitmapFactory.de codeResource(getResources()
R.drawable.push);
canvas.drawBitmap(BMP,myScreenCoords.x,myScreenCoords.y,油漆);
canvas.drawText(我在这里......,myScreenCoords.x,myScreenCoords.y,
涂料);
返回true;
}
}
私有类MyLocationListener实现LocationListener的{
公共无效onLocationChanged(位置argLocation){
的GeoPoint myGeoPoint =新的GeoPoint(
(中间体)(argLocation.getLatitude()* 1000000),
(中间体)(argLocation.getLongitude()* 1000000));
/ *
*它会显示在位置变化的消息
* Toast.makeText(getBaseContext(),新的位置纬度[
* + argLocation.getLatitude()+]东经[+
* argLocation.getLongitude()+],Toast.LENGTH_SHORT).show();
* /
mc.animateTo(myGeoPoint);
}
公共无效onProviderDisabled(字符串提供商){}
公共无效onProviderEnabled(字符串提供商){}
公共无效onStatusChanged(字符串商,INT地位,捆绑演员){}
}
保护的布尔isRouteDisplayed(){
返回false;
}
}
这里是logcat的:
5月1号至19日:31:43.011:DEBUG / AndroidRuntime(759):>>>>>>>>>>> >>> AndroidRuntime START<<<<<<<<<<<<<<
五月一号至19号:31:43.011:DEBUG / AndroidRuntime(759):CheckJNI为ON
五月一号至19号:31:43.411:DEBUG / AndroidRuntime(759):---注册本地函数---
五月一号至19号:31:43.431:信息/ JDWP(759):接收到的文件描述符19亚行
五月一号至19号:31:43.431:信息/ JDWP(759):忽略第二调试器 - 接受和丢弃
五月一号至19号:31:44.531:信息/ ActivityManager(583):启动活动:意向{FLG = 0x10000000处CMP = pro.googlemapp / .LocationActivity}
五月一号至19号:31:44.641:DEBUG / AndroidRuntime(759):关闭虚拟机
五月一号至19号:31:44.641:DEBUG / dalvikvm(759):DestroyJavaVM等非守护线程退出
五月一号至19号:31:44.641:DEBUG / dalvikvm(759):DestroyJavaVM关闭VM下来
五月一号至19号:31:44.641:DEBUG / dalvikvm(759):HeapWorker线程关闭
五月一号至19号:31:44.651:DEBUG / dalvikvm(759):HeapWorker线程已关闭
五月一号至19号:31:44.651:DEBUG / JDWP(759):JDWP关闭网...
五月一号至19号:31:44.651:DEBUG / JDWP(759):+++同行断开
五月一号至19号:31:44.651:信息/ dalvikvm(759):调试器分离;对象注册了1项
五月一号至19号:31:44.661:DEBUG / dalvikvm(759):虚拟机清理
五月一号至19号:31:44.681:信息/ ActivityManager(583):启动PROC pro.googlemapp的活动pro.googlemapp / .LocationActivity:PID = 770 UID = 10025导报= {3003}
一月一十九号05:31:44.761:调试/ dalvikvm(759):为0x0 LinearAlloc使用676436的4194304(16%)
五月一号至19号:31:44.801:信息/ JDWP(770):接收到的文件描述符20亚行
五月一号至19号:31:44.822:信息/ dalvikvm(770):螺纹忽略registerObject请求= 3
五月一号至19号:31:44.851:信息/ JDWP(770):忽略第二调试器 - 接受和丢弃
五月一号至19号:31:44.851:ERROR / JDWP(770):无法写握手字节:中断的管道(14 -1)
五月一号至19号:31:44.851:信息/ dalvikvm(770):调试器分离;对象注册表有0项
五月一号至19号:31:45.320:ERROR / ActivityThread(770):未能找到com.google.settings供应商信息
五月一号至19号:31:45.320:ERROR / ActivityThread(770):未能找到com.google.settings供应商信息
五月一号至19号:31:45.340:ERROR / ActivityThread(770):未能找到com.google.settings供应商信息
五月一号至19号:31:45.781:DEBUG / LocationManager(770):构造函数:服务= android.location.ILocationManager$Stub$Proxy@4379d9f0
五月一号至19号:31:45.791:WARN / GpsLocationProvider(583):重复添加监听UID 10025
五月一号至19号:31:45.791:DEBUG / GpsLocationProvider(583):setMinTime 0
五月一号至19号:31:45.791:DEBUG / GpsLocationProvider(583):startNavigating
五月一号至19号:31:45.831:信息/ JDWP(770):接收到的文件描述符27亚行
五月一号至19号:31:46.001:信息/ MapActivity(770):处理网络变更通知:连
五月一号至19号:31:46.001:ERROR / MapActivity(770):不能获得连接工厂客户端
五月一号至19号:31:46.451:DEBUG / dalvikvm(770):GC释放4539对象/在118ms 298952字节
五月一号至19号:31:46.470:DEBUG / AndroidRuntime(770):关闭虚拟机
五月一号至19号:31:46.470:WARN / dalvikvm(770):主题ID = 3:线程退出与未捕获的异常(组= 0x4001aa28)
五月一号至19号:31:46.481:ERROR / AndroidRuntime(770):未捕获的处理程序:螺纹主力退出,由于未捕获的异常
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):显示java.lang.NullPointerException
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在com.google.android.maps.PixelConverter.toPixels(PixelConverter.java:58)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在com.google.android.maps.PixelConverter.toPixels(PixelConverter.java:48)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在pro.googlemapp.LocationActivity $ MyLocationOverlay.draw(LocationActivity.java:101)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在com.google.android.maps.OverlayBundle.draw(OverlayBundle.java:42)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在com.google.android.maps.MapView.onDraw(MapView.java:476)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在android.view.View.draw(View.java:6274)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在android.view.ViewGroup.drawChild(ViewGroup.java:1526)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在android.view.ViewGroup.drawChild(ViewGroup.java:1524)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在android.view.View.draw(View.java:6277)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在android.widget.FrameLayout.draw(FrameLayout.java:352)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在android.view.ViewGroup.drawChild(ViewGroup.java:1526)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在android.view.ViewGroup.drawChild(ViewGroup.java:1524)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在android.view.View.draw(View.java:6277)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在android.widget.FrameLayout.draw(FrameLayout.java:352)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在com.android.internal.policy.impl.PhoneWindow $ DecorView.draw(PhoneWindow.java:1883)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在android.view.ViewRoot.draw(ViewRoot.java:1332)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在android.view.ViewRoot.performTraversals(ViewRoot.java:1097)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在android.view.ViewRoot.handleMessage(ViewRoot.java:1613)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在android.os.Handler.dispatchMessage(Handler.java:99)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在android.os.Looper.loop(Looper.java:123)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在android.app.ActivityThread.main(ActivityThread.java:4203)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在java.lang.reflect.Method.invokeNative(本机方法)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在java.lang.reflect.Method.invoke(Method.java:521)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:791)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
五月一号至19号:31:46.541:ERROR / AndroidRuntime(770):在dalvik.system.NativeStart.main(本机方法)
五月一号至19号:31:46.551:信息/程序(583):发送信号。 PID:770 SIG:3
五月一号至19号:31:46.581:信息/ dalvikvm(770):主题ID = 7:反应信号3
五月一号至19号:31:46.661:信息/ dalvikvm(770):写堆栈跟踪/data/anr/traces.txt
五月一号至19号:31:46.871:信息/ ARMAssembler(583):产生scanline__00000077:03515104_00000000_00000000 [27 IPP](41英寸),在[0x2c69c8:0x2c6a6c在973448 NS
五月一号至19号:31:46.911:信息/ ARMAssembler(583):产生scanline__00000077:03515104_00001001_00000000 [64 IPP](84英寸),在[0x2c6a70:0x2c6bc0在1985378 NS
五月一号至19号:31:49.881:信息/程序(770):发送信号。 PID:770 SIG:9
五月一号至19号:31:49.931:信息/ ActivityManager(583):过程pro.googlemapp(PID 770)已经死亡。
五月一号至19号:31:49.941:WARN / GpsLocationProvider(583):不需要的删除监听器UID 1000
五月一号至19号:31:49.941:DEBUG / GpsLocationProvider(583):stopNavigating
五月一号至19号:31:49.951:信息/窗口管理器(583):WIN死亡:窗口{438891c0 pro.googlemapp / pro.googlemapp.LocationActivity暂停= FALSE}
五月一号至19号:31:50.111:WARN / UsageStats(583):com.android.launcher意外的简历时,如果已经恢复了pro.googlemapp
五月一号至19号:31:50.200:WARN / InputManagerService(583):得到的RemoteException发送SETACTIVE(假)通知,为PID 770 UID 10025
您构建MyLocationOverlay可能有一些问题的方式。
MyLocationOverlay mylocationOverlay =新MyLocationOverlay(本,图形页面);
根据谷歌$ C 你需要通过一个背景和一个图形页面参数$ C API。
然后把这些code之后
mylocationOverlay.enableMyLocation();
调用MapView.getOverlays()加(locationOverlay)。
也把
mylocationOverlay.enableMyLocation();
在onResume()方法
希望这可以帮助你。
I followed some tutorials to create an application that shows the current position of the user on the map with a marking. But for some reasons I can't get to work the marking part? The other parts work well, but whenever I add the marking code the application crashes.
Here is the code:
public class LocationActivity extends MapActivity {
private MapView mapView;
private LocationManager lm;
private LocationListener ll;
private MapController mc;
GeoPoint p = null;
Drawable defaultMarker = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.mapView);
// show zoom in/out buttons
mapView.setBuiltInZoomControls(true);
// Standard view of the map(map/sat)
mapView.setSatellite(false);
// get controller of the map for zooming in/out
mc = mapView.getController();
// Zoom Level
mc.setZoom(18);
MyLocationOverlay myLocationOverlay = new MyLocationOverlay();
List<Overlay> list = mapView.getOverlays();
list.add(myLocationOverlay);
lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
ll = new MyLocationListener();
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll);
// Get the current location in start-up
GeoPoint initGeoPoint = new GeoPoint((int) (lm.getLastKnownLocation(
LocationManager.GPS_PROVIDER).getLatitude() * 1000000),
(int) (lm.getLastKnownLocation(LocationManager.GPS_PROVIDER)
.getLongitude() * 1000000));
mc.animateTo(initGeoPoint);
}
protected class MyLocationOverlay extends com.google.android.maps.Overlay {
@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow,
long when) {
Paint paint = new Paint();
super.draw(canvas, mapView, shadow);
// Converts lat/lng-Point to OUR coordinates on the screen.
Point myScreenCoords = new Point();
mapView.getProjection().toPixels(p, myScreenCoords);
paint.setStrokeWidth(1);
paint.setARGB(255, 255, 255, 255);
paint.setStyle(Paint.Style.STROKE);
Bitmap bmp = BitmapFactory.decodeResource(getResources(),
R.drawable.push);
canvas.drawBitmap(bmp, myScreenCoords.x, myScreenCoords.y, paint);
canvas.drawText("I am here...", myScreenCoords.x, myScreenCoords.y,
paint);
return true;
}
}
private class MyLocationListener implements LocationListener {
public void onLocationChanged(Location argLocation) {
GeoPoint myGeoPoint = new GeoPoint(
(int) (argLocation.getLatitude() * 1000000),
(int) (argLocation.getLongitude() * 1000000));
/*
* it will show a message on location change
* Toast.makeText(getBaseContext(), "New location latitude ["
* +argLocation.getLatitude() + "] longitude [" +
* argLocation.getLongitude()+"]", Toast.LENGTH_SHORT).show();
*/
mc.animateTo(myGeoPoint);
}
public void onProviderDisabled(String provider) {}
public void onProviderEnabled(String provider) {}
public void onStatusChanged(String provider, int status, Bundle extras) {}
}
protected boolean isRouteDisplayed() {
return false;
}
}
here is the logcat:
01-19 05:31:43.011: DEBUG/AndroidRuntime(759): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
01-19 05:31:43.011: DEBUG/AndroidRuntime(759): CheckJNI is ON
01-19 05:31:43.411: DEBUG/AndroidRuntime(759): --- registering native functions ---
01-19 05:31:43.431: INFO/jdwp(759): received file descriptor 19 from ADB
01-19 05:31:43.431: INFO/jdwp(759): Ignoring second debugger -- accepting and dropping
01-19 05:31:44.531: INFO/ActivityManager(583): Starting activity: Intent { flg=0x10000000 cmp=pro.googlemapp/.LocationActivity }
01-19 05:31:44.641: DEBUG/AndroidRuntime(759): Shutting down VM
01-19 05:31:44.641: DEBUG/dalvikvm(759): DestroyJavaVM waiting for non-daemon threads to exit
01-19 05:31:44.641: DEBUG/dalvikvm(759): DestroyJavaVM shutting VM down
01-19 05:31:44.641: DEBUG/dalvikvm(759): HeapWorker thread shutting down
01-19 05:31:44.651: DEBUG/dalvikvm(759): HeapWorker thread has shut down
01-19 05:31:44.651: DEBUG/jdwp(759): JDWP shutting down net...
01-19 05:31:44.651: DEBUG/jdwp(759): +++ peer disconnected
01-19 05:31:44.651: INFO/dalvikvm(759): Debugger has detached; object registry had 1 entries
01-19 05:31:44.661: DEBUG/dalvikvm(759): VM cleaning up
01-19 05:31:44.681: INFO/ActivityManager(583): Start proc pro.googlemapp for activity pro.googlemapp/.LocationActivity: pid=770 uid=10025 gids={3003}
01-19 05:31:44.761: DEBUG/dalvikvm(759): LinearAlloc 0x0 used 676436 of 4194304 (16%)
01-19 05:31:44.801: INFO/jdwp(770): received file descriptor 20 from ADB
01-19 05:31:44.822: INFO/dalvikvm(770): ignoring registerObject request in thread=3
01-19 05:31:44.851: INFO/jdwp(770): Ignoring second debugger -- accepting and dropping
01-19 05:31:44.851: ERROR/jdwp(770): Failed writing handshake bytes: Broken pipe (-1 of 14)
01-19 05:31:44.851: INFO/dalvikvm(770): Debugger has detached; object registry had 0 entries
01-19 05:31:45.320: ERROR/ActivityThread(770): Failed to find provider info for com.google.settings
01-19 05:31:45.320: ERROR/ActivityThread(770): Failed to find provider info for com.google.settings
01-19 05:31:45.340: ERROR/ActivityThread(770): Failed to find provider info for com.google.settings
01-19 05:31:45.781: DEBUG/LocationManager(770): Constructor: service = android.location.ILocationManager$Stub$Proxy@4379d9f0
01-19 05:31:45.791: WARN/GpsLocationProvider(583): Duplicate add listener for uid 10025
01-19 05:31:45.791: DEBUG/GpsLocationProvider(583): setMinTime 0
01-19 05:31:45.791: DEBUG/GpsLocationProvider(583): startNavigating
01-19 05:31:45.831: INFO/jdwp(770): received file descriptor 27 from ADB
01-19 05:31:46.001: INFO/MapActivity(770): Handling network change notification:CONNECTED
01-19 05:31:46.001: ERROR/MapActivity(770): Couldn't get connection factory client
01-19 05:31:46.451: DEBUG/dalvikvm(770): GC freed 4539 objects / 298952 bytes in 118ms
01-19 05:31:46.470: DEBUG/AndroidRuntime(770): Shutting down VM
01-19 05:31:46.470: WARN/dalvikvm(770): threadid=3: thread exiting with uncaught exception (group=0x4001aa28)
01-19 05:31:46.481: ERROR/AndroidRuntime(770): Uncaught handler: thread main exiting due to uncaught exception
01-19 05:31:46.541: ERROR/AndroidRuntime(770): java.lang.NullPointerException
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at com.google.android.maps.PixelConverter.toPixels(PixelConverter.java:58)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at com.google.android.maps.PixelConverter.toPixels(PixelConverter.java:48)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at pro.googlemapp.LocationActivity$MyLocationOverlay.draw(LocationActivity.java:101)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at com.google.android.maps.OverlayBundle.draw(OverlayBundle.java:42)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at com.google.android.maps.MapView.onDraw(MapView.java:476)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.View.draw(View.java:6274)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.ViewGroup.drawChild(ViewGroup.java:1526)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.ViewGroup.drawChild(ViewGroup.java:1524)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.View.draw(View.java:6277)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.widget.FrameLayout.draw(FrameLayout.java:352)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.ViewGroup.drawChild(ViewGroup.java:1526)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.ViewGroup.drawChild(ViewGroup.java:1524)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.View.draw(View.java:6277)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.widget.FrameLayout.draw(FrameLayout.java:352)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1883)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.ViewRoot.draw(ViewRoot.java:1332)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.ViewRoot.performTraversals(ViewRoot.java:1097)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.ViewRoot.handleMessage(ViewRoot.java:1613)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.os.Handler.dispatchMessage(Handler.java:99)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.os.Looper.loop(Looper.java:123)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.app.ActivityThread.main(ActivityThread.java:4203)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at java.lang.reflect.Method.invokeNative(Native Method)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at java.lang.reflect.Method.invoke(Method.java:521)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
01-19 05:31:46.541: ERROR/AndroidRuntime(770): at dalvik.system.NativeStart.main(Native Method)
01-19 05:31:46.551: INFO/Process(583): Sending signal. PID: 770 SIG: 3
01-19 05:31:46.581: INFO/dalvikvm(770): threadid=7: reacting to signal 3
01-19 05:31:46.661: INFO/dalvikvm(770): Wrote stack trace to '/data/anr/traces.txt'
01-19 05:31:46.871: INFO/ARMAssembler(583): generated scanline__00000077:03515104_00000000_00000000 [ 27 ipp] (41 ins) at [0x2c69c8:0x2c6a6c] in 973448 ns
01-19 05:31:46.911: INFO/ARMAssembler(583): generated scanline__00000077:03515104_00001001_00000000 [ 64 ipp] (84 ins) at [0x2c6a70:0x2c6bc0] in 1985378 ns
01-19 05:31:49.881: INFO/Process(770): Sending signal. PID: 770 SIG: 9
01-19 05:31:49.931: INFO/ActivityManager(583): Process pro.googlemapp (pid 770) has died.
01-19 05:31:49.941: WARN/GpsLocationProvider(583): Unneeded remove listener for uid 1000
01-19 05:31:49.941: DEBUG/GpsLocationProvider(583): stopNavigating
01-19 05:31:49.951: INFO/WindowManager(583): WIN DEATH: Window{438891c0 pro.googlemapp/pro.googlemapp.LocationActivity paused=false}
01-19 05:31:50.111: WARN/UsageStats(583): Unexpected resume of com.android.launcher while already resumed in pro.googlemapp
01-19 05:31:50.200: WARN/InputManagerService(583): Got RemoteException sending setActive(false) notification to pid 770 uid 10025
the way you construct the MyLocationOverlay might have some problem.
MyLocationOverlay mylocationOverlay = new MyLocationOverlay(this, mapView);
according to the google code api you need to pass a context and a mapview param.
and then put these code after that
mylocationOverlay.enableMyLocation();
mapView.getOverlays().add(locationOverlay);
also put
mylocationOverlay.enableMyLocation();
in the onResume() method
Hope this could help you.
这篇关于在地图上标记当前位置,机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!