V
V
Vacxe2012-09-26 14:51:17
Android
Vacxe, 2012-09-26 14:51:17

Checking called activity?

Own code

...
Intent intent;
...
case (8):
      // Избранное
      intent = new Intent(getApplicationContext(), FavoriteActivity.class);
      break;
    case (9):
      // Корзина
      intent = new Intent(getApplicationContext(), CartActivity.class);
      break;
    case (12):
      // О приложении			
      intent = new Intent(getApplicationContext(), SupportActivity.class);
      break;
    default:
      break;
    }
    if (intent != null) {
      startActivity(intent);
                }

This menu is described in the parent class for all activities where it is used.
And the question is how to forbid calling an activity if it is already running, so as not to add it to the stack of running activities endlessly. Tried adding if(getApplicationContext().getClass().equals(x.class)) condition but didn't help. Maybe he didn't add some premishens?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
LeoCcoder, 2012-09-26
@Vacxe

1. manually monitoring the stack of activities yourself is not good
2. killing an activity before switching to another one. For example: opened About the application, sent an intent to a new activity, killed About the application
3. read about the flags for launching the activity, you can make the About application always have one in the stack. Not all flags are available in all versions of android.
Do you really need activations? It is possible to work with fragments or pages within one activity ... then other mechanisms will work there.

D
debugger88, 2012-09-26
@debugger88

And what are you checking against getApplicationContext()? You need at least a design
if(this instanceof ClassName)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question