Note that there are some explanatory texts on larger screens.

plurals
  1. POPressing Home Key triggers an error
    primarykey
    data
    text
    <p>I have created an image editing app..it consists of two activities, the main activity leads to next activity. Everything's working fine. The problem is when i press HOME key during second activity it jumps to the home screen now when i again run the application it generates an error to force close. This ain't happening when doing the same during first activity. I'm not able to find the exact problem.. Is there any way that if user presses HOME key i can kill that activity? </p> <p>below is the code of surfaceview i'm using...it's also using a thread...i think dat's where dis prblem is arising...can u pls check dis out</p> <pre><code>public DrawingSurface(Context context, AttributeSet attrs) { super(context, attrs); getHolder().addCallback(this); commandManager = new CommandManager(); da=new DrawingActivity(); thread = new DrawThread(getHolder()); } class DrawThread extends Thread{ private SurfaceHolder mSurfaceHolder; public DrawThread(SurfaceHolder surfaceHolder){ mSurfaceHolder = surfaceHolder; } public void setRunning(boolean run) { _run = run; } @Override public void run() { Canvas canvas = null; b=da.getpic(); while (_run){ try{ canvas = mSurfaceHolder.lockCanvas(null); if(mBitmap == null){ mBitmap = Bitmap.createBitmap (1, 1, Bitmap.Config.ARGB_8888);; } final Canvas c = new Canvas (mBitmap); c.drawBitmap(b, 0, 0, null); commandManager.executeAll(c); canvas.drawBitmap (mBitmap, 0, 0,null); //first block } finally { mSurfaceHolder.unlockCanvasAndPost(canvas); } } } } public void addDrawingPath (DrawingPath drawingPath){ commandManager.addCommand(drawingPath); } public boolean hasMoreRedo(){ return commandManager.hasMoreRedo(); } public void redo(){ commandManager.redo(); } public void undo(){ commandManager.undo(); } public boolean hasMoreUndo(){ return commandManager.hasMoreRedo(); } public Bitmap getBitmap(){ return mBitmap; } public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { mBitmap = Bitmap.createBitmap (width, height, Bitmap.Config.ARGB_8888); } public void surfaceCreated(SurfaceHolder holder) { thread.setRunning(true); thread.start(); } public void surfaceDestroyed(SurfaceHolder holder) { boolean retry = true; thread.setRunning(false); while (retry) { try { thread.join(); retry = false; } catch (InterruptedException e) { } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload