mardi 19 mai 2015

How to reopen a very same activity / how to keep an activity alive?

I have a main activity and there I start a new activity

Intent intent = new Intent(MainActivity.this, SecondActivity.class);
startActivity(intent);

To go back to the main activity I used the finish() method.

My question is: How is it possible to switch to the very same second Activity without starting a new one? I thougt the finish() method kills the second Activity, but it still works how the code is telling him (timer counts down and a sound appears) in the background . So is it possible to just switch back to the second Activity on Screen?

In the past I had used a TabWidget which works also with activities, so it it must be possible in some way!? Or do I have to use Fragments? But if I use Fragments I have the same question: How to keep the Fragment alive till I have to use it again?

I hope you can help me with this, that would be great. I would be very thankful.

Aucun commentaire:

Enregistrer un commentaire