// to create live folder on "home" screen

Java代码  
  1. if (LiveFolders.ACTION_CREATE_LIVE_FOLDER.equalsIgnoreCase(getIntent().getAction())) {
  2. tent().getAction() can be null
  3. Intent intent = new Intent();
  4. Uri LIVE_FOLDER_URI = Uri.parse("content://contacts/live_folders/people");
  5. intent.setData(LIVE_FOLDER_URI);
  6. intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_BASE_INTENT, new Intent(
  7. Intent.ACTION_VIEW, Contacts.People.CONTENT_URI));
  8. intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_NAME, "allnamefolder");
  9. intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_ICON, Intent.ShortcutIconResource
  10. .fromContext(this, R.drawable.krec));
  11. intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_DISPLAY_MODE,
  12. LiveFolders.DISPLAY_MODE_GRID);
  13. this.setResult(RESULT_OK, intent);
  14. } else {
  15. this.setResult(Activity.RESULT_CANCELED);
  16. }
[java] view plaincopy
  1. if (LiveFolders.ACTION_CREATE_LIVE_FOLDER.equalsIgnoreCase(getIntent().getAction())) {
  2. tent().getAction() can be null
  3. Intent intent = new Intent();
  4. Uri LIVE_FOLDER_URI = Uri.parse("content://contacts/live_folders/people");
  5. intent.setData(LIVE_FOLDER_URI);
  6. intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_BASE_INTENT, new Intent(
  7. Intent.ACTION_VIEW, Contacts.People.CONTENT_URI));
  8. intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_NAME, "allnamefolder");
  9. intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_ICON, Intent.ShortcutIconResource
  10. .fromContext(this, R.drawable.krec));
  11. intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_DISPLAY_MODE,
  12. LiveFolders.DISPLAY_MODE_GRID);
  13. this.setResult(RESULT_OK, intent);
  14. } else {
  15. this.setResult(Activity.RESULT_CANCELED);
  16. }

// to create shortcut on "home" screen 
// toPrint is a very simple apk.

Java代码  
  1. Intent toPrint = new Intent(this, anSimplePrint.class);
  2. Intent addShortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
  3. addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, "SP");
  4. addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, toPrint);
  5. addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource
  6. .fromContext(this, R.drawable.ksig));
[java] view plaincopy
  1. Intent toPrint = new Intent(this, anSimplePrint.class);
  2. Intent addShortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
  3. addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, "SP");
  4. addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, toPrint);
  5. addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource
  6. .fromContext(this, R.drawable.ksig));

//remember to fix manifest file 
// add .

Java代码  
  1. <intent-filter>
  2. <action android:name="android.intent.action.CREATE_SHORTCUT" />
  3. <category android:name="android.intent.category.LAUNCHER" />
  4. </intent-filter>
  5. <intent-filter>
  6. <action android:name="android.intent.action.CREATE_LIVE_FOLDER" />
  7. <category android:name="android.intent.category.LAUNCHER" />
  8. </intent-filter>
  9. <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"></uses-permission>
[java] view plaincopy
  1. <intent-filter>
  2. <action android:name="android.intent.action.CREATE_SHORTCUT" />
  3. <category android:name="android.intent.category.LAUNCHER" />
  4. </intent-filter>
  5. <intent-filter>
  6. <action android:name="android.intent.action.CREATE_LIVE_FOLDER" />
  7. <category android:name="android.intent.category.LAUNCHER" />
  8. </intent-filter>
  9. <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"></uses-permission>

/// 
// 系统的contacts 在桌面livefolder添加快捷方式的代码如下。想要在livefolder中添加// 其他app的快捷方式,也可以依法炮制

