【问题标题】:Android app with multiple activities具有多个活动的 Android 应用
【发布时间】:2010-02-08 23:43:27
【问题描述】:

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

如果标题屏幕是另一个活动,我需要对清单文件进行哪些更改才能使标题屏幕首先打开?

游戏活动称为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>

【问题讨论】:

    标签: android android-activity android-manifest


    【解决方案1】:

    你应该做的就是改变:

    <activity android:name="Leeder"
    

    到:

    <activity android:name="LeederTitleScreen"
    

    如果您希望标题屏幕通过startActivity() 启动游戏,您还需要在清单中声明您的Leeder 活动。

    编辑:是的,您需要 部分。它告诉系统您的活动将响应哪些隐式意图。所以在你的清单中,intent 过滤器告诉系统它将响应android.intent.category.LAUNCHERintent,这是Android 在启动应用程序时调度的内容(即它告诉Android 在应用程序启动时启动Activity)。

    Here 很好地概述了意图和意图过滤器。

    【讨论】:

    • 意图过滤器是干什么用的?我还需要那个吗?
    • 编辑了我的答案,使其更加深入。
    猜你喜欢
    • 2021-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多