I got curious too, and went looking for it in the Android source code.
I found what seems to be the relevant code at the platform/frameworks/base
repository, in the tools/aapt/Resource.cpp
file. The relevant function is fullyQualifyClassName
, called by massageManifest
.
The rule it applies is explained in a comment block within the fullyQualifyClassName
function:
// asdf --> package.asdf
// .asdf .a.b --> package.asdf package.a.b
// asdf.adsf --> asdf.asdf
Explaining this rule, we have:
- If the name starts with a dot, always prefix it with the package.
- If the name has a dot anywhere else, do not prefix it.
- If the name has no dot at all, also prefix it with the package.
So, to answer your question: as long as there is no dot anywhere else, both ways of writing the activity name should have the same effect.
As an extra, the massageManifest
function shows where this rule is applied:
- In the
application
element, on the name
and backupAgent
attributes.
- In the
activity
, service
, receiver
, provider
, and activity-alias
elements, on the name
attribute.
- In the
activity-alias
element, on the targetActivity
attribute.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…