gpt4 book ai didi

android - IllegalStateException 映射大小不应为 0

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:23:33 26 4
gpt4 key购买 nike

<分区>

我有一个显示 map 的MapFragment

如果用户离开 map 的 Activity (或设备进入休眠状态)然后返回 onResume 被调用,我将 map 移回标记。

但是当我移动相机时出现异常

07-23 16:28:42.725: E/AndroidRuntime(19095): java.lang.RuntimeException: Unable to resume activity {ecm2.android/ecm2.android.EMGNoteMapActivity}: java.lang.IllegalStateException: Map size should not be 0. Most likely, layout has not yet occured for the map view.
07-23 16:28:42.725: E/AndroidRuntime(19095): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2742)
07-23 16:28:42.725: E/AndroidRuntime(19095): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2771)
07-23 16:28:42.725: E/AndroidRuntime(19095): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2235)
07-23 16:28:42.725: E/AndroidRuntime(19095): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-23 16:28:42.725: E/AndroidRuntime(19095): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-23 16:28:42.725: E/AndroidRuntime(19095): at android.os.Handler.dispatchMessage(Handler.java:99)
07-23 16:28:42.725: E/AndroidRuntime(19095): at android.os.Looper.loop(Looper.java:137)
07-23 16:28:42.725: E/AndroidRuntime(19095): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-23 16:28:42.725: E/AndroidRuntime(19095): at java.lang.reflect.Method.invokeNative(Native Method)
07-23 16:28:42.725: E/AndroidRuntime(19095): at java.lang.reflect.Method.invoke(Method.java:511)
07-23 16:28:42.725: E/AndroidRuntime(19095): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-23 16:28:42.725: E/AndroidRuntime(19095): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-23 16:28:42.725: E/AndroidRuntime(19095): at dalvik.system.NativeStart.main(Native Method)
07-23 16:28:42.725: E/AndroidRuntime(19095): Caused by: java.lang.IllegalStateException: Map size should not be 0. Most likely, layout has not yet occured for the map view.
07-23 16:28:42.725: E/AndroidRuntime(19095): at maps.as.i.b(Unknown Source)
07-23 16:28:42.725: E/AndroidRuntime(19095): at maps.ah.w.a(Unknown Source)
07-23 16:28:42.725: E/AndroidRuntime(19095): at maps.ah.s.a(Unknown Source)
07-23 16:28:42.725: E/AndroidRuntime(19095): at maps.ah.an.b(Unknown Source)
07-23 16:28:42.725: E/AndroidRuntime(19095): at bgc.onTransact(SourceFile:92)
07-23 16:28:42.725: E/AndroidRuntime(19095): at android.os.Binder.transact(Binder.java:310)
07-23 16:28:42.725: E/AndroidRuntime(19095): at com.google.android.gms.maps.internal.IGoogleMapDelegate$a$a.animateCamera(Unknown Source)
07-23 16:28:42.725: E/AndroidRuntime(19095): at com.google.android.gms.maps.GoogleMap.animateCamera(Unknown Source)
07-23 16:28:42.725: E/AndroidRuntime(19095): at ecm2.android.Fragments.EMGMap.centerOnNote(EMGMap.java:340)
07-23 16:28:42.725: E/AndroidRuntime(19095): at ecm2.android.Fragments.EMGMap.fetchMapSettings(EMGMap.java:283)
07-23 16:28:42.725: E/AndroidRuntime(19095): at ecm2.android.Fragments.EMGMap.onResume(EMGMap.java:289)
07-23 16:28:42.725: E/AndroidRuntime(19095): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:917)
07-23 16:28:42.725: E/AndroidRuntime(19095): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1080)
07-23 16:28:42.725: E/AndroidRuntime(19095): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
07-23 16:28:42.725: E/AndroidRuntime(19095): at android.support.v4.app.FragmentManagerImpl.dispatchResume(FragmentManager.java:1820)
07-23 16:28:42.725: E/AndroidRuntime(19095): at android.support.v4.app.FragmentActivity.onPostResume(FragmentActivity.java:412)
07-23 16:28:42.725: E/AndroidRuntime(19095): at android.app.Activity.performResume(Activity.java:5195)
07-23 16:28:42.725: E/AndroidRuntime(19095): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2732)
07-23 16:28:42.725: E/AndroidRuntime(19095): ... 12 more

这是我在 onResume 上的相机移动

if(map != null && northEast != null && southWest != null){
map.animateCamera(CameraUpdateFactory.newLatLngBounds(new LatLngBounds(southWest,northEast),10));
}else if(map != null && centerPoint != null){
CameraPosition position = new CameraPosition.Builder()
.target(centerPoint).zoom(17).build();
map.animateCamera(CameraUpdateFactory.newCameraPosition(position));
}

如果我去掉相机运动,它不会崩溃,但不会回到他们离开它或其他东西的点。

我检查以确保 map 不为空,所以我不知道是什么导致了错误?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com