为什么使用“$”而不是“.”?
Why use '$' instead of '.'?
在我的AndroidManifest.xml中,我在下面的行代码中有一个警告。
<service android:name=".Helper.LocationService"/>
警告是:
Inner classes should use $ rather than . When you reference an inner
class in a manifest file, you must use '$' instead of '.' as the
separator character, i.e. Outer$Inner instead of Outer.Inner.
所以,如果我使用“.”,为什么要使用“$”而不是“.”?还能用吗?
建议使用$
以免外层class名称与包名称混淆。所以 $
当你想引用一个 InnerClass
和 .
时引用包。
例如,如果 Helper
是包名,那么(包名建议小写):
<service android:name=".helper.LocationService"/>
where if Helper
is a class and LocationService
is an inner class defined inside Helper
<service android:name=".Helper$LocationService"/>
在我的AndroidManifest.xml中,我在下面的行代码中有一个警告。
<service android:name=".Helper.LocationService"/>
警告是:
Inner classes should use $ rather than . When you reference an inner class in a manifest file, you must use '$' instead of '.' as the separator character, i.e. Outer$Inner instead of Outer.Inner.
所以,如果我使用“.”,为什么要使用“$”而不是“.”?还能用吗?
建议使用$
以免外层class名称与包名称混淆。所以 $
当你想引用一个 InnerClass
和 .
时引用包。
例如,如果 Helper
是包名,那么(包名建议小写):
<service android:name=".helper.LocationService"/>
where if Helper
is a class and LocationService
is an inner class defined inside Helper
<service android:name=".Helper$LocationService"/>