Android - 应用程序hasCode标记

时间:2015-06-21 19:51:23

标签: android

<application>的Android开发人员page包含标记hasCode。它的描述说:

An application would not have any code of its own only if it's using 
nothing but built-in component classes, such as an activity that uses 
the AliasActivity class, a rare occurrence.

有人可以提供他们谈论的AliasActivity用例(罕见)的代码示例吗?

1 个答案:

答案 0 :(得分:2)

AliasActivity - 顾名思义 - 只是另一个活动的别名。

您可以使用XML创建一个。 Android git存储库中有example available

你的表现可能如下:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.aliasactivity">
    <application android:hasCode="false" android:label="@string/app_label">
        <activity android:name="android.app.AliasActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <meta-data android:name="android.app.alias"
                    android:resource="@xml/alias" />
        </activity>
    </application>
</manifest>

在res / xml / alias.xml中定义intent:

<alias xmlns:android="http://schemas.android.com/apk/res/android">
    <intent android:action="android.intent.action.VIEW"
        android:data="http://www.google.com/">
    </intent>
</alias>
相关问题