
Activity MyAlphabets(在应用程序MyAlphabets中)没有响应(强制关闭并等待)“.
我的代码是,
public voID onDraw(Canvas canvas) { if (myDrawBitmap == null) { myDrawBitmap = Bitmap.createBitmap(canvas.getWIDth(),canvas.getHeight(),Bitmap.Config.ARGB_8888); bmpDrawCanvas = new Canvas(myDrawBitmap); intDrawArray = new int[myDrawBitmap.getWIDth() * myDrawBitmap.getHeight()]; } if (bmpDrawCanvas != null) { for (Path path : MyActivity.mArryLstPath) { bmpDrawCanvas.drawPath(MyActivity.mPath,mPaintAlphabet); }myDrawBitmap.getPixels(intDrawArray,220,305); for (int i = 0; i < intDrawArray.length; i ++) { if (intDrawArray[i] == 0xFFFFFFFF) { if (MyActivity.mArryLstDrawnPixels.contains(i)) { } else { MyActivity.mArryLstDrawnPixels.add(i); } }} 当我们点击“强制关闭”时Logcat是,
INFO/ActivityManager(52): Killing process com.qteq.myapplication (pID=225) at user's request INFO/Process(52): Sending signal. PID: 225 SIG: 9 INFO/ActivityManager(52): Process com.qteq.myapplication (pID 225) has dIEd. INFO/WindowManager(52): WIN DEATH: Window{608fbd10 com.qtq.myapplication/com.qtq.myapplication.MyApplicationActivity paused=false} INFO/UsageStats(52): Unexpected resume of com.androID.launcher while already resumed in com.qtq.myapplication ERROR/gralloc(52): [unregister] handle 0x4a2740 still locked (state=40000001) WARN/inputManagerService(52): Got remoteexception sending setActive(false) notification to pID 225 uID 10025 这是在抽奖时收集彩色像素的正确方法.请帮帮我..
如何解决这个问题呢.请帮我..
解决方法 您的应用程序必然会因为您正在进行所有计算而获得“应用程序无响应”错误,包括在UI线程(onDraw)中进行分配.首先,您应该尝试将计算移动到非ui线程中(参见AsyncTask).任何超过20毫秒的 *** 作都必须调用“应用程序未响应”消息.
其次,您应该尝试重构代码,这样您每次必须绘制时都不必执行计算.基本上渲染图像是一个屏幕外的位图,缓存它并从onDraw中的缓存副本渲染它.我担心,“如何”的范围超出了本次讨论的范围.
总结以上是内存溢出为你收集整理的android – 如何修复应用程序没有响应?全部内容,希望文章能够帮你解决android – 如何修复应用程序没有响应?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)