我得到一个IllegalStateException:恢复异常的下溢,这导致我的应用程序崩溃.
这开始发生在 Android 4.3更新之后.在android 3.0 – 4.2.x它工作正常.
这开始发生在 Android 4.3更新之后.在android 3.0 – 4.2.x它工作正常.
第二个例外发生
canvas.restore();
以下是我的图纸代码
private void doDraw(Canvas canvas) { if(mTickerBackGround!=null && (!mTickerBackGround.isRecycled())){ canvas.drawBitmap(mTickerBackGround,null); } if((mBitMapBuffer!=null)){ canvas.save(); canvas.translate(mX,0); if(!mBitMapBuffer.isRecycled()){ canvas.drawBitmap(mBitMapBuffer,null); } canvas.restore(); if(bitMapWidth+mX<mCanvasWidth){ canvas.translate(bitMapWidth+mX,0); if(!mBitMapBuffer.isRecycled()){ canvas.drawBitmap(mBitMapBuffer,null); } canvas.restore(); } if(bitMapWidth+mX<=0){ mX = 0; }else if(Math.abs(mX)>(bitMapWidth)){ mX= mCanvasWidth; } mX-=TickerConstants.SCROLLING_SMOOTHNESS*density;; } if(mlogo!=null && (!mlogo.isRecycled())){ canvas.drawBitmap(mlogo,mCanvasWidth-(60*density),mlogo.getHeight()/6,null); } }
我的问题是
生成的堆栈跟踪消息是.第165行对应于第二个canvas.restore()
08-13 18:13:09.083: E/AndroidRuntime(14139): FATAL EXCEPTION:
Thread-506 08-13 18:13:09.083: E/AndroidRuntime(14139):
java.lang.IllegalStateException: Underflow in restore 08-13
18:13:09.083: E/AndroidRuntime(14139): at
android.graphics.Canvas.restore(Native Method) 08-13 18:13:09.083:
E/AndroidRuntime(14139): at
com.my.package.name.ticker.TickerSurfaceView$TickerThread.doDraw(TickerSurfaceView.java:165)
08-13 18:13:09.083: E/AndroidRuntime(14139): at
com.my.package.name.ticker.TickerSurfaceView$TickerThread.run(TickerSurfaceView.java:128)