Thursday, 20 March 2014

Detect back button click android

Restring the user to press the back button in android and showing the message that back button is not allowed to press.

You need to override the onBackPressed Event.

private Context ctx;
           @Override
           public void onBackPressed() {
              ctx = this;
              Toast.makeText(ctx,
                            "You are not allowed to press back button.",
                            Toast.LENGTH_LONG).show();
           }

                                              

No comments:

Post a Comment