Adding an Exit button to Android Application

So what is the right way of closing the application!

Usually it is "USER! press back ! press back! keep pressing back! we are close!! okay finally bye"


Here is a small idea i had on adding an Exit button to application.


In my personal opinion, even android users will find a Close button nice and friendly.




public class ExitNotifier {
    
     public ExitNotifier getInstance() {
      if(instance==null)
       instance = new ExitNotifier();
      return instance;
     }
     public boolean isExitting() {
      return exit;
     }
     public void doExit(boolean exit) {
      this.exit = exit;
     }
     private static ExitNotifier instance;
     
     boolean exit;
     private ExitNotifier() {
      exit = false;
     }
     
    }


Whenever the exit button is pressed, do the following

ExitNotifier.getInstance().doExit(true);
finish();


In all activities, in your onActivityResult function add the following line:

if(ExitNotifier.getInstance().isExitting())
    finish();


The only requirement for this is to always use startActivityForResult when starting new Activities.
If you want to eliminate this requirement, just add the code you added to the onActivityResult to your onResume of all your activities.

Enjoy! I like it!!

19 comments:

  1. Usually it is "USER! press back ! press back! keep pressing back! we are close!! okay finally bye" Cell Phone Tracker Location

    ReplyDelete
  2. The asset tracking capabilities of a great helpdesk program, should allow for the software to be remotely loaded from the network onto client PCs. This way it should be able to track their operating system, hardware details, and software details. driver toolkit serial

    ReplyDelete
  3. The open source nature of Android has opened extensive portal for mobile app development and shaking hands with OHA (Open handset Alliance), more than 80 companies are changing the world continuously, with rapid advancements in the OS.
    http://www.showboxdownloadsapp.com/

    ReplyDelete

  4. If you face any kind of trouble during movies downloading and you want to see latest movies in HD format then you need an app like Showbox.
    Nowadays this app is getting much popular because of its attractive and trendy
    ShowBox for Windows

    ReplyDelete
  5. Apps not only ensure to enhance business productivity, but can also help businesses to publicize their brand to a wider market segment.
    click here

    ReplyDelete
  6. The open source nature of Android has opened extensive portal for mobile app development and shaking hands with OHA (Open handset Alliance), more than 80 companies are changing the world continuously, with rapid advancements in the OS.
    Lucky Patcher
    0xc0000142

    ReplyDelete
  7. OK thanks for this post it's quite informative and I have learned new things.
    hotmail signup process
    kissanime alternatives

    ReplyDelete
  8. Use dual account with Gbwhatsapp Apk Latest Application With free of cost.

    ReplyDelete
  9. Watch more than 900 channels using Live NetTv App on your Smart phone devices.

    ReplyDelete
  10. The asset tracking capabilities of a great helpdesk program, should allow for the software to be remotely loaded from the network onto client PCs. This way it should be able to track their operating system, hardware details, and software details https://whatsopp.net/download-gbwhatsapp-apk-latest-version/

    ReplyDelete
  11. The asset tracking capabilities of a great helpdesk program, should allow for the software to be remotely loaded from the network onto client PCs. This way it should be able to track their operating system, hardware details, and software detailslucky patcher lucky patcher apk download

    ReplyDelete
  12. Really, this article is truly one of the best in the history of the article. I am an antique 'Article' collector and sometimes I read some new articles if I find it interesting. And I found this quite interesting and had to go into my collection.
    Very good job!
    agen domino99
    daftar idpro poker
    88dewa
    aktifqq
    armaniqq
    aslibandar
    aslidomino
    bandarkiu
    bandarq168
    bandarqq

    ReplyDelete
  13. Hey! I just wanna say that you are sharing a quality and useful content with us. This kind of content is difficult to find it and you are sharing FMWhatsApp is very good. Keep up the high work.

    ReplyDelete
  14. This was very helpful me for the project. Thanks for sharing this with me.

    ReplyDelete
  15. Very nice article on this topic. I would like to see more such awesome articles from you.
    FMWhatsApp

    ReplyDelete
  16. Excellent Content. I enjoy how you present. Continue to impart more information.

    ReplyDelete