Is there a way to capture back button twice in same activity libgdx game

| | August 6, 2015

Can anybody tell me if there is a possibility to capture back button twice in same activity in libgdx.
What i want to achieve is that if the user press back button once the game pause. if in the pause screen user press back key again so the level exit. This happens well in “Video” that is the built in app in android OS. During video play a if user press back button it toast to press back again to exit.

so I want somthing like this.

if (Gdx.input.isKeyPressed(Keys.BACK)) {

        code to call game pause  state


  if (Gdx.input.isKeyPressed(Keys.BACK)){   //// is this possible? 

  game.setScreen(new Menu(game))


 }

    } else {
        code to call game resume state
    }

Leave a Reply