I want to implement voice actions, "start running" and "stop running".
"Start running" works fine, but "stop running" doesn't work.
My app has one activity with several fragments. When I speak "stop running", the activity is destroyed and created. My workout data is lost.
- setRetainInstance(true) has no effect.
- Change launchMode to singleTask/singleTop/singleInstance has no effect.
- I saved workout data in onSaveInstanceState(), but it's lost when a new activity is created.
Is there any other way?
I'm not sure if this is too obvious, but have you considered using SharedPreferences?
To save data:
To get data:
You can also save data in arrays and store it in the SharePreferences.
If this is too simple for you, you can grab a mySQL database, which is much more robust.