将什么作为 launcher:ClassName 放入启动器收藏夹
What to put as launcher:ClassName for launcher favorite
我的客户想将我开发的应用程序放入他们的启动器收藏夹中,他们要求提供程序包名称和启动器的 class 名称。
包名称非常简单,但 ClassName 不是,因为如果我查看清单,class 名称前面有一个散列,如下所示:md599e473470f20dc18f556aff51bcfbcb1.LaunchScreen
那么我必须为启动器收藏夹使用的 class 名称是什么,整个东西还是只有 class 名称 LaunchScreen?
谢谢
(恭喜您进入他们的收藏夹,如果您提供播放 link ;-)
如您所说,包名很简单,它是在清单中定义为 manifest
元素的 package
属性:
<manifest .... package="com.sushihangover.playscriptstarling2" ...>
启动器 class 名称是在 Activity
C# class 属性中标记的 class,"MainLauncher = true"
反过来,这会在清单中创建 activity
属性片段:
<activity android:icon="@mipmap/icon" android:label="PlayScriptStarling2" android:name="md5d2519388ea1895e3e3594794d2e0c4ce.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
您的 class 名称是完整的 android:name
属性,因为它不以句点开头。这是生成的唯一子 class 标识符,因此在我的示例中这是完整的 class 名称:
md5d2519388ea1895e3e3594794d2e0c4ce.MainActivity
虽然大多数人永远不会看到这个 class ID,但我 强烈 建议您覆盖这个生成的 class 标识符并使用点 class 包含您的包名称的符号。
通常,这是通过使用以句点开头的 android:name
提供的名称来完成的(这是标准的 Android class 命名 101 ;-),但 Xamarin 目前 不 支持 Android shorthand-style class 以点开头的名称,因此您需要使用带有 class ID 的完全限定包名称名字.
所以 Main Activity 属性变为:
[Activity(Label = "PlayScriptStarling2", Name = "com.sushihangover.playscriptstarling2.MyBigBadGameEveryOneShouldPlay", MainLauncher = true, Icon = "@mipmap/icon")]
生成的清单变为:
<activity android:icon="@mipmap/icon" android:label="PlayScriptStarling2" android:name="com.sushihangover.playscriptstarling2.MyBigBadGameEveryOneShouldPlay">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
我的启动器 class 名称变为:
com.sushihangover.playscriptstarling2.MyBigBadGameEveryOneShouldPlay
Android 文档:
Declaring class names
Many elements correspond to Java objects, including elements for the application itself (the element) and its principal components — activities (), services (), broadcast receivers (), and content providers ().
If you define a subclass, as you almost always would for the component classes (Activity, Service, BroadcastReceiver, and ContentProvider), the subclass is declared through a name attribute. The name must include the full package designation. For example, an Service subclass might be declared as follows:
<manifest . . . >
<application . . . >
<service android:name="com.example.project.SecretService" . . . >
. . .
</service>
. . .
</application>
</manifest>
However, as a shorthand, if the first character of the string is a period, the string is appended to the application's package name (as specified by the element's package attribute).
下面的赋值和上面的一样:
<manifest package="com.example.project" . . . >
<application . . . >
<service android:name=".SecretService" . . . >
. . .
</service>
. . .
</application>
</manifest>
When starting a component, Android creates an instance of the named subclass. If a subclass isn't specified, it creates an instance of the base class.
参考:http://developer.android.com/guide/topics/manifest/manifest-intro.html
我的客户想将我开发的应用程序放入他们的启动器收藏夹中,他们要求提供程序包名称和启动器的 class 名称。 包名称非常简单,但 ClassName 不是,因为如果我查看清单,class 名称前面有一个散列,如下所示:md599e473470f20dc18f556aff51bcfbcb1.LaunchScreen
那么我必须为启动器收藏夹使用的 class 名称是什么,整个东西还是只有 class 名称 LaunchScreen?
谢谢
(恭喜您进入他们的收藏夹,如果您提供播放 link ;-)
如您所说,包名很简单,它是在清单中定义为 manifest
元素的 package
属性:
<manifest .... package="com.sushihangover.playscriptstarling2" ...>
启动器 class 名称是在 Activity
C# class 属性中标记的 class,"MainLauncher = true"
反过来,这会在清单中创建 activity
属性片段:
<activity android:icon="@mipmap/icon" android:label="PlayScriptStarling2" android:name="md5d2519388ea1895e3e3594794d2e0c4ce.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
您的 class 名称是完整的 android:name
属性,因为它不以句点开头。这是生成的唯一子 class 标识符,因此在我的示例中这是完整的 class 名称:
md5d2519388ea1895e3e3594794d2e0c4ce.MainActivity
虽然大多数人永远不会看到这个 class ID,但我 强烈 建议您覆盖这个生成的 class 标识符并使用点 class 包含您的包名称的符号。
通常,这是通过使用以句点开头的 android:name
提供的名称来完成的(这是标准的 Android class 命名 101 ;-),但 Xamarin 目前 不 支持 Android shorthand-style class 以点开头的名称,因此您需要使用带有 class ID 的完全限定包名称名字.
所以 Main Activity 属性变为:
[Activity(Label = "PlayScriptStarling2", Name = "com.sushihangover.playscriptstarling2.MyBigBadGameEveryOneShouldPlay", MainLauncher = true, Icon = "@mipmap/icon")]
生成的清单变为:
<activity android:icon="@mipmap/icon" android:label="PlayScriptStarling2" android:name="com.sushihangover.playscriptstarling2.MyBigBadGameEveryOneShouldPlay">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
我的启动器 class 名称变为:
com.sushihangover.playscriptstarling2.MyBigBadGameEveryOneShouldPlay
Android 文档:
Declaring class names
Many elements correspond to Java objects, including elements for the application itself (the element) and its principal components — activities (), services (), broadcast receivers (), and content providers ().
If you define a subclass, as you almost always would for the component classes (Activity, Service, BroadcastReceiver, and ContentProvider), the subclass is declared through a name attribute. The name must include the full package designation. For example, an Service subclass might be declared as follows:
<manifest . . . >
<application . . . >
<service android:name="com.example.project.SecretService" . . . >
. . .
</service>
. . .
</application>
</manifest>
However, as a shorthand, if the first character of the string is a period, the string is appended to the application's package name (as specified by the element's package attribute).
下面的赋值和上面的一样:
<manifest package="com.example.project" . . . >
<application . . . >
<service android:name=".SecretService" . . . >
. . .
</service>
. . .
</application>
</manifest>
When starting a component, Android creates an instance of the named subclass. If a subclass isn't specified, it creates an instance of the base class.
参考:http://developer.android.com/guide/topics/manifest/manifest-intro.html