Question

I have an android activity with Theme=Theme.Transluscent.NoTitleBar.

I want to use finish this kind of activity using finish() but it doesnt work. As it is an invisible activity it goes to onPause State rather than onDestroy state.

How can I overcome this problem as it uses unnecessary memory.

Thank YOU !!

Was it helpful?

Solution

There are many threads which explain this. When you are calling finish(), Android will let your code in the specific block after the finish() call execute, and that is why the Toast message appears. A simple return statement after the finish() call is the solution. Taken from answer on question:

Android Help! I want to completely finish my activity, and after activity.finish no further code will execute?

Other relevant ones are:

Calling finish() on an Android activity doesn't actually finish

about finish() in android

Hope this helps.

OTHER TIPS

you can use System.exit(0); but as stated it is not a good approach. but however you can use this approach to clear the previous activity intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top