aMap.animateCamera不起作用,捕获异常Handler sending message to a Handler on a dead thread
来源:互联网 发布:什么行业招数据分析 编辑:程序博客网 时间:2024/04/28 18:31
问题:aMap.animateCamera不起作用,捕获异常Handler sending message to a Handler on a dead thread;
原因:
地图布局的复用造成的,去掉地图布局的复用就行了。
onCreateView中复用造成的问题:
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (mapLayout == null) { mapLayout = inflater.inflate(R.layout.fragment_home_map, null); mapView = (TextureMapView) mapLayout.findViewById(R.id.mv_home_map_map); mapView.onCreate(savedInstanceState); aMap = mapView.getMap(); } else { if (mapLayout.getParent() != null) { ((ViewGroup) mapLayout.getParent()).removeView(mapLayout); } if (mapView == null) { mapView = (TextureMapView) mapLayout.findViewById(R.id.mv_home_map_map); } mapView.onCreate(savedInstanceState); if (aMap == null){ aMap = mapView.getMap(); } } }
解决方案代码,不复用布局:
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mapLayout = inflater.inflate(R.layout.fragment_home_map, null); mapView = (TextureMapView) mapLayout.findViewById(R.id.mv_home_map_map); mapView.onCreate(savedInstanceState); aMap = mapView.getMap(); return mapLayout; }
布局复用导致的问题,定位成功后,更新当前中心点会出现的异常:
aMap.animateCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition( new LatLng(latitude, longitude),//新的中心点坐标 18, //新的缩放级别 30, //俯仰角0°~45°(垂直与地图时为0) 0 ////偏航角 0~360° (正北方为0) )));
1 0
- aMap.animateCamera不起作用,捕获异常Handler sending message to a Handler on a dead thread
- java.lang.RuntimeException: Handler{405c1180} sending message to a Handler on a dead thread
- 使用AsyncTask引发RuntimeException:sending message to a Handler on a dead thread
- 缩略信息是: sending message to a Handler on a dead thread 我是用IntentService时报的
- java.lang.RuntimeException: Handler (com.***.behavior.BEvent$1) {421bca80} sending message to a Hand
- Handler — Send message to worker thread from main thread
- Handler、Message、MessageQueue、 Looper、Handler Thread
- 发送消息(Sending a Message)
- Thread,looper,handler,message相关
- Thread、Looper、Handler和Message
- Thread、Handler、Looper以及Message
- Thread、Looper、Handler和Message
- Handler, Thread, Looper, Message,一图胜千言
- android thread Handler 、Looper、 Message、 Message Queue
- A good document about android thread, Handler, Asyntask
- Thread、Looper、Handler和Message 解开迷惑
- Thread、Looper、Handler和Message 解开迷惑
- Thread和Looper以及Handler和Message
- SAP script 实用技巧之批量注释、多语言粘贴
- android 通过 sharedpreferences 来缓存数据 到xml文件中去 Utils 的创建
- ubuntu14.04下使用A3E生成satg配置
- 线与面
- MATLAB数据类型和变量示例
- aMap.animateCamera不起作用,捕获异常Handler sending message to a Handler on a dead thread
- c++函数指针2.0
- java中synchronized与static synchronized 的区别
- APUE笔记—C语言标准IO库之文件IO
- 恢复和去除时间(Recovery and Removal Time)
- Atitit. Atiposter 发帖机 新特性 poster new feature v7 q39
- 块级元素与行内元素
- Android学习好资料网址
- thinkphp5.0整合七牛云