【问题标题】:How can I create a custom home-screen replacement application for Android?如何为 Android 创建自定义主屏幕替换应用程序?
【发布时间】:2011-04-09 16:02:20
【问题描述】:

如何创建主屏幕替换应用程序?有关于主屏幕应用程序的任何信息吗?

任何应用程序都可以通过CATEGORY_HOME 意图注册成为主屏幕吗?

【问题讨论】:

    标签: android launcher homescreen


    【解决方案1】:

    编写您自己的主屏幕应用程序是可能的。它被称为启动器。

    您可以通过Git获取默认Android Launcher的源代码。

    项目网址是:

    https://android.googlesource.com/platform/packages/apps/Launcher2.git

    你可以这样获取源代码:

    git clone https://android.googlesource.com/platform/packages/apps/Launcher2.git
    

    这将为您创建一个名为 Launcher2 的目录。现在您可以开始破解并创建您的自定义启动器了。

    如果您在使用 Git 方面需要帮助,请查看 Git 的documentation section

    【讨论】:

    • 别忘了看看ADW Launcher的源代码:code.google.com/p/adw-launcher-android
    • 这个问题专门询问应用程序是否可以注册特定意图 - 如果它很复杂,我可以理解示例代码,但它有多复杂?有人能描述一下意图及其要求吗?
    • 这显然让我的回答错了。说得通。查看代码并找出答案如何?
    【解决方案2】:

    使您的活动成为主屏幕的具体意图是:

    <activity....>
    <!-- Put this filter inside the activity to make it the Home screen -->
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.HOME" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    

    【讨论】:

    • 非常简单。这就是我需要知道的全部内容。
    猜你喜欢
    • 1970-01-01
    • 2011-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多