System equivalent in Android?
I know this call shouldn't be made, but for now it's the only thing that stops working quickly enough.
Basically, after returning the application from the background (or using the End DDMS Application button), some static variables are null. I would like to restart the activity to stop the crashes and so all values ββare updated.
For now, System.exit (0) has done what I want, but I know it is not good.
I tried finish()
it but it doesn't stop the action fast enough, it keeps on executing some instructions which still crashes.
Any suggestions on how to manage this issue.
source to share
Only in android api 21> you can use>
getActivity().finishAndRemoveTask();
Ends all activities in this task and removes them from the recent task list.
It stops the application as quickly as System.exit (0). But is it better System.exit(0)
? I dont know...
- EDIT -
In this question enter link description here you can see all kinds of ways to stop your application.
source to share
As per the docs for Activity.finish () :
Call this when your activity is finished and needs to be closed. ActivityResult is propagated to those who launched you via onActivityResult ().
When you call System.exit (), you are effectively shutting down the JVM; by shutting down, you are allowing the Android JVM to do its cleanup.
source to share