开发一进入程序就加载地图引起ANR 怎么办呢!! 线程地图ANR 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Activity最长执行时间是5秒,BroadcastReceiver最长执行时间则是10秒,超过了就会出现ANR你把初始化地图放在工作线程中,结束后通过handler发消息给主线程,来显示地图。 同楼上,主线程卡住5秒就会ANR的了.必须要新开线程,完成后通过handler通知主线程来更新界面. 百度地图自家的demo就有教怎么做的了,你可以去下一个,照着来修改. BMapApiDemoApp app = (BMapApiDemoApp) this.getApplication(); if (app.mBMapMan == null) { app.mBMapMan = new BMapManager(getApplication()); app.mBMapMan.init(app.mStrKey, new BMapApiDemoApp.MyGeneralListener()); } app.mBMapMan.start(); // 如果使用地图SDK,请初始化地图Activity long iTime = System.nanoTime(); super.initMapActivity(app.mBMapMan); iTime = System.nanoTime() - iTime; Log.d("MapViewDemo", "the init time is " + iTime); mMapView = (MapView) findViewById(R.id.bmapView); mMapView.setBuiltInZoomControls(true); mMapView.setDrawOverlayWhenZooming(true); GeoPoint point = new GeoPoint((int) (24.91536 * 1e6), (int) (118.6201 * 1e6)); mMapView.getController().setCenter(point); mMapView.getController().setZoom(15); // 创建点击时的弹出泡泡 mPopView = super.getLayoutInflater().inflate(R.layout.popview, null); mMapView.addView(mPopView, new MapView.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, null, MapView.LayoutParams.TOP_LEFT)); mPopView.setVisibility(View.GONE); iZoom = mMapView.getZoomLevel();我试了下还是会ANR 。 要把哪部分放在子线程呢? 为什么我放在子线程了还是一样会ANR 为什么我放在子线程了还是一样会ANR那你主线程在干什么呢?最好显示一个进度吧。 为什么我放在子线程了还是一样会ANR那你主线程在干什么呢?最好显示一个进度吧。主线程什么也没干了啊。 android不能自动启动apk android客户端使用socket连接本机进行通信 未编译源码里的项目如何导入eclipse android 游戏开发 [求教]Android GridLayout如何平均分配子View宽度 关于手机端抓取log日志 请问怎么实现如图中所示的效果 关于SQL语句的问题 路过的求助,android进程如何减小? 如何让安卓apk 在手机中自动静默更新 qq授权和空间分享 安卓如何实现这个效果
if (app.mBMapMan == null) {
app.mBMapMan = new BMapManager(getApplication());
app.mBMapMan.init(app.mStrKey,
new BMapApiDemoApp.MyGeneralListener());
}
app.mBMapMan.start();
// 如果使用地图SDK,请初始化地图Activity
long iTime = System.nanoTime();
super.initMapActivity(app.mBMapMan);
iTime = System.nanoTime() - iTime;
Log.d("MapViewDemo", "the init time is " + iTime);
mMapView = (MapView) findViewById(R.id.bmapView);
mMapView.setBuiltInZoomControls(true);
mMapView.setDrawOverlayWhenZooming(true);
GeoPoint point = new GeoPoint((int) (24.91536 * 1e6),
(int) (118.6201 * 1e6));
mMapView.getController().setCenter(point);
mMapView.getController().setZoom(15); // 创建点击时的弹出泡泡
mPopView = super.getLayoutInflater().inflate(R.layout.popview, null);
mMapView.addView(mPopView, new MapView.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, null,
MapView.LayoutParams.TOP_LEFT));
mPopView.setVisibility(View.GONE);
iZoom = mMapView.getZoomLevel();
我试了下还是会ANR 。 要把哪部分放在子线程呢?
那你主线程在干什么呢?最好显示一个进度吧。
那你主线程在干什么呢?最好显示一个进度吧。
主线程什么也没干了啊。