Java代码  
  1. public class ContactsLiveFolders {
  2. public static class StarredContacts extends Activity {
  3. public static final Uri CONTENT_URI =
  4. Uri.parse("content://contacts/live_folders/favorites");
  5. @Override
  6. protected void onCreate(Bundle savedInstanceState) {
  7. super.onCreate(savedInstanceState);
  8. final Intent intent = getIntent();
  9. final String action = intent.getAction();
  10. if (LiveFolders.ACTION_CREATE_LIVE_FOLDER.equals(action)) {
  11. setResult(RESULT_OK, createLiveFolder(this, CONTENT_URI,
  12. getString(R.string.liveFolder_favorites_label),
  13. R.drawable.ic_launcher_folder_live_contacts_starred));
  14. } else {
  15. setResult(RESULT_CANCELED);
  16. }
  17. finish();
  18. }
  19. }
  20. public static class PhoneContacts extends Activity {
  21. public static final Uri CONTENT_URI =
  22. Uri.parse("content://contacts/live_folders/people_with_phones");
  23. @Override
  24. protected void onCreate(Bundle savedInstanceState) {
  25. super.onCreate(savedInstanceState);
  26. final Intent intent = getIntent();
  27. final String action = intent.getAction();
  28. if (LiveFolders.ACTION_CREATE_LIVE_FOLDER.equals(action)) {
  29. setResult(RESULT_OK, createLiveFolder(this, CONTENT_URI,
  30. getString(R.string.liveFolder_phones_label),
  31. R.drawable.ic_launcher_folder_live_contacts_phone));
  32. } else {
  33. setResult(RESULT_CANCELED);
  34. }
  35. finish();
  36. }
  37. }
  38. public static class AllContacts extends Activity {
  39. public static final Uri CONTENT_URI =
  40. Uri.parse("content://contacts/live_folders/people");
  41. @Override
  42. protected void onCreate(Bundle savedInstanceState) {
  43. super.onCreate(savedInstanceState);
  44. final Intent intent = getIntent();
  45. final String action = intent.getAction();
  46. if (LiveFolders.ACTION_CREATE_LIVE_FOLDER.equals(action)) {
  47. setResult(RESULT_OK, createLiveFolder(this, CONTENT_URI,
  48. getString(R.string.liveFolder_all_label),
  49. R.drawable.ic_launcher_folder_live_contacts));
  50. } else {
  51. setResult(RESULT_CANCELED);
  52. }
  53. finish();
  54. }
  55. }
  56. private static Intent createLiveFolder(Context context, Uri uri, String name,
  57. int icon) {
  58. final Intent intent = new Intent();
  59. intent.setData(uri);
  60. intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_BASE_INTENT,
  61. new Intent(Intent.ACTION_VIEW, Contacts.CONTENT_URI));
  62. intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_NAME, name);
  63. intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_ICON,
  64. Intent.ShortcutIconResource.fromContext(context, icon));
  65. intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_DISPLAY_MODE, LiveFolders.DISPLAY_MODE_LIST);
  66. return intent;
  67. }
  68. }
[java] view plaincopy
  1. public class ContactsLiveFolders {
  2. public static class StarredContacts extends Activity {
  3. public static final Uri CONTENT_URI =
  4. Uri.parse("content://contacts/live_folders/favorites");
  5. @Override
  6. protected void onCreate(Bundle savedInstanceState) {
  7. super.onCreate(savedInstanceState);
  8. final Intent intent = getIntent();
  9. final String action = intent.getAction();
  10. if (LiveFolders.ACTION_CREATE_LIVE_FOLDER.equals(action)) {
  11. setResult(RESULT_OK, createLiveFolder(this, CONTENT_URI,
  12. getString(R.string.liveFolder_favorites_label),
  13. R.drawable.ic_launcher_folder_live_contacts_starred));
  14. } else {
  15. setResult(RESULT_CANCELED);
  16. }
  17. finish();
  18. }
  19. }
  20. public static class PhoneContacts extends Activity {
  21. public static final Uri CONTENT_URI =
  22. Uri.parse("content://contacts/live_folders/people_with_phones");
  23. @Override
  24. protected void onCreate(Bundle savedInstanceState) {
  25. super.onCreate(savedInstanceState);
  26. final Intent intent = getIntent();
  27. final String action = intent.getAction();
  28. if (LiveFolders.ACTION_CREATE_LIVE_FOLDER.equals(action)) {
  29. setResult(RESULT_OK, createLiveFolder(this, CONTENT_URI,
  30. getString(R.string.liveFolder_phones_label),
  31. R.drawable.ic_launcher_folder_live_contacts_phone));
  32. } else {
  33. setResult(RESULT_CANCELED);
  34. }
  35. finish();
  36. }
  37. }
  38. public static class AllContacts extends Activity {
  39. public static final Uri CONTENT_URI =
  40. Uri.parse("content://contacts/live_folders/people");
  41. @Override
  42. protected void onCreate(Bundle savedInstanceState) {
  43. super.onCreate(savedInstanceState);
  44. final Intent intent = getIntent();
  45. final String action = intent.getAction();
  46. if (LiveFolders.ACTION_CREATE_LIVE_FOLDER.equals(action)) {
  47. setResult(RESULT_OK, createLiveFolder(this, CONTENT_URI,
  48. getString(R.string.liveFolder_all_label),
  49. R.drawable.ic_launcher_folder_live_contacts));
  50. } else {
  51. setResult(RESULT_CANCELED);
  52. }
  53. finish();
  54. }
  55. }
  56. private static Intent createLiveFolder(Context context, Uri uri, String name,
  57. int icon) {
  58. final Intent intent = new Intent();
  59. intent.setData(uri);
  60. intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_BASE_INTENT,
  61. new Intent(Intent.ACTION_VIEW, Contacts.CONTENT_URI));
  62. intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_NAME, name);
  63. intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_ICON,
  64. Intent.ShortcutIconResource.fromContext(context, icon));
  65. intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_DISPLAY_MODE, LiveFolders.DISPLAY_MODE_LIST);
  66. return intent;
  67. }
  68. }

