Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set Activity dialog uncancelable

I have an activity which i am using as a dialog in my app(by making use of Theme.Dialog and startActivity(dialogactivityintent)). But I don't want it to close when the user presses the back button (which all android phones have). I've searched a lot but couldn't find a solution to this. Please help me out. Thanks in advance!

EDIT: I've tried using setCancelable(false) but in vain.

like image 980
Chinmay Dabke Avatar asked Nov 12 '13 18:11

Chinmay Dabke


1 Answers

HI use the following code::

Paste this line next to setContentView(R.layout.main)

this.setFinishOnTouchOutside(false);

and disable the back Key using the following line:

@Override
public void onBackPressed() {
}
like image 164
Sivakumar Avatar answered Nov 01 '22 06:11

Sivakumar