`
qepwqnp
  • 浏览: 105960 次
  • 性别: 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--UI-新手必备源码master.zip

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

    BaiduMap_AndroidSDK Sample_demo

    配置AndroidManifest.xml 使用百度SDK时,应用的AndroidManifest.xml主要需要注意以下三项: 4.1、权限 不同的功能需要申请不同的权限,因此在实际使用时,最好参考百度的SDK文档。 其次,在Android 6.0以后引入...

    安卓查看系统内存大小

    ...........\AndroidManifest.xml ...........\ant.properties ...........\assets ...........\bin ...........\build.xml ...........\CheckMemory.iml ...........\gen ...........\...\me ...........\...

    快速Android 反编译 回编译 工具集 含直接调试破解之法

    1》修改AndroidManifest.xml 主中android.intent.action.MAIN和android.intent.category.LAUNCHER【application】的 android:debuggable="true" 2》在入口处添加waitForDebugger代码进行调试等待。 Activity中a=0...

    CustomLauncher3:自己修改的安卓系统桌面,基于Launcher3

    需要插入包称为非com.android.launcher3,并放置所有com.android.launcher3的引用,如:ProviderConfig.AUTHORITY,AndroidManifest.xml中的权限相关及提供者的权限属性等; ###改屏幕方向AndroidManifest.xml的入口...

    ResourcesId.zip

    代码中动态获取资源ID res\ .settings\ gen\ src\ libs\ assets\ .classpath AndroidManifest.xml project.properties ic_launcher-web.png .project proguard-project.txt

    tigase-mobilemessenger

    │ │ │ AndroidManifest.xml │ │ │ │ │ ├─java │ │ │ └─org │ │ │ └─tigase │ │ │ └─messenger │ │ │ ├─jaxmpp │ │ │ │ └─android │ │ │ │ ├─caps │ │ │ │ │ ...

    自己做的动画效果 旋转 侧滑 勿喷哈

    /MyAnimationcxy /src com.cxy.myanimation /src/.../gen /assets /bin /libs /res /AndroidManifest.xml /ic_launcher-web.png /lint.xml /proguard-project.txt /project.properties

    自动更新apk,xamarin.android 对话框

    ## 权限清单(AndroidManifest.xml) ```xml &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android....

    android_通话处理流程

    1、contacts的androidmanifest.xml android:process="android.process.acore"说明此应用程序运行在acore进程中。 DialtactsActivity的intent-filter的action属性设置为main,catelog属性设置为launcher,所以此...

    debugoverlay-在页面上方以半透明层的方式弹出消息、通知.zip

    项目地址:https://github.com/sockeqwe/debugoverlay 效果图:如何使用在清单文件(AndroidManifest.xml)中添加权限及.DebugOverlayService服务: android:name="android.permission.SYSTEM_ALERT_WINDOW"/&gt; ...

    android扫雷源码

    * AndroidManifest.xml =&gt; app\src\main\AndroidManifest.xml * assets\ =&gt; app\src\main\assets * res\ =&gt; app\src\main\res\ * src\ =&gt; app\src\main\java\ Next Steps: ----------- You can now build the ...

    ADW_Launcher源码和配置过程

    最后在AndroidManifest.xml文件里面,找到这句话删除掉(android:sharedUserId="android.uid.shared")。到现在为止,你就拥有了自己的Launcher了! 关于如何调试代码的问题请参考以下网址: 原帖地址:...

    flutter_launcher_name

    如果您使用此软件包,则无需修改AndroidManifest.xml或Info.plist。 :sparkles: 什么是新的 :open_book: 指导1.设置配置文件将Flutter Launcher名称配置添加到pubspec.yaml 。 一个例子如下所示。 dev_dependencies...

    Android 修改app图标和名称的方法

    如果你要自己的名称,可以修改AndroidManifest.xml的这个节点: &lt;application Android:icon=@drawable/ic_launcher&gt; 不需要加文件扩展名。 2 修改程序名 请到values/strings.xml下 &lt;?xml version=1.0 ...

    Example_NovaTheme:记录了Nova Launcher的示例主题

    示例Nova启动器主题 Nova Launcher是Android的高度可定制的启动器。 这种定制的一部分来自像您这样的开发人员。 ... 这是通过在AndroidManifest.xml中的标签下方添加以下内容来完成的 &lt;actio

    Android状态保存、用户偏好设置保存、通过universal_image_loder网络加载图片并做图片缓存处理Demo

    4、在AndroidManifest.xml文件中加入权限 &lt;uses-permission android:name="android.permission.INTERNET" /&gt; &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt; 和 android:name=".My...

    apktool documentation

    If you tried to view AndroidManifest.xml. You'd be left viewing this. P4F0\fnversionCodeversionNameandroid*...

    opencv_android开发库

    在AndroidManifest.xml中增加写sd卡的权限: &lt;uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/&gt; &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt; ...

    Android如何让WebView中的HTML5页面实现视频全屏播放

    前言 本文主要是将最近工作中遇到的一个问题进行总结分享,...在清单需要配置的AndroidManifest.xml &lt;application android:allowBackup=true android:icon=@mipmap/ic_launcher android:label=@string/app_name

Global site tag (gtag.js) - Google Analytics