//

Java代码  
  1. intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_BASE_INTENT,
  2. new Intent(Intent.ACTION_VIEW, Contacts.CONTENT_URI));
  3. 这个在用的时候。 如果你用的uri读出来没有一个叫name的表项,
  4. 那这个ACTION_VIEW会失败,所以需要有个叫name的,作为livefolder显示出来的东西。
  5. 比如系统的contactsprovider 里面  大概3790行
  6. case LIVE_FOLDERS_CONTACTS_GROUP_NAME:
  7. qb.setTables(mDbHelper.getContactView());
  8. qb.setProjectionMap(sLiveFoldersProjectionMap);
  9. qb.appendWhere(CONTACTS_IN_GROUP_SELECT);
  10. selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());
  11. break;
  12. 这里qb.setProjectionMap(sLiveFoldersProjectionMap); 就是把有一个项作为name显示
  13. //contactsProvider2.java line 854
  14. sLiveFoldersProjectionMap = new HashMap<String, String>();
  15. sLiveFoldersProjectionMap.put(LiveFolders._ID,
  16. Contacts._ID + " AS " + LiveFolders._ID);
  17. sLiveFoldersProjectionMap.put(LiveFolders.NAME,
  18. Contacts.DISPLAY_NAME + " AS " + LiveFolders.NAME);
[java] view plaincopy
  1. intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_BASE_INTENT,
  2. new Intent(Intent.ACTION_VIEW, Contacts.CONTENT_URI));
  3. 这个在用的时候。 如果你用的uri读出来没有一个叫name的表项,
  4. 那这个ACTION_VIEW会失败,所以需要有个叫name的,作为livefolder显示出来的东西。
  5. 比如系统的contactsprovider 里面  大概3790行
  6. case LIVE_FOLDERS_CONTACTS_GROUP_NAME:
  7. qb.setTables(mDbHelper.getContactView());
  8. qb.setProjectionMap(sLiveFoldersProjectionMap);
  9. qb.appendWhere(CONTACTS_IN_GROUP_SELECT);
  10. selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());
  11. break;
  12. 这里qb.setProjectionMap(sLiveFoldersProjectionMap); 就是把有一个项作为name显示
  13. //contactsProvider2.java line 854
  14. sLiveFoldersProjectionMap = new HashMap<String, String>();
  15. sLiveFoldersProjectionMap.put(LiveFolders._ID,
  16. Contacts._ID + " AS " + LiveFolders._ID);
  17. sLiveFoldersProjectionMap.put(LiveFolders.NAME,
  18. Contacts.DISPLAY_NAME + " AS " + LiveFolders.NAME);

自己实现一contentprovider来做这个事情的时候也需要实现一个 name作为显示, 
即在cursor query的时候加入比如select xxx as name, 在projection里加。 
说不清了。。。 
//一般还是不要自己造contentprovider了。。 系统的差不多够用 
//问题是怎么在系统里找到所有的uri? 嘿嘿。我不会- -

这里转个大大的博克 
http://kuikui.iteye.com/blog/318627 
刚起步的时候经常困扰我们的是一些本来容易解决的问题,往往我们会花掉很大的力气去找解决的办法,最后才知道原来这么简单,这就是英文世界造成的。

