定制替换Android桌面(home screen)


替换Android桌面的相关问题:

1、想将home screen换成自己写的activity,该如何实现?

在你要设置为home screen的那个activity的androidManifest.xml中的<intent-filter>标签中加上这几句 话<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />运行后,重启模拟器会弹出一个选择进入哪个界面的对话框

2、怎样将系统默认的home screen删除?

重新编译launcher源码,去掉配置文件中的home属性和HOME属性。。
在自己的activity中加入这两个属性,然后重新烧系统。 

以下是定制Android的完整思路和步骤:

如果你要定制一个Android系统,你想用你自己的Launcher(Home)作主界面来替换Android自己的Home,而且不希望用户安装的Launcher来替换掉你的Launcher.
我们可以通过修改Framework来实现这样的功能。

这里以Android2.1的源代码为例来实际说明。

1)首先了解一下Android的启动过程。
Android系统的启动先从Zygote开始启动,然后……(中间的过程就不说了)…..一直到了SystemServer(framework)这个地方,看到这段代码:

  1. /**
  2. * This method is called from Zygote to initialize the system. This will cause the native
  3. * services (SurfaceFlinger, AudioFlinger, etc..) to be started. After that it will call back
  4. * up into init2() to start the Android services.
  5. */
  6. native public static void init1(String[] args);
  7. public static void main(String[] args) {
  8. if (SamplingProfilerIntegration.isEnabled()) {
  9. SamplingProfilerIntegration.start();
  10. timer = new Timer();
  11. timer.schedule(new TimerTask() {
  12. @Override
  13. public void run() {
  14. SamplingProfilerIntegration.writeSnapshot(“system_server”);
  15. }
  16. }, SNAPSHOT_INTERVAL, SNAPSHOT_INTERVAL);
  17. }
  18. // The system server has to run all of the time, so it needs to be
  19. // as efficient as possible with its memory usage.
  20. VMRuntime.getRuntime().setTargetHeapUtilization(0.8f);
  21. System.loadLibrary(“android_servers”);
  22. init1(args);
  23. }
  24. public static final void init2() {
  25. Log.i(TAG, “Entered the Android system server!”);
  26. Thread thr = new ServerThread();
  27. thr.setName(“android.server.ServerThread”);
  28. thr.start();
  29. }
  30. }

从SystemServer的main函数开始启动各种服务。
首先启动init1,然后启动init2.
从上面的注释可以看到:init1这个方法时被Zygote调用来初始化系统的,init1会启动native的服务如SurfaceFlinger,AudioFlinger等等,这些工作做完以后会回调init2来启动Android的service。

  • 1
  • 2
  • 3
  • 下一页

相关内容