java - how to disable back button for particular activity -



java - how to disable back button for particular activity -

i developing android app in first screen logging screen. after successful log-in home screen appears. problem when press button, goes log-in screen again. want disable button while on home screen , display alert box asking

are sure want exit

i have searched many examples didn't find perfect solution have tried using public void onbackpressed() {} method don't know implement. , min sdk version 15

can help me ton.

in activity override onbackpressed()

@override public void onbackpressed() { alertdialog diabox = askoption(); diabox.show(); } private alertdialog askoption() { alertdialog myquittingdialogbox =new alertdialog.builder(this) .settitle("exit") .setmessage("are sure want exit?") .seticon(r.drawable.delete) .setpositivebutton("yes", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int whichbutton) { finish(); } }) .setnegativebutton("no", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int which) { dialog.dismiss(); } }) .create(); homecoming myquittingdialogbox; }

java android

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -