-2

I want to disable back button. I know that I can do it via onBackPressed(). But I want disable thi button for a while time (20 second). Help me please, how I do it?

Ertt Ertt
  • 45
  • 5
  • If you know the method that you need to override, what is the question then?? just check for a timer or something – Has AlTaiar Jun 20 '13 at 11:51

3 Answers3

1

In onCreate catch starting time and save it. Then inside onBackPressed check current time against that time.

here is how you can get time Get current time and date on Android

here is how onBackPressed would look like more less

if((startTime - currentTime) < 20min)
   return;
else
   super.onBackPressed()
Community
  • 1
  • 1
AndroidGecko
  • 14,034
  • 3
  • 35
  • 49
1
@Override
public void onBackPressed() {

        handler.postDelayed(new Runnable() {
                public void run() {
                super.onbackpressed();
        }
   }, 20000); 
}
Huzi
  • 130
  • 6
0

just use

@Override
    public void onBackPressed() {
        // TODO Auto-generated method stub

    }

just remover super method like above

abhi
  • 759
  • 6
  • 15