判斷快捷方式是否已經建立,快捷方式訊息是儲存在com.android.launcher的launcher.db的favorites表中,
java程式碼:
- boolean isInstallShortcut = false ;
- final ContentResolver cr = context.getContentResolver();
- final String AUTHORITY = "com.android.launcher.settings";
- final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/favorites?notify=true");
- Cursor c = cr.query(CONTENT_URI, new String[] {"title","iconResource" }, "title=?",
- new String[] {"XXX" }, null);//XXX表示應用名稱。
- if(c!=null && c.getCount()>0){
- isInstallShortcut = true ;
- }
- /*try {
- while (c.moveToNext()) {
- String tmp = "";
- tmp = c.getString(0);
- }
- } catch (Exception e) {
- } finally {
- c.close();
- }*/
- return isInstallShortcut ;
- }
全站熱搜
留言列表