友
有人知道为什么marker.showInfoWindow()方法会崩溃吗?使用以下错误代码。 当我不使用该方法时,一切正常,所有标记都可以在地图中点击,并且所有自定义信息窗口都会根据需要在用户点击时显示在屏幕上。
感谢您的帮助
private void addGoogleMapAdvertisementMarker(ValueObjectAdvertiserData valueObjectAdvertiserData) {
// adds a single advertisement marker to the map and
// stores the individual marker to the arraylist markers
Marker marker = map.addMarker(new MarkerOptions()
.position(new LatLng(valueObjectAdvertiserData.latitude, valueObjectAdvertiserData.longitude))
.title(valueObjectAdvertiserData.headline)
.snippet(valueObjectAdvertiserData.description)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
marker.showInfoWindow();
markers.add(marker);
}
堆栈跟踪:
04-17 19:09:58.540 25708-25708/il.co.shabeng.SLDMP E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: il.co.shabeng.SLDMP, PID: 25708
java.lang.RuntimeException: Unable to start activity ComponentInfo{il.co.shabeng.SLDMP/il.co.shabeng.SLDMP.ActivityMain}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2328)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2386)
at android.app.ActivityThread.access$900(ActivityThread.java:169)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5476)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at il.co.shabeng.SLDMP.ActivityMain$1.getInfoContents(ActivityMain.java:244)
at com.google.android.gms.maps.GoogleMap$13.zzg(Unknown Source)
at com.google.android.gms.maps.internal.zzd$zza.onTransact(Unknown Source)
at android.os.Binder.transact(Binder.java:361)
at com.google.android.gms.maps.internal.p.b(SourceFile:112)
at com.google.maps.api.android.lib6.c.h.a(Unknown Source)
at com.google.maps.api.android.lib6.c.h.a(Unknown Source)
at com.google.maps.api.android.lib6.gmm6.c.h.b(Unknown Source)
at com.google.maps.api.android.lib6.gmm6.c.j.c(Unknown Source)
at com.google.maps.api.android.lib6.c.aj.g(Unknown Source)
at com.google.android.gms.maps.model.internal.t.onTransact(SourceFile:145)
at android.os.Binder.transact(Binder.java:361)
at com.google.android.gms.maps.model.internal.zzl$zza$zza.showInfoWindow(Unknown Source)
at com.google.android.gms.maps.model.Marker.showInfoWindow(Unknown Source)
at il.co.shabeng.SLDMP.ActivityMain.addGoogleMapAdvertisementMarker(ActivityMain.java:204)
at il.co.shabeng.SLDMP.ActivityMain.placeAdMarkersOnMap(ActivityMain.java:169)
at il.co.shabeng.SLDMP.ActivityMain.onCreate(ActivityMain.java:106)
at android.app.Activity.performCreate(Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2386)
at android.app.ActivityThread.access$900(ActivityThread.java:169)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5476)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)