0

I'd like to have an options menu that includes a logout option to exit the entire app, but none of the logout(), exit(), finish() methods I've tried to incorporate do more than just exit the present activity to show the previous one.

I didn't see anything addressing this on the SOF site, so maybe I'm not approaching a logout in the best way. Optimally, it would also prompt a "Are you sure you want to exit the app" message and flush out particular SQLite data- but I'll worry about that after I get the logout part running.

Any insight?

Faysal Ahmed
  • 7,501
  • 5
  • 28
  • 50

1 Answers1

0

It's a bad practise to kill the app in your application. However if you really need to do this here is a good solution:

https://stackoverflow.com/a/44208360/6683139

Ege Kuzubasioglu
  • 5,991
  • 12
  • 49
  • 85
  • The employees using the various company smart phones will sometimes need to use somebody else's. The logout would kill that user, flush pertinent SQLite data, and allow the other user to log on. And thank you for the response. I'l tinker with it now. – Dave Higgins Jan 08 '18 at 20:24
  • ok then make sure you kill listeners etc. before you call this method, to avoid memory leaks – Ege Kuzubasioglu Jan 08 '18 at 20:29
  • https://stackoverflow.com/questions/2033914/is-quitting-an-application-frowned-upon/2034238#2034238 – Ege Kuzubasioglu Jan 08 '18 at 20:30
  • Well, that solution mostly works in that at the base level it kills the app. The added layer of an options menu, however, requires clicking on Logout once to revert back to the main layer, and then a second time to actually close the app. What you provided should set me on the correct path to see if I can kill the app from within an options menu. Thanks again. I really appreciated it. – Dave Higgins Jan 08 '18 at 20:40
  • So is it bad practice to kill an app in the way I envisioned, as it's too abrupt and might not allow processes, etc. to stop properly? Is there a more elegant solution or approach to what I'm trying to do? – Dave Higgins Jan 08 '18 at 20:52
  • In your specific use case it's abnormal to keep the app in the background after logout but as the answer suggests, let thesystem does the job of killing an application – Ege Kuzubasioglu Jan 09 '18 at 06:19