Intent在 Android应用开发中,占有很大的分量,关于Intent在Android中的作用在网络上已经有很多资料了,这里不再累赘,本人喜欢直来直去。在网上看到很多关于Intent的资料,说那么多,你也许还是一头雾水,到底如何使用Intent呢?这里总结一些重用的Intent使用,仅供参考。

下面直接给我学习的实例片段。

1,掉web浏览器

Uri myBlogUri = Uri.parse("http://kuikui.iteye.com");

returnIt = new Intent(Intent.ACTION_VIEW, myBlogUri);

2,地图

Uri mapUri = Uri.parse("geo:38.899533,-77.036476");

returnIt = new Intent(Intent.ACTION_VIEW, mapUri);

3,调拨打电话界面

Uri telUri = Uri.parse("tel:100861");

returnIt = new Intent(Intent.ACTION_DIAL, telUri);

4,直接拨打电话

Uri callUri = Uri.parse("tel:100861");

returnIt = new Intent(Intent.ACTION_CALL, callUri);

5,卸载

Uri uninstallUri = Uri.fromParts("package", "xxx", null);

returnIt = new Intent(Intent.ACTION_DELETE, uninstallUri);

6,安装

Uri installUri = Uri.fromParts("package", "xxx", null);

returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);

7,播放

Uri playUri = Uri.parse("file:///sdcard/download/everything.mp3");

returnIt = new Intent(Intent.ACTION_VIEW, playUri);

8,掉用发邮件

Uri emailUri = Uri.parse("mailto:shenrenkui@gmail.com");

returnIt = new Intent(Intent.ACTION_SENDTO, emailUri);

9,发邮件

returnIt = new Intent(Intent.ACTION_SEND);

String[] tos = { "shenrenkui@gmail.com" };

String[] ccs = { "shenrenkui@gmail.com" };

returnIt.putExtra(Intent.EXTRA_EMAIL, tos);

returnIt.putExtra(Intent.EXTRA_CC, ccs);

returnIt.putExtra(Intent.EXTRA_TEXT, "body");

returnIt.putExtra(Intent.EXTRA_SUBJECT, "subject");

returnIt.setType("message/rfc882");

Intent.createChooser(returnIt, "Choose Email Client");

10,发短信

Uri smsUri = Uri.parse("tel:100861");

returnIt = new Intent(Intent.ACTION_VIEW, smsUri);

returnIt.putExtra("sms_body", "shenrenkui");

returnIt.setType("vnd.android-dir/mms-sms");

11,直接发邮件

Uri smsToUri = Uri.parse("smsto://100861");

returnIt = new Intent(Intent.ACTION_SENDTO, smsToUri);

returnIt.putExtra("sms_body", "shenrenkui");

12,发彩信

Uri mmsUri = Uri.parse("content://media/external/images/media/23");

returnIt = new Intent(Intent.ACTION_SEND);

returnIt.putExtra("sms_body", "shenrenkui");

returnIt.putExtra(Intent.EXTRA_STREAM, mmsUri);

returnIt.setType("image/png");

用获取到的Intent直接调用startActivity(returnIt)就ok了

转载于:https://www.cnblogs.com/greywolf/archive/2012/12/24/2831344.html

