(8)Launcher3客制化之ContentProvider内容提供者,实现其它应用改动数据库更新等操作
首先加入两个权限
<uses-permission android:name="com.android.launcher3.permission.READ_SETTINGS"/>
<uses-permission android:name="com.android.launcher3.permission.WRITE_SETTINGS"/>
这两个是改动 桌面的数据库的权限
不加入就改动不了哦
直接通过内容提供者获取数据,
static ArrayList<ShortcutInfo> getItemsInLocalCoordinates(Context context) {
ArrayList<ShortcutInfo> items = new ArrayList<ShortcutInfo>();
final ContentResolver cr = context.getContentResolver();
Cursor c = cr.query(LauncherSettings.Favorites.CONTENT_URI, new String[] {
LauncherSettings.Favorites.ITEM_TYPE, LauncherSettings.Favorites.CONTAINER,
LauncherSettings.Favorites.SCREEN, LauncherSettings.Favorites.CELLX, LauncherSettings.Favorites.CELLY,
LauncherSettings.Favorites.SPANX, LauncherSettings.Favorites.SPANY ,LauncherSettings.Favorites.TITLE,LauncherSettings.Favorites.INTENT}, null, null, null);
final int itemTypeIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ITEM_TYPE);
final int containerIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CONTAINER);
final int screenIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.SCREEN);
final int cellXIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLX);
final int cellYIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLY);
final int spanXIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.SPANX);
final int spanYIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.SPANY);
final int titleIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.TITLE);
final int intenIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.INTENT);
try {
while (c.moveToNext()) {
ShortcutInfo item = new ShortcutInfo();
item.cellX = c.getInt(cellXIndex);
item.cellY = c.getInt(cellYIndex);
item.spanX = Math.max(1, c.getInt(spanXIndex));
item.spanY = Math.max(1, c.getInt(spanYIndex));
item.container = c.getInt(containerIndex);
item.itemType = c.getInt(itemTypeIndex);
item.screenId = c.getInt(screenIndex);
item.title=c.getString(titleIndex);
if(c.getString(intenIndex)!=null){
item.intent=new Intent(c.getString(intenIndex));
}
items.add(item);
}
} catch (Exception e) {
items.clear();
} finally {
c.close();
}
return items;
}
改动内容同理通过对于的URL进行改动。
详细我就不进行代码编写了。
(8)Launcher3客制化之ContentProvider内容提供者,实现其它应用改动数据库更新等操作的更多相关文章
- (7)Launcher3客制化之,改动单屏幕后,Fix在Hotseat拖动应用删除报错
改动单屏幕后,在workspace里面拖动图标.到删除button上松开的时候,报错问题. 而且无法再次显示拖动的图标. 拖动松开手时候触发 public void onDropCompleted(f ...
- Dynamics AX 2012 R2 客制化RDP报表参数对话框
当我们在使用RDP报表时,AX会根据Data Contract,自动生成报表参数对话框上的字段控件.一般情况下,该对话框能够满足我们的需求,但是如果有较为复杂或特殊的需求,就要我们对该对话框进行客制化 ...
- BEvent_客制化BusinessEvent通过PLSQL Procedurer接受消息传递(案例)
2014-06-27 Created By BaoXinjian
- Form_通过Zoom客制化跳转页面功能(案例)
2012-09-08 Created By BaoXinjian
- 转:FORM:客制化Form的菜单栏和右鍵菜單
Oracle EBS还允许客制化Form的菜单栏. 用户最多可以定义45个form-level的trigger,名称必须为SPECIALn, 其中SPECIAL1 to SPECIAL15属于Tool ...
- Android MTK6580 客制化关机充电动画
1.客制化关机充电图片 vendor/mediatek/proprietary/bootable/bootloader/lk/dev/logo/xxx 找到对应分辨率替换 2.调整显示图片位置.大小 ...
- Android组件系列----ContentProvider内容提供者
[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/4 ...
- android 53 ContentProvider内容提供者
ContentProvider内容提供者:像是一个中间件一样,一个媒介一样,可以以标准的增删改差操作对手机的文件.数据库进行增删改差.通过ContentProvider查找sd卡的音频文件,可以提供标 ...
- contentProvider内容提供者
contentProvider内容提供者 15. 四 / android基础 / 没有评论 步骤 权限在application中注册 Source code <provider an ...
随机推荐
- 四大主流云平台对比--CloudStack, Eucalyptus, vCloud Director和OpenStack。
我迟早可能都要进入的领域,提前温习... 还有KVM,ESXI,API,XEN之间的术语和关系,也要心中有数.. ~~~~~~~~~~~~~~~~~~~ 云计算在如今的IT界一直是一个最热门的话题,鉴 ...
- Altium Designer 特定网络取消 remove loops
在使用Altium Designer时,在PCB Editor 里面可以设定是否需要Automatically remove Loops,但是这个设置是全局的,在设计时难免会遇到对大部分网络是需要删除 ...
- iCloud 包括文稿与数据、日历、提醒事项、 通讯录、备忘录、Safari书签
iCloud 能够为用户在设备间同步数据和在服务器上保存数据.当前 iCloud 包括文稿与数据.日历.提醒事项. 通讯录.备忘录.Safari书签.阅读列表.iCloud Tabs.iBooks书签 ...
- 编译android后找不到ramdisk-u.img[已解决]
--- --- #!/bin/bash OUTDIR=out/target/product/tiny4412AHOSTBIN=out/host/linux-x86/bin # install vend ...
- libvlc 双击,鼠标事件消息响应
基于vlc 2.1 动态库实现接收双击消息的接收,使双击vlc播放画面可以全屏显示. 需要其他版本的vlc可以与我联系(有偿进行修改) 下载地址:http://download.csdn.net/de ...
- 监控Nginx负载均衡器脚本
1.编写脚本 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 vim nginx_pid.sh #!/bin/bash while : do nginxpid=`ps -C ...
- Sublime Text 插件 autoprefixer
Sublime Text 早就有插件(Sublime Prefixr)使用 prefixr 的 API 来自动完成 CSS 前缀,但是 autoprefixer 更牛,这款可使用 Can I Use ...
- Hadoop中两表JOIN的处理方法
Dong的这篇博客我觉得把原理写的很详细,同时介绍了一些优化办法,利用二次排序或者布隆过滤器,但在之前实践中我并没有在join中用二者来优化,因为我不是作join优化的,而是做单纯的倾斜处理,做joi ...
- [Hadoop源码解读](二)MapReduce篇之Mapper类
前面在讲InputFormat的时候,讲到了Mapper类是如何利用RecordReader来读取InputSplit中的K-V对的. 这一篇里,开始对Mapper.class的子类进行解读. 先回忆 ...
- ☀【JS】检测属性
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8& ...