只需一个应用程序即可制作嵌入式Android操作系统? [英] How do I make an embedded Android OS with just one app?

查看:112
本文介绍了只需一个应用程序即可制作嵌入式Android操作系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Android(ARM)构建的我自己的嵌入式系统仅使用Android分发的设备,但没有启动器。

I would like to make my own embedded system built on Android (ARM) just using devices distributed with Android but without their launcher.

strong>

OR

我想启动Android,我的应用程序在顶部启动,拒绝关闭它,并从我的应用程序关闭Android。

I want to start Android with my application launched on top and refuse to close it and shutdown Android from my app.

推荐答案

本质上,您正在尝试自定义构建AOSP,Home是您的应用程序。如果您查看 / packages / apps / Launcher2 ,您将找到默认主屏幕的代码。

Essentially you're trying to have a custom build of the AOSP where the "Home" is your application. If you look into /packages/apps/Launcher2 you'll find the code for the default Home screen.

如果您查看其中的 AndroidManifest.xml 文件,您将看到如下:

If you look at the AndroidManifest.xml file in there, you'll see something like this:

     <activity
        android:name="com.android.launcher2.Launcher"
        android:launchMode="singleTask"
        android:clearTaskOnLaunch="true"
        android:stateNotNeeded="true"
        android:theme="@style/Theme"
        android:screenOrientation="nosensor"
        android:windowSoftInputMode="stateUnspecified|adjustPan">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.HOME" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.MONKEY"/>
        </intent-filter>
    </activity>

本质上说,此活动对


android.intent.category.HOME 意图

当系统完成启动(更具体的ActivityManager)时,发送该意图。所以,如果你希望你的应用程序启动而不是启动器,只需创建一个具有类似意图过滤器的应用程序,并删除默认的Launcher2(将其从 build / target / product / generic.mk 并把你的代替)。还要确保相关的.mk文件有这样的东西:

When the system finishes booting (the ActivityManager more specifically), sends that intent. So, if you want your app to start instead of the Launcher, just create yourself an app with a similar intent filter and remove the default Launcher2 (take it out of the list in build/target/product/generic.mk and put yours instead). Also make sure the relevant .mk file has something like this:

LOCAL_OVERRIDES_PACKAGES := Home

只要您的应用程序不提供用户使用图标启动其他应用程序的方式(如启动器),则没有其他应用程序将开始;除非当然,某些其他路径会发送一个活动启动意图,而不是由您的应用程序控制的其他路径 - 例如通过在目标的Android shell上使用am命令。

So long as your app doesn't provide a way for the user to launch other apps using icons (like the Launcher does), no other app will be started; unless of course something sends an Activity-starting intent from some other path than the one controlled by your app - say by using the "am" command on the target's Android shell.

这篇关于只需一个应用程序即可制作嵌入式Android操作系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