Use a leading :.

Activity names are *very* different that affinities.  Activity (and service,
receiver) names are within the namespace of only that package.  That is, the
official name of an Activity is a ComponentName which is both a package name
and the class name.  Thus two applications can have activities with the same
class name and will not conflict in any way.

Task affinities (and permissions, and processes, and shared user IDs, and
actions, etc etc) are NOT qualified by the app package name.  They are a
single string, much must be globally unique.  Just adding a ".foo" does not
make it unique because another app could have a package name that is a
shorter or longer version of your own and also come up with the same name.
 So for affinities and processes, you can use a ":" prefix in the name to
append it to your own package name and create a name that is guaranteed
unique for your package.

On Mon, May 16, 2011 at 6:49 PM, Eric <[email protected]> wrote:

> When you name an Activity, you are allowed to start the name with a
> leading "." which causes the name to inherit the Application package.
> So, when you define taskAffinity names, can you do the same thing,
> i.e.
>
> android:taskAffinity=".activities.MyAffinity"
>
> so that the full name is:
> com.mycompany.android.myapp.activities.MyAffinity, (assuming main app
> package name is "om.mycompany.android.myapp.")?
>
> I've seen other posts where people define affinity names like this,
> with a leading colon:
>
> android:taskAffinity=":MyAffinity"
>
> Task affinity names are global across the phone, so I'd like to know
> the proper way to define them.
>
> I assume defining a fully explicit affinity name would be the safest?
> i.e.
>
> android:taskAffinity="com.mycompany.android.myapp.activities.MyAffinity"
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to