1.5.12

How To Add an Action to the Exit Button in Android

From the Google developers, button exit is not necessary, because the Android itself can manage to kill the app while it no longer in use. To close the application, just hit the back button, and the rest, may the  Android System manage the the app life cycle.
But if you need to put the Button Exit in android App, the syntax is so simple, take a look at the code below:

  // 6. Event for Exit
  btn_exitt.setOnClickListener(new View.OnClickListener() {

   @Override
   public void onClick(View v) {
    // TODO Auto-generated method stub
     finish();
     System.exit(0);
   }
  }
I hope the short code above can help you.. :)
Share:

0 comments :

Post a Comment

Mari komentar dan berdiskusi...