android launcher开发(1)

从这里可以下载源码
launcher,启动器,是我们安卓系统运行的第一个程序。我们可以通过学习源码,对launcher进行了解,从而定制我们的桌面程序。

清单文件

通过源码我们可以看出,launcher中声明 了一些 自定义的权限。

  <activity
            android:name="com.android.launcher3.Launcher"
            android:launchMode="singleTask"
            android:clearTaskOnLaunch="true"
            android:stateNotNeeded="true"
            android:theme="@style/Theme"
            android:windowSoftInputMode="adjustPan"
            android:screenOrientation="nosensor"
            android:resumeWhilePausing="true"
            android:taskAffinity=""
            android:enabled="true">
            <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>

laucher类是我们开发中最终的的一个类,也就是我么所看到的桌面类。从他的launchmode可以看出他是一个,单任务模式。
从android:name=”android.intent.category.HOME” ,可以看出他就是桌面。
从名字可以看出,他是对外提供设置壁纸的功能

   <activity
            android:name="com.android.launcher3.WallpaperPickerActivity"
            android:theme="@style/Theme.WallpaperPicker"
            android:label="@string/pick_wallpaper"
            android:icon="@mipmap/ic_launcher_wallpaper"
            android:finishOnCloseSystemDialogs="true"
            android:process=":wallpaper_chooser">
            <intent-filter>
                <action android:name="android.intent.action.SET_WALLPAPER" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

通过第三方设置壁纸的接口

  <activity
            android:name="com.android.launcher3.WallpaperCropActivity"
            android:theme="@style/Theme.WallpaperCropper"
            android:label="@string/crop_wallpaper"
            android:icon="@mipmap/ic_launcher_wallpaper"
            android:finishOnCloseSystemDialogs="true"
            android:process=":wallpaper_chooser">
            <intent-filter>
                <action android:name="android.service.wallpaper.CROP_AND_SET_WALLPAPER" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="image/*" />
            </intent-filter>
        </activity>

既然提供了改变壁纸的接口,那么同样提供壁纸改变的广播接收器

  <receiver
            android:name="com.android.launcher3.WallpaperChangedReceiver">
            <intent-filter>
                <action android:name="android.intent.action.WALLPAPER_CHANGED" />
            </intent-filter>
        </receiver>

既然launcher是我们系统的启动程序,那么他肯定监听系统启动完成的广播
:StartupReceiver
launcher3数据库组件: LauncherProvider,可以看得出继承一个内容提供者

Lau ncher初始化

在launcher类的oncreate方法里面,LauncherAppState.setApplicationContext(getApplicationContext());
LauncherAppState app = LauncherAppState.getInstance();

这是对LauncherAppState进行初始化,他保存这laucher运行时所需要的公共信息。
当我们的laucher因为某些原因种植的时候,可以调用其onTerminate()方法。
在这个方法里面里,laucher会对其运行环境进行清理

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值