开发自己的android桌面,有这个想法是去年一个项目(移动公司的变态项目,需要定制android机器,将一对移动业务定制到里面去)需要定制android桌面,当初的做法是直接改原版的Launcher.apk源码,然后再Linux下编译生成Launcher.apk然后刷到固件中去.实现桌面定制,让用户无法删除.至于为什么,你懂的....
废话不多说了.我们现在要做的不是改原生的Launcher.apk,而是做个相当于普通apk能删除与安装的桌面,现在市面上有的如:91的熊猫桌面.还有其他一些在开发的就不多说了.
先什么都不说来段demo最实际,一切从最原始的兴趣驱动,有了小成就才更有动力来了解与学习launcher,需要刨根问底的同学们,自己google先.



Manager.java

package com.jaryou;    import com.nebulalauncher.R;    import android.app.Activity;  import android.os.Bundle;    public class Manager extends Activity {      /** Called when the activity is first created. */      @Override      public void onCreate(Bundle savedInstanceState) {          super.onCreate(savedInstanceState);          setContentView(R.layout.main);      }  } 


Launcher.java view plain print ?
  1. packagecom.jaryou.launcher;
  2. importcom.nebulalauncher.R;
  3. importandroid.app.Activity;
  4. importandroid.os.Bundle;
  5. publicclassLauncherextendsActivity{
  6. /**Calledwhentheactivityisfirstcreated.*/
  7. @Override
  8. publicvoidonCreate(BundlesavedInstanceState){
  9. super.onCreate(savedInstanceState);
  10. setContentView(R.layout.launcher);
  11. }
  12. }

launcher.xml
    <?xml version="1.0" encoding="utf-8"?>      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"          android:orientation="vertical"          android:layout_width="fill_parent"          android:layout_height="fill_parent"          >      <TextView            android:layout_width="fill_parent"           android:layout_height="wrap_content"           android:text="@string/hello"          />      </LinearLayout>  



main.xml

    <?xml version="1.0" encoding="utf-8"?>      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"          android:orientation="vertical"          android:layout_width="fill_parent"          android:layout_height="fill_parent"          >      <TextView            android:layout_width="fill_parent"           android:layout_height="wrap_content"           android:text="@string/hello"          />      </LinearLayout>  AndroidManifest.xml     (关键代码)view plainprint?    <?xml version="1.0" encoding="utf-8"?>      <manifest xmlns:android="http://schemas.android.com/apk/res/android"          package="com.nebulalauncher" android:versionCode="1"          android:versionName="1.0">          <application android:icon="@drawable/icon" android:label="@string/app_name">      <!-- 作为桌面设置的Activity -->              <activity android:name=".Manager" android:label="@string/app_name">                  <intent-filter>                      <action android:name="android.intent.action.MAIN" />                      <category android:name="android.intent.category.LAUNCHER" />                  </intent-filter>              </activity>              <!--  作为桌面Activity -->              <activity android:name="com.jaryou.launcher.Launcher">                  <intent-filter>                       <action android:name="android.intent.action.MAIN" />                       <!-- 关键部分 开始-->                      <category android:name="android.intent.category.HOME"/>                       <category android:name="android.intent.category.DEFAULT" />                      <!-- 关键部分 结束-->                   </intent-filter>               </activity>                 </application>          <uses-permission android:name="android.permission.CALL_PHONE" />          <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />          <uses-permission android:name="android.permission.GET_TASKS" />          <uses-permission android:name="android.permission.READ_CONTACTS" />          <uses-permission android:name="android.permission.SET_WALLPAPER" />          <uses-permission android:name="android.permission.SET_WALLPAPER_HINTS" />          <uses-permission android:name="android.permission.VIBRATE" />          <uses-permission android:name="android.permission.WRITE_SETTINGS" />      </manifest>


新建个android的项目,将上面的代码贴进去,然后运行.

ok,然后再长按 挂机键 出现桌面选择提示

1.启动器(默认launcher)

2. 你的应用名称

这时候选择你的应用,会发现桌面变成了你的刚弄的这个demo了.

如果需要变回原来的launcher.只需要要长按挂机键然后松开就能换回默认桌面.

不多说了.先去体现下吧.


更多相关文章

  1. Kotlin For Android:如何创建一个Kotlin项目
  2. Android官方MVP架构示例项目解析
  3. 【Android】AsyncTask原理应用及源码关键部分解析
  4. Android项目使用Ant打包,自动生成build.xml
  5. 【边做项目边学Android】异常处理:android.os.NetworkOnMainThrea
  6. Android 应用桌面角标显示
  7. Android 小项目之--使用【AudioManager】类控制音量

随机推荐

  1. Android带进度条文件上传
  2. Android:DialogFragment的使用
  3. WordPress for Android 开源学习
  4. 大型博彩公司招聘 .net,DB,tester,androi
  5. Android(安卓)TV应用 RecyclerView 焦点
  6. Android UI显示电量跳变
  7. Loader和Fragment使用示例代码
  8. Android提供语音搜索功能
  9. Android(安卓)Vibrator震动效果
  10. Android 2.2 r1 API 中文文档系列(11) ――