android - Disable Back Button (onBackPressed) -


I want to disable the back button after closing the app (sorry, my english is bad)

< P> How do I disable the back button?

You can override the method and determine what happens in that method. By this way:

  Override public null at @BackPressed () {// nothing because you do not want to leave them when you press it}  
< P> Just add that method to your activity class and you are good to go.

However, this is a bad app design. What you most likely want is a dialogue pop up that asks them whether they want to leave that you will add a dialogue code inside that method , So that when the back button is pressed, the dialog will pop up.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -