%3cprovider android,LauncheProvider解析.doc

LauncheProvider解析

LauncherProvider解析

Launcher是由ActivityManagerService启动的,而ActivityManagerService和PackageManagerService一样,都是在开机时由SystemServer组件启动的,SystemServer组件首先是启动PackageManagerServic,由它来负责安装系统的应用程序,系统中的应用程序安装好了以后,SystemServer组件接下来就要通过ActivityManagerService来启动Home应用程序Launcher了,Launcher在启动的时候便会通过PackageManagerServic把系统中已经安装好的应用程序以快捷图标的形式展示在桌面上,这样用户就可以使用这些应用程序了。

一、整个Launcher的入口点

1、LauncherApplication.java

继承了Application类,当整个Launcher启动时,它就是整个程序的入口。由AndroidManifest.xml文件可以看到整个Launcher的代码结构,如下:

在AndroidManifest.xml中的配置

android:name="com.android.launcher2.LauncherApplication"

android:label="@string/application_name"

android:icon="@drawable/ic_launcher_home"

android:hardwareAccelerated="@bool/config_hardwareAccelerated"

android:largeHeap="@bool/config_largeHeap">

android:name:指定了整个Launcher的Application也就是入口是在 com.android.launcher2.LauncherApplication这个路径下。

android:label:指定了桌面的名字是叫 Launcher,如果要改名字就改values文件夹的string.xml中的相应属性就可以了。

android:icon:指定了Laucher的图标,这个图标可以在应用程序管理器中看见。如果需要更改Laucher的图片,重新设置这个属性就可以了。

android:hardwareAccelerated:指定了整个应用程序是启用硬件加速的,这样整个应用程序的运行速度会更快。

android:largeHeap:指定了应用程序使用了大的堆内存,能在一定程度上避免,对内存out of memory错误的出现。可以在values文件夹的config.xml中看到对是否启用硬件加速和大内存的配置。如下:

true

false

2、LauncherApplication中onCreate()方法:

public class LauncherApplication extends Application {

public LauncherModel mModel;

public IconCache mIconCache;

private static boolean sIsScreenLarge;

private static float sScreenDensity;

WeakReference mLauncherProvider;

@Override

public void onCreate() {

super.onCreate();

// set sIsScreenXLarge and sScreenDensity *before* creating icon cache

final int screenSize = getResources().getConfiguration().screenLayout &

Configuration.SCREENLAYOUT_SIZE_MASK;

sIsScreenLarge = screenSize == Configuration.SCREENLAYOUT_SIZE_LARGE ||

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值