maryana
maryana

Reputation: 21

android singleton activity

The main activity of the app is TabActivity that contains some OneActivity

It is necessary to call from another part of app the OneActivity not creating the another instance of it, just calling onResume() of the one that lies in TabActivity

Tried set different launchMode ("singleTop", "singleTask", "singleInstance") and set flags for intent:

intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER);

How to do it not creating a new instance of activity?

Upvotes: 2

Views: 4935

Answers (1)

Arnab Chakraborty
Arnab Chakraborty

Reputation: 7472

Try the CLEAR_TOP flag. I removes all the activities above your activity in the activity stack, so it should solve your purpose.

Intent i = new Intent(context, YourSingleInstanceActivityName.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);

Upvotes: 5

Related Questions