`
elvwong
  • 浏览: 1774 次
文章分类
社区版块
存档分类
最新评论

android判断快捷方式是否已经创建的方法

阅读更多
最近一直想找如何判断快捷方式是否已经创建的方法,最后终于结合几家算可以啦,不知道对不对,反正在XT800试是可以的。
其实快捷方式信息是保存在com.android.launcher的launcher.db的favorites表中,
相关代码:

		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 ;
	}



要有权限:
<uses-permission android:name="com.android.launcher.permission.READ_SETTINGS"/> 
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics