如何仅使用一个应用程序制作嵌入式 Android 操作系统? [英] How do I make an embedded Android OS with just one app?

查看:24
本文介绍了如何仅使用一个应用程序制作嵌入式 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.

我想在我的应用程序在顶部启动的情况下启动 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,其中主页"是您的应用程序.如果您查看 /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>

本质上,这表示该 Activity 对

Essentialy, this says that this Activity reacts to the

android.intent.category.HOME 意图.

android.intent.category.HOME intent.

当系统完成启动(更具体地说是 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

只要您的应用没有为用户提供使用图标启动其他应用的方式(如启动器那样),其他应用就不会被启动;当然,除非某些东西从应用控制的路径之外的其他路径发送 Activity-starting Intent - 例如通过在目标的 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天全站免登陆