我将如何让嵌入式Android操作系统只有一个应用程序?只有一个、我将、嵌入式、应用程序

2023-09-04 23:56:07 作者:坚强的大宝贝

我会做我自己的嵌入式系统的建造仅仅使用设备分布与Android(没有他们的GUI)Android操作系统(ARM)上。

I would make my own embedded system builded on Android OS (ARM) just using device distributed with Android (without their GUI).

我要开始Android的叠加通过自己的应用程序,并拒绝它的关闭(我想从它关闭系统)。

I want to start Android overlayed by my own application and refuse it's closing (and I want shutdown system from it).

推荐答案

基本上你想有AOSP的定制版本,其中的家就是你的应用程序。如果你考虑的 /封装/应用程序/的launcher2 的你会发现$ C $下的默认主屏幕。

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.

如果你看的的Andr​​oidManifest.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>

Essentialy,这表示,本次活动反应了

Essentialy, this says that this Activity reacts to the

android.intent.category.HOME的的意图的。

android.intent.category.HOME intent.

当系统完成(更具体的ActivityManager)启动,将这一意图。所以,如果你希望你的应用程序来启动,而不是启动,只需创建自己有类似意图过滤器的应用程序,并删除默认的launcher2(把它淘汰名单中的建立/目标/产品/ 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

只要你的应用程序并没有为用户提供了一种方法来启动使用图标(如发射器一样),没有其他的应用程序将被启动其他应用程序;当然,除非一些发送活动启动意图从比一个接你的应用程序来控制一些其他的路径 - 比如通过对目标的Andr​​oid外壳是命令

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.