`
qepwqnp
  • 浏览: 108855 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

【转】Launcher研究之AndroidManifest.xml分析

阅读更多

Launcher的AndroidManifest.xml文件有很多特殊性,分析一下就会理解整个程序的大概结构。
代码如下:

< manifest xmlns:android = http://schemas.android.com/apk/res/android

package = "net.sunniwell.launcher"

android:versionCode = "1" android:versionName = "1.0.1" >

关于自定义权限,这是很好的例子,其他 apk 程序要想使用 Launcher 的功能必须添加这些权限,而这些权限都是在这里声明的。

这个是安装快捷方式的权限定义:

< permission

android:name = "com.android.launcher.permission.INSTALL_SHORTCUT"

android:permissionGroup = "android.permission-group.SYSTEM_TOOLS"

android:protectionLevel = "normal"

android:label = "@string/permlab_install_shortcut"

android:description = "@string/permdesc_install_shortcut" />

这个是卸载快捷方式的权限定义:

< permission

android:name = "com.android.launcher.permission.UNINSTALL_SHORTCUT"

android:permissionGroup = "android.permission-group.SYSTEM_TOOLS"

android:protectionLevel = "normal"

android:label = "@string/permlab_uninstall_shortcut"

android:description = "@string/permdesc_uninstall_shortcut" />

这个是读取 launcher.db 内容的权限定义:

< permission

android:name = "net.sunniwell.launcher.permission.READ_SETTINGS"

android:permissionGroup = "android.permission-group.SYSTEM_TOOLS"

android:protectionLevel = "normal"

android:label = "@string/permlab_read_settings"

android:description = "@string/permdesc_read_settings" />

这个是修改和删除 launcher.db 内容的权限定义:

< permission

android:name = "net.sunniwell.launcher.permission.WRITE_SETTINGS"

android:permissionGroup = "android.permission-group.SYSTEM_TOOLS"

android:protectionLevel = "normal"

android:label = "@string/permlab_write_settings"

android:description = "@string/permdesc_write_settings" />

这些是 Launcher 的权限声明,通过这些就能看出 launcher 的大概功能了:

打电话权限:

< 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" />

允许程序设置壁纸 hits 的权限:

< uses-permission android:name = "android.permission.SET_WALLPAPER_HINTS" />

使用震动功能权限:

< uses-permission android:name = "android.permission.VIBRATE" />

修改删除 launcher.db 内容权限:

< uses-permission android:name = "android.permission.WRITE_SETTINGS" />

绑定 widget 权限:

< uses-permission android:name = "android.permission.BIND_APPWIDGET" />

读取 launcher.db 内容权限:

< uses-permission android:name = "net.sunniwell.launcher.permission.READ_SETTINGS" />

修改删除 launcher.db 内容权限:

< uses-permission android:name = "net.sunniwell.launcher.permission.WRITE_SETTINGS" />

读写外部存储设备权限:

< uses-permission android:name = "android.permission.WRITE_EXTERNAL_STORAGE" ><!-- </font-->uses-permission >

< application

android:name = "LauncherApplication"

activity 应该运行的进程的名字:

android:process = "android.process.acore"

android:label = "@string/application_name"

android:icon = "@drawable/swicon" >

< activity

android:name = "Launcher"

是否

android:launchMode = "singleTask"

android:clearTaskOnLaunch = "true"

这个 activity 是否在被杀死或者重启后能恢复原来的状态:

android:stateNotNeeded = "true"

android:theme = "@style/Theme"

android:screenOrientation = "landscape"

android:windowSoftInputMode = "stateUnspecified|adjustPan" >

< intent-filter >

< action android:name = "android.intent.action.MAIN" />

< category android:name = "android.intent.category.LAUNCHER" />

桌面应用的标记:

< category android:name = "android.intent.category.HOME" />

< category android:name = "android.intent.category.DEFAULT" />

自动化测试工具 Monkey 的标记,待研究

< category android:name = "android.intent.category.MONKEY" />

<!-- </font-->intent-filter >

<!-- </font-->activity >

选择壁纸的 activity:
< activity

android:name = "WallpaperChooser"

android:label = "@string/pick_wallpaper"

android:icon = "@drawable/ic_launcher_gallery" >

设置壁纸的 intent-filter

< intent-filter >

< action android:name = "android.intent.action.SET_WALLPAPER" />

< category android:name = "android.intent.category.DEFAULT" />

<!-- </font-->intent-filter >

搜索的 activity

<!-- </font-->activity >

<!-- Enable system-default search mode for any activity in Home -->

< meta-data

android:name = "android.app.default_searchable"

android:value = "*" />

安装快捷方式的广播接收器:

<!-- Intent received used to install shortcuts from other applications -->

< receiver

android:name = ".InstallShortcutReceiver"

android:permission = "com.android.launcher.permission.INSTALL_SHORTCUT" >
< intent-filter >
< action android:name = "com.android.launcher.action.INSTALL_SHORTCUT" />
<!-- </font-->intent-filter >
<!-- </font-->receiver >
<!-- Intent received used to <u>uninstall</u> shortcuts from other applications &ndash;></font></p> <p><font face="宋体 "><font style="font-size: 10pt" mce_style="font-size: 10pt" size="3">卸载快捷方式的广播接收器:</font></font><font style="font-size: 10pt" mce_style="font-size: 10pt"> <br /></font><font size="3"><font style="font-size: 10pt" mce_style="font-size: 10pt"><</font><font style="font-size: 10pt" mce_style="font-size: 10pt">receiver</font></font></p> <p align="left"><font style="font-size: 10pt" mce_style="font-size: 10pt"><font size="3"><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#7f007f">android:name</font><font color="#000000">=</font><font color="#2a00ff"><i>".UninstallShortcutReceiver"</i></font></font></font></p> <p align="left"><font style="font-size: 10pt" mce_style="font-size: 10pt"><font size="3"><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#7f007f">android:permission</font><font color="#000000">=</font><font color="#2a00ff"><i>"com.android.launcher.permission.UNINSTALL_SHORTCUT"</i></font><font color="#008080">></font></font></font><font style="font-size: 10pt" mce_style="font-size: 10pt"> <br /></font><font size="3"><font style="font-size: 10pt" mce_style="font-size: 10pt"><</font><font style="font-size: 10pt" mce_style="font-size: 10pt">intent-filter</font><font style="font-size: 10pt" mce_style="font-size: 10pt">></font></font><font style="font-size: 10pt" mce_style="font-size: 10pt"> <br /></font><font size="3"><font style="font-size: 10pt" mce_style="font-size: 10pt"><</font><font style="font-size: 10pt" mce_style="font-size: 10pt">action</font><font style="font-size: 10pt" mce_style="font-size: 10pt"><font color="#000000"> </font><font color="#7f007f">android:name</font><font color="#000000">=</font><font color="#2a00ff"><i>"com.android.launcher.action.UNINSTALL_SHORTCUT"</i></font><font color="#000000"> </font><font color="#008080">/></font></font></font><font style="font-size: 10pt" mce_style="font-size: 10pt"> <br /></font><font size="3"><font style="font-size: 10pt" mce_style="font-size: 10pt"></</font><font style="font-size: 10pt" mce_style="font-size: 10pt">intent-filter</font><font style="font-size: 10pt" mce_style="font-size: 10pt">></font></font><font style="font-size: 10pt" mce_style="font-size: 10pt"> <br /></font><font size="3"><font style="font-size: 10pt" mce_style="font-size: 10pt"></</font><font style="font-size: 10pt" mce_style="font-size: 10pt">receiver</font><font style="font-size: 10pt" mce_style="font-size: 10pt">></font></font></p> <p align="left"><font size="3"><font face="宋体 "><font style="font-size: 10pt" mce_style="font-size: 10pt">声明</font></font><font style="font-size: 10pt" mce_style="font-size: 10pt">ContentProvider</font><font face="宋体 "><font style="font-size: 10pt" mce_style="font-size: 10pt">,用于对</font></font><font style="font-size: 10pt" mce_style="font-size: 10pt">launcher.db</font><font face="宋体 "><font style="font-size: 10pt" mce_style="font-size: 10pt">操作:</font></font></font><font style="font-size: 10pt" mce_style="font-size: 10pt"> <br /></font><font style="font-size: 10pt" mce_style="font-size: 10pt" size="3"><!-- The settings provider contains Home's data, like the workspace favorites -->
< provider

android:name = "SWLauncherProvider"

android:authorities = "net.sunniwell.launcher.settings"

android:writePermission = "net.sunniwell.launcher.permission.WRITE_SETTINGS"

android:readPermission = "net.sunniwell.launcher.permission.READ_SETTINGS" />
<!-- </font-->application >
< uses-sdk android:minSdkVersion = "4" />

<!-- </font-->manifest >
说明:
1.
标签头部还应声明:

android:sharedUserId="android.uid.shared" ,作用是获得系统权限,但是这样的程序属性只能在build整个系统时放进去(就是系统软件)才起作用,手动安装是没有权限的。

分享到:
评论

相关推荐

    Android学习笔记之AndroidManifest.xml文件解析

    ### AndroidManifest.xml 文件解析知识点 #### 一、概述 `AndroidManifest.xml` 是 Android 应用的核心配置文件,它位于应用项目的根目录下。该文件主要用于描述应用的基本信息及其组件,比如 Activity、Service、...

    AndroidManifest.xml解析

    《深入理解AndroidManifest.xml解析》 在Android应用开发中,AndroidManifest.xml文件扮演着至关重要的角色。它是每个Android程序的核心配置文件,位于应用程序的根目录下,用于定义应用程序的全局特性,包括应用...

    AndroidManifest.rar

    在Android应用开发中,`AndroidManifest.xml`文件是至关重要的组成部分,它...压缩包中的`AndroidManifest.xml`文件可能包含了解决这个问题的关键信息,通过详细查看和分析,可以找到并修复问题,从而实现“完美解”。

    AndroidManifest.xml+G+÷

    AndroidManifest.xml是Android应用的核心配置文件,它包含了应用程序的全局信息,是每个Android程序必不可少的部分。这个文件主要负责声明应用中的组件(如Activities、Services、Broadcast Receivers和Content ...

    Manifest.xml文件的作用和简单使用

    `AndroidManifest.xml` 是 Android 应用中的核心配置文件,其主要职责在于向 Android 操作系统声明应用的各个组成部分及特性。该文件采用 XML 格式编写,包含了应用的基础信息如包名、主 Activity 等,同时也定义了...

    AndroidManifest-Apk-Collection:这是您的Apk项目的AndroidManifest.xml的集合(可免费编辑和使用)

    AndroidManifest.xml是每个Android应用程序的核心组件之一,它作为应用程序的元数据存储库,定义了应用的基本属性、权限、活动、服务、广播接收器以及内容提供者等关键元素。在这个"AndroidManifest-Apk-Collection...

    android手把手教你开发launcher[整理].pdf

    要开发自己的 Launcher 应用程序,需要在 AndroidManifest.xml 文件中添加相应的 Intent Filter,包括 android.intent.action.MAIN、android.intent.category.LAUNCHER、android.intent.category.HOME 和 android....

    android手把手教你开发launcher

    在 AndroidManifest.xml 文件中,我们需要添加 intent-filter,以便我们的应用程序能够作为 Launcher 运行。 AndroidManifest.xml 文件 在 AndroidManifest.xml 文件中,我们需要添加以下代码: ```xml &lt;?xml ...

    android手把手教你开发launcher.pdf

    要开发自己的 Launcher,我们需要创建一个新的 Android 项目,并在 AndroidManifest.xml 文件中添加相应的配置。首先,我们创建一个新的 Android 项目,called MyHome,并在 AndroidManifest.xml 文件中添加以下代码...

    eclipse直接运行Launcher

    在Android开发中,Launcher源码的分析对于开发者来说非常有价值,因为它涵盖了Android四大组件(Activity、Service、BroadcastReceiver、ContentProvider)的使用,以及对AndroidManifest.xml配置的理解。Launcher2....

    Android--UI-新手必备源码master.zip

    │ │ │ AndroidManifest.xml │ │ │ │ │ ├─java │ │ │ └─com │ │ │ └─bob │ │ │ └─arclayout │ │ │ │ AnimatorUtils.java │ │ │ │ Demo.java │ │ │ │ DemoActivity....

    android手把手教你开发launcher(AndroidStudio版)

    创建项目后,需要在AndroidManifest.xml文件中对MainActivity添加特定的intent-filter,使其能被系统识别为Launcher。这通常通过添加如下category来实现: &lt;category android:name="android.intent.category....

    2AndroidManifest文件介绍.docx

    ### AndroidManifest.xml 文件详解 #### 一、概览 在Android应用开发中,`AndroidManifest.xml`文件扮演着至关重要的角色。它不仅是应用程序的核心配置文件,还是应用与Android系统进行沟通的重要桥梁。通过该文件...

    去除ROM内 apk软件 列表图标的显示 例如设置等可以完全隐秘 .doc

    在AndroidManifest.xml文件中,搜索`&lt;category android:name="android.intent.category.LAUNCHER" /&gt;`。这段代码表示该应用应该有一个图标在主屏幕或应用列表上。如果你想隐藏特定应用,例如设置,你需要找到对应...

Global site tag (gtag.js) - Google Analytics