Domanda

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 !!

È stato utile?

Soluzione

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.

Altri suggerimenti

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); .

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top