如何为 Android 创建自定义主屏幕替换应用程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3666771/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I create a custom home-screen replacement application for Android?
提问by Simon
How do I create a home-screen replacement application? Is there any information about the home-screen application available?
如何创建主屏幕更换应用程序?是否有关于主屏幕应用程序的任何信息?
Can any application be a home-screen by just registering it with a CATEGORY_HOME
intent?
任何应用程序都可以通过CATEGORY_HOME
意图注册来成为主屏幕吗?
采纳答案by Octavian A. Damiean
Writing your own home screen application is possible. It is called the Launcher.
编写您自己的主屏幕应用程序是可能的。它被称为启动器。
You can get the source code of the default Android Launcher via Git.
您可以通过Git获取默认 Android Launcher 的源代码。
The project URL is:
项目网址是:
https://android.googlesource.com/platform/packages/apps/Launcher2.git
https://android.googlesource.com/platform/packages/apps/Launcher2.git
You can get the source code like this:
你可以得到这样的源代码:
git clone https://android.googlesource.com/platform/packages/apps/Launcher2.git
That will create a directory called Launcher2for you. Now you can get cracking and create your custom launcher.
这将为您创建一个名为Launcher2的目录。现在您可以破解并创建您的自定义启动器。
If you need help with using Git then checkout Git's documentation section.
如果您在使用 Git 方面需要帮助,请查看 Git 的文档部分。
回答by Ena
The specific Intent to make your activity the Home screen is:
使您的活动成为主屏幕的具体意图是:
<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>