我有一个非常简单的游戏,只包含一个活动,我想添加一个标题画面。

如果标题画面是另一个活动,我需要什么样的变化,使我的清单文件,使标题画面开放的第一?

在游戏活动被称为Leeder先生和标题屏幕活动被称为LeederTitleScreen

下面是我目前的清单文件。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="org.nifong.leeder"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name="Leeder"
                  android:label="@string/app_name"
                  android:configChanges="keyboardHidden|orientation"
                  android:screenOrientation="landscape">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-sdk android:minSdkVersion="5" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
</manifest>
有帮助吗?

解决方案

所有你应该做的是改变:

<activity android:name="Leeder"

为:

<activity android:name="LeederTitleScreen"

如果你希望你的标题画面开始通过startActivity()游戏,你还需要申报清单的Leeder活动。

修改:是的,你需要的<意向过滤器>部分。它告诉它隐含的意图您的活动将响应系统。因此,在您的清单中,意图过滤告诉它将给android.intent.category.LAUNCHER意图,这是Android的,当它启动一个应用程序调度响应系统(即它告诉Android的开始,当应用程序被启动的活动)。

这里是很好地概述意图和意图过滤器。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top