tags:

views:

73

answers:

0

I finally got everything in my app done, but now whenever I exit it with anything except the Home button, it flashes a force close screen, and then it goes away. I know its not that big of a deal, but I really want that to stop happening, I finally got a logcat on it and it said there was no super.onStop(), so I added that, then it force closed again giving me a nullPointer,

I am closing the application by using moveTaskToBack(true), and any time I use it that is what it does, gives me a nullpointer in my onDraw method. I'm not sure what other info is needed, so let me know, thanks in advance for any help

public void onDraw(Canvas canvas){
        if(checkState == -9){
            canvas.drawColor(Color.BLACK);
            canvas.drawBitmap(bG, 0, 0, paint);
            canvas.drawBitmap(title, display.getWidth()/2 - title.getWidth()/2, 10, paint);
            canvas.drawBitmap(start, display.getWidth()/2 - start.getWidth()/2, 40 + title.getHeight(), paint);
            canvas.drawBitmap(instructions, display.getWidth()/2 - instructions.getWidth()/2, 80 + title.getHeight() + start.getHeight(), paint);
            canvas.drawBitmap(exit, display.getWidth()/2 - exit.getWidth()/2, 120 + title.getHeight() + start.getHeight() + exit.getHeight(), paint);
            canvas.drawBitmap(highScore, 0, display.getHeight() - highScore.getHeight(), paint);
            String high = highLevel + "";
            for(int i = 0; i < high.length(); i++){
                levelOnMenu = high.charAt(i) + "";
                levelPiece = Integer.parseInt(levelOnMenu);
                int placeX = highScore.getWidth() + levelNumber.getWidth()/2 ;
                if(high.length() == 1){

                }
                else if(high.length() == 2){
                    if(i == 0){

                    }
                    else{
                        placeX = placeX + levelNumber.getWidth();
                    }
                }

it is telling me that the first part of the onDraw is null, the drawColor...which doesn't make a lot of sense to me

Here is where I use moveTaskToBack()

if(checkState == -11){
            if(event.getAction() == MotionEvent.ACTION_UP){
                if(x >= display.getWidth()/2 - pauseMenu.getWidth()/2 && x <= display.getWidth()/2 + pauseMenu.getWidth()/2 && y >=  display.getHeight()/2 - pauseMenu.getHeight()/2 && y <=  display.getHeight()/2 - pauseMenu.getHeight()/2 + pauseMenu.getHeight()/3){
                    checkState = previousState;
                }
                if(x >= display.getWidth()/2 - pauseMenu.getWidth()/2 && x <= display.getWidth()/2 + pauseMenu.getWidth()/2 && y >=  display.getHeight()/2 - pauseMenu.getHeight()/2 + pauseMenu.getHeight()/3 && y <=  display.getHeight()/2 - pauseMenu.getHeight()/2 + 2*(pauseMenu.getHeight()/3)){
                    if(sound){
                        sound = false;
                    }
                    else{
                        sound = true;
                    }
                }
                if(x >= display.getWidth()/2 - pauseMenu.getWidth()/2 && x <= display.getWidth()/2 + pauseMenu.getWidth()/2 && y >=  display.getHeight()/2 - pauseMenu.getHeight()/2 + 2*(pauseMenu.getHeight()/3) && y <=  display.getHeight()/2 - pauseMenu.getHeight()/2 + pauseMenu.getHeight()){

                    moveTaskToBack(true);
                }

            }
        }