Launcher就是一个普通的应用,不需要在系统级实现。与普通的应用区别在于AndroidManifest.xml中声明:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
>
<activity
android:name=".MyLauncherActivity"
android:clearTaskOnLaunch="true"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="nosensor"
android:stateNotNeeded="true"
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>
</application>
上面的声明同时把状态栏隐藏了。在按Home键时,会弹出选择是启动系统自带的Launcher还是我们的Launcher,可以把我们的Launcher设为默认,重启机器后,启动的就是我们的Launcher,按返回键,Home键,显示的也是我们的Launcher.