判斷快捷方式是否已經建立,快捷方式訊息是儲存在com.android.launcher的launcher.db的favorites表中,

java程式碼:

  1. boolean isInstallShortcut = false ;
  2. final ContentResolver cr = context.getContentResolver();
  3. final String AUTHORITY = "com.android.launcher.settings";
  4. final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/favorites?notify=true");
  5. Cursor c = cr.query(CONTENT_URI, new String[] {"title","iconResource" }, "title=?",
  6. new String[] {"XXX" }, null);//XXX表示應用名稱。
  7. if(c!=null && c.getCount()>0){
  8. isInstallShortcut = true ;
  9. }
  10. /*try {
  11. while (c.moveToNext()) {
  12. String tmp = "";
  13. tmp = c.getString(0);
  14. }
  15. } catch (Exception e) {
  16. } finally {
  17. c.close();
  18. }*/
  19. return isInstallShortcut ;
  20. }
arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()