我准备了一款涂鸦应用程序,这个应用程序包含一个自定义绘图视图。当我们在自定义视图中绘制任何东西时,只需收集所绘制的像素并存储在ArrayList中,第一次它可以正常工作(但需要很长时间),第二次会出现“Activity MyAlphabets(在应用程序MyAlphabets中)未响应(强制关闭和等待)”的问题。
我的代码如下:
当我们点击“强制关闭”时,Logcat会显示:
我的代码如下:
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, 0, 220, 0, 0, 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
在绘制时收集颜色像素的正确方式是使用以下方法。请帮助我……
如何解决这个问题。请帮助我……