I have found the following description on Android Developers site:
As another example, the Android Browser application declares that the
web browser activity should always open in its own taskby specifying
the singleTask launch mode in the element. This means that
if your application issues an intent to open the Android Browser, its
activity is not placed in the same task as your application. Instead,
either a new task starts for the Browser or, if the Browser already
has a task running in the background, that task is brought forward to
handle the new intent.
As you can see android:launchMode=singleTask is the right choice in your case. You already mentioned that you had issues with this property so maybe let's focus on them.
Note from Google regarding singleTask launchMode:
The other modes singleTask and singleInstance are not appropriate
for most applications, since they result in an interaction model that
is likely to be unfamiliar to users and is very different from most
singleTask and singleInstance use case from Google:
As you can see singleTask may not be recommended for general use but your case is not general, actually it's one of the cases where singleTask fits perfectly.
In other words, singleTask is not forbidden, it's just need to be used with caution in order to provide end users common experience with your app.
I've tried it (put my package ID as the Affinity) but it is not working. I think because my task was not started yet, so the activity will open in the calling task.
It should be opened in new task even if your activity was not started. Can you tell how do you determine that your activity is in the same task?
Two indications: FIRST: in task manager I see only one task (the messaging task) and when clicking on it i see my activity. SECOND: running "adb shell dumpsys activity" in "Running Activities" i see one task with two activities: mms and my activity.
I've put my package name as the Affinity, is that correct?
Yes, it's fine. Did you remember to set allowTaskReparenting along with affinity? Can you also explain why do you need your activity to be in the separate task? Maybe we could come up with another solution for the initial reason.