0

There're two activities in my app: A and B. A is opened in a usual way (from launcher). B is opened from widget. Also B has "dialog" theme, so I can see what's under it.

When app isn't runned and I open B from widget, everything is correct and I see launcher under B.

When app is runned and I open B from widget, I see A under it. But I need launcher to be under B, not A. How to get this?

UPDATE 1

Here's what I get (when I click the widget)

enter image description here

And here's what I need

enter image description here

kandi
  • 1,098
  • 2
  • 12
  • 24

3 Answers3

0

you probably want to launch this activity with the following flags:

FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_NO_HISTORY

so on your widget intent you add them as normal:

intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
                Intent.FLAG_ACTIVITY_NO_HISTORY);
Budius
  • 39,391
  • 16
  • 102
  • 144
0

Try to build your PendingIntent using TaskStackBuilder from the support library.

Alternatively, add these flags to your Intent:

Intent.FLAG_ACTIVITY_NEW_TASK |
            Intent.FLAG_ACTIVITY_CLEAR_TASK |
            Intent.FLAG_ACTIVITY_TASK_ON_HOME
BladeCoder
  • 12,779
  • 3
  • 59
  • 51
0

My solution.

  1. Use this
  2. Finish the A (I've static field in A which stores its instance. So I just use a.finish())
  3. simply startActivity() (don't forget about Intent.FLAG_ACTIVITY_NEW_TASK)
Community
  • 1
  • 1
kandi
  • 1,098
  • 2
  • 12
  • 24