桌面快捷键和桌面livefolder相关推荐

  1. cenos回到linux桌面快捷键,Centos桌面 快捷键

    最近常常使用Centos桌面,下面介绍一些常用的快捷键 * 打开主菜单 = Alt + F1 * 运行 = Alt + F2 * 显示桌面 = Ctrl + Alt + d * 最小化当前窗口 = A ...

  2. win7计算机桌面快捷键显示桌面,【显示桌面快捷键 win7】显示桌面的快捷键是_win7返回桌面快捷键-系统城...

    2018-01-19 13:49:19 浏览量:4649 在使用windowsxp系统过程中,一位用户发现电脑桌面左下角的显示桌面图标消失不见了,感觉非常烦恼.那么,我们要如何恢复它呢?若是不恢复又有 ...

  3. Mac快速显示桌面快捷键

    Mac快速显示桌面快捷键 在Mac系统中,有时候打开的程序多了,想退回桌面,要一个一个的将窗口小化 今天无意中发现了一个快捷键,可以直接显示到桌面: 普通键盘按 F11 Mac笔记本键盘按  fn(左 ...

  4. [Fedora 20] 设置Terminal快捷键 + 设置桌面快捷方式 + Terminal透明解决方案

    [Fedora 20] 设置Terminal快捷键 + 设置桌面快捷方式 + Terminal透明解决方案 参考文章: (1)[Fedora 20] 设置Terminal快捷键 + 设置桌面快捷方式 ...

  5. win11怎么快速返回桌面 windows11快捷键返回桌面的设置方法

    有时候我们在win11系统上全屏玩游戏时要怎么快速回到桌面呢?可能很多小伙伴都不知道如何操作,那么下面小编就来跟大家说说win11快捷键返回桌面是哪个的介绍,还有不懂的可以来看看这篇教程,更多wind ...

  6. linux切换桌面的快捷键,SUSE Linux Gnome桌面快捷键整理

    整理了一些常用的SUSE Linux Gnome桌面快捷键,希望对大家有用! 快捷键 ctrl+shift+f (窗口全屏) ctrl+shift+n (新建konsole窗口) ctrl+shift ...

  7. 计算机快捷键如何移动到桌面,如何设置显示桌面快捷键 设置显示桌面快捷键方法【图文】...

    显示桌面图标快捷方式是Windows系统中一个非常实用的功能,当我们使用的电脑时间比较长之后就会有很多软件程序窗口开着,占满了电脑的整个屏幕,您只要点击一下电脑左下角的显示桌面图标就能回到桌面.但是有 ...

  8. 计算机快捷键里面不显示桌面,桌面显示,显示桌面快捷键不见了

    我们通常在使用电脑的时候,都不会只打开一个窗口,我们会使用很多功能同时运行,比如我们可以边聊QQ,边看电影;也可以边听歌儿变上网购物. 所以这时候,就要用到最小化来显示出桌面. 但是如果对这些程序一一 ...

  9. 计算机怎么一键到桌面快捷键,关于添加一键返回桌面快捷键在win10电脑中的技巧...

    我们在win10系统的操作中,对于电脑中需要操作到多个窗口和页面的情况是很多的,那有小伙伴在网络上提问不知道是不是可以添加一个返回桌面快捷键的情况,我们在win10电脑中打开的程序很多的话切换窗口也就 ...

最新文章

  1. JAVA面试题(2)
  2. css 在线生成器,CSS Sprites在线生成器
  3. wsl for pycharm vscode
  4. 关于开源软件的书籍一定要尽量提供搭配好的软件版本
  5. 转:认识cpu、核与线程
  6. java8 日期api_我们多么想要新的Java日期/时间API?
  7. python漏洞检测脚本_URL重定向漏洞,python打造URL重定向漏洞检测脚本
  8. 关于iOS7里的JavaScriptCore framework
  9. 高效测试必学 | 用pytest生成测试报告
  10. 73.fseek与宽字符读取文件
  11. 深度学习pytorch基础入门教程(1小时)-张量、操作、转换
  12. 360linux如何卸载,卸载360安全卫士方法
  13. Linux下用ffmpeg轉PSP影片 (MP4/AVC格式)
  14. UART串口协议时序图
  15. 全球及中国布鲁顿酪氨酸蛋白激酶抑制剂行业研究及十四五规划分析报告
  16. 给你一个二维整数数组 matrix,返回 matrix 的 转置矩阵
  17. java模拟微信抢红包金额算法规则二倍均值法模拟(满满的注释)
  18. 掘金mysql_我的 mysql 半年小得 | 掘金征文
  19. easyui复杂表单_jQuery EasyUI 表单 – 创建树形下拉框(ComboTree) | 菜鸟教程
  20. 为泰泽铺路, Intel宣布32nm Atom正式出货 规格详解

热门文章

  1. VTK:图片之ImageMagnify
  2. OpenCV iOS-视频处理
  3. C++ Opengl 绘制纹理字符源码
  4. C++STL的 list容器
  5. c++访问者模式visitor
  6. 经典C语言程序100例之九五
  7. C++变量、函数在内存中的情况
  8. snmp linux arm,Net-SNMP的交叉编译 for ARM64
  9. 「ProtocolBuffers2」ProtocolBuffers2 Python简易入门
  10. 远程拷贝、查看端口、vim常见快捷键、查找替换命令、grep命令、查看存储空间的命令、chkconfig命令、系统自动启动级别、主机名配置、IP地址配置、域名映射、防火墙设置