作为启动器放置什么:启动器收藏夹的ClassName [英] What to put as launcher:ClassName for launcher favorite

查看:95
本文介绍了作为启动器放置什么:启动器收藏夹的ClassName的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的客户希望将我开发的应用程序放在启动器的最爱中,他们要求启动器的程序包名称和类名. 包名称非常简单,但ClassName却不是,因为如果我查看清单,该类名称的开头是这样的哈希:md599e473470f20dc18f556aff51bcfbcb1.LaunchScreen

My client wants to put the app I developed to be in their launcher favorite and they are asking for the package name and class name of the launcher. Package name is quite straightforward, but ClassName isn't since if I look into the manifest the class name is preceeded by a hash like this: md599e473470f20dc18f556aff51bcfbcb1.LaunchScreen

那么我最喜欢启动器使用的类名是什么,整件事还是仅使用类名LaunchScreen?

So what is the class name I have to use for launcher favorite, the whole thing or only the class name LaunchScreen?

谢谢

推荐答案

(祝贺您加入他们的收藏夹,如果您提供了Play链接;-)

(Congrats on getting into their favorites, should you provide a Play link ;-)

您说过,包名称很简单,它是在清单中定义为manifest元素的package属性:

As you say, the package name is easy, it is the defined in the manifest as a package attribute of the manifest element:

<manifest .... package="com.sushihangover.playscriptstarling2" ...>

启动器类名称是在Activity C#类属性中标记的类,即" MainLauncher = true"

The launcher class name is the class that is tagged within the Activity C# class attribute, "MainLauncher = true"

反过来,这会在清单中创建activity属性片段:

In turn, this creates the activity attribute fragment within the manifest:

<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>

您的班级名称是完整的android:name属性,因为它不是以句点开头.这是一个生成的唯一子类标识符,因此在我的示例中,这是完整的类名:

Your class name is the full android:name attribute since it does NOT begin with a period. This is a generated unique subclass identifier, thus in my example this is the full class name:

md5d2519388ea1895e3e3594794d2e0c4ce.MainActivity

虽然大多数人永远不会看到此类ID,但我高度建议您覆盖此生成类标识符,并使用包含您的软件包名称的点类表示法.

While most people will never see this class ID, I highly recommend you override this generate class identifier and use the dot class notation that includes your package name.

通常,这是通过使用android:name提供一个带有句号的BEGINS名称来完成的(这是标准的Android类名称101 ;-),但是Xamarin当前不支持Android速记样式类名以点号开头,因此您需要使用完全合格的程序包名称和类ID名称.

Normally, this is done by providing a name using the android:name that BEGINS with a period (this is standard Android class naming 101 ;-) but Xamarin currently does not support Android shorthand-style class names beginning w/ a dot so you need to use the fully qualified package name with your class ID name.

因此主要活动"属性变为:

So the Main Activity attribute becomes:

[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>

我的启动器类名称变为:

And my launcher class name becomes:

com.sushihangover.playscriptstarling2.MyBigBadGameEveryOneShouldPlay

Android文档:

声明类名

许多元素与Java对象相对应,包括应用程序本身(元素)及其主要组件的元素-活动(),服务(),广播接收者()和内容提供者().

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 ().

如果您定义一个子类,就像您几乎总是对组件类(Activity,Service,BroadcastReceiver和ContentProvider)一样,则通过name属性声明该子类.名称必须包含完整的包装名称.例如,服务子类可能声明如下:

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>

但是,作为简写,如果字符串的第一个字符是句点,则该字符串将附加到应用程序的程序包名称(由元素的package属性指定).

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).

以下分配与上述分配相同:

The following assignment is the same as the one above:

<manifest package="com.example.project" . . . >
    <application . . . >
        <service android:name=".SecretService" . . . >
            . . .
        </service>
        . . .
    </application>
</manifest>

启动组件时,Android创建命名子类的实例.如果未指定子类,则会创建基类的实例.

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

参考: https://developer.xamarin.com/guides/android/advanced_topics/working_with_androidmanifest.xml/#Intent_Actions_and_Features

这篇关于作为启动器放置什么:启动器收藏夹的ClassName的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