I am starting an activity with Theme.Dialog on IncomingCall detected; however, when I start my dialog activity, it hides the Incoming Call Screen which is not the behavior I want. I want to start that dialog activity alone so that it appears on top of the incoming call screen and NOT the WHOLE application on top of the incoming call screen. I used the SingleTask in the Manifest and the NEW_TASK flag and used all sorts of Contexts. as a hint, I want to do something like TrueCaller Android App.

有帮助吗?

解决方案

You need to make sure that the activity with Dialog theme has a different task affinity than the rest of your app. Otherwise, if your app is running, launching that activity (even with FLAG_ACTIVITY_NEW_TASK) will just bring the existing task forward and put your activity on top of that.

You should add the following to the manifest for this specific activity:

android:taskAffinity=""
android:noHistory="true"
android:excludeFromRecents="true"

NOTE: Setting noHistory and excludeFromRecentsensures that this task does NOT show up in the "recent tasks list".

其他提示

use android:launchMode="singleInstance"

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top