Wednesday, 14 August 2013

Android app terminate

Android app terminate

I really need to be able to terminate the app on menu button click. My
menu works just fine, but when I try to terminate/kill the app, it just
closes the current activity and opens the previous one.
I need to be able to navigate back and forth between the activities in the
app using the back button, or the designed by me navigation buttons
In the menu, I added a button for exiting the app and inside the click
event, I entered the code
android.os.Process.killProcess(android.os.Process.myPid())
However nothing happens, I mean it's the same. Behaves like Finish(). I
need to finish all my activities when that button is clicked.
I pretty much hate the back button when entering deep in an app, and
navigating for a couple of minutes, then when you want to close the app...
without clicking Home button, it takes you almost the same amount of time
to go back through all the steps that you did before, in reverse... it's
annoying to say the least.
Plus, my app makes HTTP requests onCreate of almost every Activity, so my
app will make double internet traffic when going "back". And "YES" my app
needs to do this. I cannot cache my database locally and use it from here,
because my app will be used by multiple users simultaneously and they need
to see the updated data every time they enter an Activity
I do not want/need my app to remain open for future use. My app will
require a user+pass authentication and i need to provide the safety of
being able to close it when user wants to log-off it, so he can leave his
phone safely on the table when leaving for the toilet (it's just an
example).
I do not need a lecture about why Android wants me to not close my app...
I DO NOT CARE what Android would like me to do. It's what I would like to
do, that is more important. If my user leaves his phone unattended, anyone
can just start the app and be logged in and see whatever information my
app is storing, so NO, I do not want my app to linger on. I want it
STOPPED when the user chooses to stop it.
So please tell me how to do it? I tried adding in the manifest:
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
for every activity and then added this whenever I start an activity:
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
nothing changed... when I click the exit button, current activity finishes
and previous activity shows up. I hate this. Please tell me how to do it.
There are plenty TaskManager applications out there that let you finish
other apps, so there has to be a way to be able to finish your own app...
Thank you

No comments:

Post a Comment