-1

I have an Activity, that launches from browser by this intent-flter:

   <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="myapp" />
            <data android:host="someaction"/>
            <data android:path="/" />
        </intent-filter>

But if i have other activities of my app not destroyed, they will appear behind launched activity. I need somehow use CLEAR_TOP flag but with intent filter. Activity's launchMode was set to singleTop and i can't use singleInstance or singleTask. So how can launch only my desirable activity and not the others?

Lester
  • 2,544
  • 4
  • 27
  • 38

1 Answers1

1

Solution 1

I'd try this with some BroadCast event. Send one from the Activity you start, and add BroadcastReceivers to the ones you'd like to close.

Check this answer, I think it should help you.

Solution 2

I would also give this a try: set you activity's intent flag as FLAG_ACTIVITY_CLEAR_TOP. Also you can consider using the following intent flags: FLAG_ACTIVITY_CLEAR_TASK FLAG_ACTIVITY_NEW_TASK

Community
  • 1
  • 1
abbath
  • 2,444
  • 4
  • 28
  • 40
  • nice solution, but with switching activities animation - previous activity is visible some time, before destroying – Lester Nov 16 '15 at 23:07
  • Try with overriding pending animations: [link](http://foobarpig.com/android-dev/how-to-disable-animation-on-startactivity-finish-and-backpressed.html) – abbath Nov 16 '15 at 23:11
  • I've updated my answer, maybe that flag could also do for you. – abbath Nov 16 '15 at 23:13
  • i can't use CLEAR_TOP flag or override pending animations cause i don't launch activity explicitly, instead i'm using intent filter and user launch my activity from browser – Lester Nov 16 '15 at 23:16
  • Create a dummy activity with intent filters only, which starts your real activity with CLEAR_TOP flag. Ovveride pending transition between the dummy and real, so no visible trace would remain after. – abbath Nov 16 '15 at 23:22
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/95287/discussion-between-lester-and-abbath). – Lester Nov 16 '15 at 23:37