I am dealing with a strange issue here.
Basically, I have one application (made by another developer) that has an activity that specifies its taskAffinity to "" and its launchMode to "singleTask".
When the phone receives a notification, I launch an activity in my application with FLAG_ACTIVITY_NEW_TASK flag.
I would like my activity to have a taskAffinity for that other application if the task exists.
When I do dumpsys activity
I see that the other developers application TaskRecord is:
aj.streetPhone.app/.ViewActivity
However, in my manifest on my activity I specify aj.streetphone.app
it does not seem to add my activity to that applications task. I have tried another package name and it seems to be working. The problem perhaps has to do with the fact that the task name includes the activity, not just the package name (the default).
I am basically having a problem to use the '/' because the manifest does not accept it.
android:taskAffinity="aj.streetPhone.app/.ViewActivity" <--- does not work!
I have tried escaping the '/', added by unicode, everything. Please help!
Any ideas?
The / is indeed invalid.
Unless it's been abbreviated in some way (a quick look at
dumpsys activity
for my own app seems to show that it isn't) your activity's full name isaj.streetPhone.app.ViewActivity
. However, if you want to prepend your package name to thetaskAffinity
you can simply use a colon, e.g.:myAffinity
. That said, thetaskAffinity
is not meant to be the activity's name!As I understand it,
taskAffinity
is meant to control which "task" an activity belongs to. While I can't comment on why you'd try to stick an activity to another app's task, you may want to clear the affinity to indicate the activity can be in any task; although I haven't tried it I imagine this would result in, for example, the back button leading back to whatever activity the user was on before rather than leading back to whatever activity was last active in your app (your task).More info (which, FYI, is where chemalarrea was quoting from without giving credit): https://groups.google.com/forum/?fromgroups=#!topic/android-developers/wKwnV1k_96A
Documentation: https://developer.android.com/guide/topics/manifest/activity-element.html#aff