How do I make an embedded Android OS with just one app?

陌路散爱 提交于 2019-12-18 10:08:25

问题


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

OR

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


回答1:


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.

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, this says that this Activity reacts to the

android.intent.category.HOME intent.

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

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.




回答2:


By the sound of your question you want to create your own custom Android OS build. That is going to be more involved than developing ordinary Android apps and consequently you're going to have to do a lot of reading, especially the Android OS source code.

I recommend you start here at the Android Open Source Project.



来源:https://stackoverflow.com/questions/11312576/how-do-i-make-an-embedded-android-os-with-just-one-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!