java - How to open activity from widget like this: if app is not open, open main activity too but if app is open, just open on top of the current activity? -


basically want user able hit , reach main activity @ point. here 2 senarios:

  1. if app open, widget launch app , start activity on top of it.
  2. if app not open, want main activity present in stack.

is possible? think senario 2 code right:

intent mainactivityintent = new intent(context, mainactivity.class); mainactivityintent.setflags(intent.flag_activity_new_task | intent.flag_activity_clear_task); //this starts app fresh (i.e. clears current activities)  intent addcruisesintent = new intent(context, secondactivity.class); addcruisesintent.setflags(intent.flag_activity_new_task ); //this starts app fresh (i.e. clears current activities)  intent[] intents={mainactivityintent,addcruisesintent}; intent[] intents={addcruisesintent};  pendingintent pendingintent = pendingintent.getactivities(context, 0, intents, 0); 

i wondering if there flag or combination of flags can achieve want.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -