I have several static and non-static variables in my app. when I terminate the app by clicking on the right button in the android control bar:
and drag the app out, the next start of the app is complately normal (as expected), but when use:
((Activity)MainDisplay.getContext()).finish();
the app is finalized (but still in RAM) and during the next start there are some UI problems (for instance, by changing the activity, the UI-elements of the first activity are still shown).
Is there any idea how to fix it?
should I maybe clear all the variables before finish()?
finish
only closes the activity you call it on, it does not terminate your app. Note that terminating your app by yourself is not usual, you should be able to deal with pausing and resuming. If you really do want to terminate your app, I think the closest you will get is System.exit(int)
. The int represents an error, 0 means the program ended OK