日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

桌面快捷键和桌面livefolder

發布時間:2024/9/20 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 桌面快捷键和桌面livefolder 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?// to create live folder on "home" screen?

Java代碼??
  • if?(LiveFolders.ACTION_CREATE_LIVE_FOLDER.equalsIgnoreCase(getIntent().getAction()))?{ ??
  • tent().getAction()?can?be?null??
  • ????Intent?intent?=?new?Intent(); ??
  • ????Uri?LIVE_FOLDER_URI?=?Uri.parse("content://contacts/live_folders/people"); ??
  • ????intent.setData(LIVE_FOLDER_URI); ??
  • ????intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_BASE_INTENT,?new?Intent( ??
  • ????????????Intent.ACTION_VIEW,?Contacts.People.CONTENT_URI)); ??
  • ????intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_NAME,?"allnamefolder"); ??
  • ????intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_ICON,?Intent.ShortcutIconResource ??
  • ????????????.fromContext(this,?R.drawable.krec)); ??
  • ????intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_DISPLAY_MODE, ??
  • ????????????LiveFolders.DISPLAY_MODE_GRID); ??
  • ????this.setResult(RESULT_OK,?intent); ??
  • ??
  • }?else?{ ??
  • ????this.setResult(Activity.RESULT_CANCELED); ??
  • }??
  • [java]?view plaincopy
  • if?(LiveFolders.ACTION_CREATE_LIVE_FOLDER.equalsIgnoreCase(getIntent().getAction()))?{??
  • tent().getAction()?can?be?null??
  • ????Intent?intent?=?new?Intent();??
  • ????Uri?LIVE_FOLDER_URI?=?Uri.parse("content://contacts/live_folders/people");??
  • ????intent.setData(LIVE_FOLDER_URI);??
  • ????intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_BASE_INTENT,?new?Intent(??
  • ????????????Intent.ACTION_VIEW,?Contacts.People.CONTENT_URI));??
  • ????intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_NAME,?"allnamefolder");??
  • ????intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_ICON,?Intent.ShortcutIconResource??
  • ????????????.fromContext(this,?R.drawable.krec));??
  • ????intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_DISPLAY_MODE,??
  • ????????????LiveFolders.DISPLAY_MODE_GRID);??
  • ????this.setResult(RESULT_OK,?intent);??
  • ??
  • }?else?{??
  • ????this.setResult(Activity.RESULT_CANCELED);??
  • }??




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

    Java代碼??
  • Intent?toPrint?=?new?Intent(this,?anSimplePrint.class); ??
  • ??
  • Intent?addShortcut?=?new?Intent("com.android.launcher.action.INSTALL_SHORTCUT"); ??
  • addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,?"SP"); ??
  • addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT,?toPrint); ??
  • addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,?Intent.ShortcutIconResource ??
  • ????????.fromContext(this,?R.drawable.ksig));??
  • [java]?view plaincopy
  • Intent?toPrint?=?new?Intent(this,?anSimplePrint.class);??
  • ??
  • Intent?addShortcut?=?new?Intent("com.android.launcher.action.INSTALL_SHORTCUT");??
  • addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,?"SP");??
  • addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT,?toPrint);??
  • addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,?Intent.ShortcutIconResource??
  • ????????.fromContext(this,?R.drawable.ksig));??

  • //remember to fix manifest file?
    // add .?

    Java代碼??
  • ????????<intent-filter> ??
  • ????????????<action?android:name="android.intent.action.CREATE_SHORTCUT"?/> ??
  • ????????????<category?android:name="android.intent.category.LAUNCHER"?/> ??
  • ????????</intent-filter> ??
  • ????????<intent-filter> ??
  • ????????????<action?android:name="android.intent.action.CREATE_LIVE_FOLDER"?/> ??
  • ????????????<category?android:name="android.intent.category.LAUNCHER"?/> ??
  • ????????</intent-filter> ??
  • ??
  • ??
  • <uses-permission?android:name="com.android.launcher.permission.INSTALL_SHORTCUT"></uses-permission>??
  • [java]?view plaincopy
  • ????????<intent-filter>??
  • ????????????<action?android:name="android.intent.action.CREATE_SHORTCUT"?/>??
  • ????????????<category?android:name="android.intent.category.LAUNCHER"?/>??
  • ????????</intent-filter>??
  • ????????<intent-filter>??
  • ????????????<action?android:name="android.intent.action.CREATE_LIVE_FOLDER"?/>??
  • ????????????<category?android:name="android.intent.category.LAUNCHER"?/>??
  • ????????</intent-filter>??
  • ??
  • ??
  • <uses-permission?android:name="com.android.launcher.permission.INSTALL_SHORTCUT"></uses-permission>??



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

    Java代碼??
  • public?class?ContactsLiveFolders?{ ??
  • ????public?static?class?StarredContacts?extends?Activity?{ ??
  • ????????public?static?final?Uri?CONTENT_URI?= ??
  • ????????????????Uri.parse("content://contacts/live_folders/favorites"); ??
  • ??
  • ????????@Override??
  • ????????protected?void?onCreate(Bundle?savedInstanceState)?{ ??
  • ????????????super.onCreate(savedInstanceState); ??
  • ??
  • ????????????final?Intent?intent?=?getIntent(); ??
  • ????????????final?String?action?=?intent.getAction(); ??
  • ??
  • ????????????if?(LiveFolders.ACTION_CREATE_LIVE_FOLDER.equals(action))?{ ??
  • ????????????????setResult(RESULT_OK,?createLiveFolder(this,?CONTENT_URI, ??
  • ????????????????????????getString(R.string.liveFolder_favorites_label), ??
  • ????????????????????????R.drawable.ic_launcher_folder_live_contacts_starred)); ??
  • ????????????}?else?{ ??
  • ????????????????setResult(RESULT_CANCELED); ??
  • ????????????} ??
  • ??
  • ????????????finish(); ??
  • ????????} ??
  • ????} ??
  • ??
  • ????public?static?class?PhoneContacts?extends?Activity?{ ??
  • ????????public?static?final?Uri?CONTENT_URI?= ??
  • ????????????????Uri.parse("content://contacts/live_folders/people_with_phones"); ??
  • ??
  • ????????@Override??
  • ????????protected?void?onCreate(Bundle?savedInstanceState)?{ ??
  • ????????????super.onCreate(savedInstanceState); ??
  • ??
  • ????????????final?Intent?intent?=?getIntent(); ??
  • ????????????final?String?action?=?intent.getAction(); ??
  • ??
  • ????????????if?(LiveFolders.ACTION_CREATE_LIVE_FOLDER.equals(action))?{ ??
  • ????????????????setResult(RESULT_OK,?createLiveFolder(this,?CONTENT_URI, ??
  • ????????????????????????getString(R.string.liveFolder_phones_label), ??
  • ????????????????????????R.drawable.ic_launcher_folder_live_contacts_phone)); ??
  • ????????????}?else?{ ??
  • ????????????????setResult(RESULT_CANCELED); ??
  • ????????????} ??
  • ??
  • ????????????finish(); ??
  • ????????} ??
  • ????} ??
  • ??
  • ????public?static?class?AllContacts?extends?Activity?{ ??
  • ????????public?static?final?Uri?CONTENT_URI?= ??
  • ????????????????Uri.parse("content://contacts/live_folders/people"); ??
  • ??
  • ????????@Override??
  • ????????protected?void?onCreate(Bundle?savedInstanceState)?{ ??
  • ????????????super.onCreate(savedInstanceState); ??
  • ??
  • ????????????final?Intent?intent?=?getIntent(); ??
  • ????????????final?String?action?=?intent.getAction(); ??
  • ??
  • ????????????if?(LiveFolders.ACTION_CREATE_LIVE_FOLDER.equals(action))?{ ??
  • ????????????????setResult(RESULT_OK,?createLiveFolder(this,?CONTENT_URI, ??
  • ????????????????????????getString(R.string.liveFolder_all_label), ??
  • ????????????????????????R.drawable.ic_launcher_folder_live_contacts)); ??
  • ????????????}?else?{ ??
  • ????????????????setResult(RESULT_CANCELED); ??
  • ????????????} ??
  • ??
  • ????????????finish(); ??
  • ????????} ??
  • ????} ??
  • ??
  • ????private?static?Intent?createLiveFolder(Context?context,?Uri?uri,?String?name, ??
  • ????????????int?icon)?{ ??
  • ??
  • ????????final?Intent?intent?=?new?Intent(); ??
  • ??
  • ????????intent.setData(uri); ??
  • ????????intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_BASE_INTENT, ??
  • ????????????????new?Intent(Intent.ACTION_VIEW,?Contacts.CONTENT_URI)); ??
  • ????????intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_NAME,?name); ??
  • ????????intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_ICON, ??
  • ????????????????Intent.ShortcutIconResource.fromContext(context,?icon)); ??
  • ????????intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_DISPLAY_MODE,?LiveFolders.DISPLAY_MODE_LIST); ??
  • ??
  • ????????return?intent; ??
  • ????} ??
  • }??
  • [java]?view plaincopy
  • public?class?ContactsLiveFolders?{??
  • ????public?static?class?StarredContacts?extends?Activity?{??
  • ????????public?static?final?Uri?CONTENT_URI?=??
  • ????????????????Uri.parse("content://contacts/live_folders/favorites");??
  • ??
  • ????????@Override??
  • ????????protected?void?onCreate(Bundle?savedInstanceState)?{??
  • ????????????super.onCreate(savedInstanceState);??
  • ??
  • ????????????final?Intent?intent?=?getIntent();??
  • ????????????final?String?action?=?intent.getAction();??
  • ??
  • ????????????if?(LiveFolders.ACTION_CREATE_LIVE_FOLDER.equals(action))?{??
  • ????????????????setResult(RESULT_OK,?createLiveFolder(this,?CONTENT_URI,??
  • ????????????????????????getString(R.string.liveFolder_favorites_label),??
  • ????????????????????????R.drawable.ic_launcher_folder_live_contacts_starred));??
  • ????????????}?else?{??
  • ????????????????setResult(RESULT_CANCELED);??
  • ????????????}??
  • ??
  • ????????????finish();??
  • ????????}??
  • ????}??
  • ??
  • ????public?static?class?PhoneContacts?extends?Activity?{??
  • ????????public?static?final?Uri?CONTENT_URI?=??
  • ????????????????Uri.parse("content://contacts/live_folders/people_with_phones");??
  • ??
  • ????????@Override??
  • ????????protected?void?onCreate(Bundle?savedInstanceState)?{??
  • ????????????super.onCreate(savedInstanceState);??
  • ??
  • ????????????final?Intent?intent?=?getIntent();??
  • ????????????final?String?action?=?intent.getAction();??
  • ??
  • ????????????if?(LiveFolders.ACTION_CREATE_LIVE_FOLDER.equals(action))?{??
  • ????????????????setResult(RESULT_OK,?createLiveFolder(this,?CONTENT_URI,??
  • ????????????????????????getString(R.string.liveFolder_phones_label),??
  • ????????????????????????R.drawable.ic_launcher_folder_live_contacts_phone));??
  • ????????????}?else?{??
  • ????????????????setResult(RESULT_CANCELED);??
  • ????????????}??
  • ??
  • ????????????finish();??
  • ????????}??
  • ????}??
  • ??
  • ????public?static?class?AllContacts?extends?Activity?{??
  • ????????public?static?final?Uri?CONTENT_URI?=??
  • ????????????????Uri.parse("content://contacts/live_folders/people");??
  • ??
  • ????????@Override??
  • ????????protected?void?onCreate(Bundle?savedInstanceState)?{??
  • ????????????super.onCreate(savedInstanceState);??
  • ??
  • ????????????final?Intent?intent?=?getIntent();??
  • ????????????final?String?action?=?intent.getAction();??
  • ??
  • ????????????if?(LiveFolders.ACTION_CREATE_LIVE_FOLDER.equals(action))?{??
  • ????????????????setResult(RESULT_OK,?createLiveFolder(this,?CONTENT_URI,??
  • ????????????????????????getString(R.string.liveFolder_all_label),??
  • ????????????????????????R.drawable.ic_launcher_folder_live_contacts));??
  • ????????????}?else?{??
  • ????????????????setResult(RESULT_CANCELED);??
  • ????????????}??
  • ??
  • ????????????finish();??
  • ????????}??
  • ????}??
  • ??
  • ????private?static?Intent?createLiveFolder(Context?context,?Uri?uri,?String?name,??
  • ????????????int?icon)?{??
  • ??
  • ????????final?Intent?intent?=?new?Intent();??
  • ??
  • ????????intent.setData(uri);??
  • ????????intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_BASE_INTENT,??
  • ????????????????new?Intent(Intent.ACTION_VIEW,?Contacts.CONTENT_URI));??
  • ????????intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_NAME,?name);??
  • ????????intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_ICON,??
  • ????????????????Intent.ShortcutIconResource.fromContext(context,?icon));??
  • ????????intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_DISPLAY_MODE,?LiveFolders.DISPLAY_MODE_LIST);??
  • ??
  • ????????return?intent;??
  • ????}??
  • }??

  • ?
    //?

    Java代碼??
  • ????????intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_BASE_INTENT, ??
  • ????????????????new?Intent(Intent.ACTION_VIEW,?Contacts.CONTENT_URI)); ??
  • 這個在用的時候。?如果你用的uri讀出來沒有一個叫name的表項, ??
  • 那這個ACTION_VIEW會失敗,所以需要有個叫name的,作為livefolder顯示出來的東西。 ??
  • ??
  • 比如系統的contactsprovider?里面??大概3790行 ??
  • ????????????case?LIVE_FOLDERS_CONTACTS_GROUP_NAME: ??
  • ????????????????qb.setTables(mDbHelper.getContactView()); ??
  • ????????????????qb.setProjectionMap(sLiveFoldersProjectionMap); ??
  • ????????????????qb.appendWhere(CONTACTS_IN_GROUP_SELECT); ??
  • ????????????????selectionArgs?=?insertSelectionArg(selectionArgs,?uri.getLastPathSegment()); ??
  • ????????????????break; ??
  • ??
  • 這里qb.setProjectionMap(sLiveFoldersProjectionMap);?就是把有一個項作為name顯示 ??
  • //contactsProvider2.java?line?854????
  • ???????sLiveFoldersProjectionMap?=?new?HashMap<String,?String>(); ??
  • ????????sLiveFoldersProjectionMap.put(LiveFolders._ID, ??
  • ????????????????Contacts._ID?+?"?AS?"?+?LiveFolders._ID); ??
  • ????????sLiveFoldersProjectionMap.put(LiveFolders.NAME, ??
  • ????????????????Contacts.DISPLAY_NAME?+?"?AS?"?+?LiveFolders.NAME);??
  • [java]?view plaincopy
  • ????????intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_BASE_INTENT,??
  • ????????????????new?Intent(Intent.ACTION_VIEW,?Contacts.CONTENT_URI));??
  • 這個在用的時候。?如果你用的uri讀出來沒有一個叫name的表項,??
  • 那這個ACTION_VIEW會失敗,所以需要有個叫name的,作為livefolder顯示出來的東西。??
  • ??
  • 比如系統的contactsprovider?里面??大概3790行??
  • ????????????case?LIVE_FOLDERS_CONTACTS_GROUP_NAME:??
  • ????????????????qb.setTables(mDbHelper.getContactView());??
  • ????????????????qb.setProjectionMap(sLiveFoldersProjectionMap);??
  • ????????????????qb.appendWhere(CONTACTS_IN_GROUP_SELECT);??
  • ????????????????selectionArgs?=?insertSelectionArg(selectionArgs,?uri.getLastPathSegment());??
  • ????????????????break;??
  • ??
  • 這里qb.setProjectionMap(sLiveFoldersProjectionMap);?就是把有一個項作為name顯示??
  • //contactsProvider2.java?line?854???
  • ???????sLiveFoldersProjectionMap?=?new?HashMap<String,?String>();??
  • ????????sLiveFoldersProjectionMap.put(LiveFolders._ID,??
  • ????????????????Contacts._ID?+?"?AS?"?+?LiveFolders._ID);??
  • ????????sLiveFoldersProjectionMap.put(LiveFolders.NAME,??
  • ????????????????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的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。