I have 3 activities let's say MainActivity, Activity 2, and Activity 3.
In the MainActivity I have a button (start/stop) when I click on this button an animation start but when I go to activity 2 or activity 3 and I comeback to MainActivity the animation stopped by itself.
But me I want that the animation of the MainActivity never stop until I click the button stop.
I tried this code in AndroidManifest.xml but it doesn't work.
android:launchMode="singleInstance"
If you go back from MainActivity
then your Activity will be Destroyed if you do not fire an Intent
in onbackPressed()
regardless of launchMode
. launchMode
are instruction for how the activity should be launched. On stack pop it will destroy anyway. Read launchModes .
Solution:- Solution to your problem SharedPreference
. Save the current state of animation and restart it with previous state when Activity
relaunched.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.