在android应用启动时中我写了个判断快捷方式的方法,但是它总是返回false,并不会返回true,请问下我哪里写错了吗?
谢谢各位了!
代码如下:
- Java code
private boolean isFavorites() { boolean isInstallShortcut = false; final ContentResolver cr = 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[] { getString(R.string.app_name) }, null); if (c != null && c.getCount() > 0) isInstallShortcut = true; return isInstallShortcut; }
------解决方案--------------------
可能是中文名称导致的没找到
------解决方案--------------------
这个是安全的考虑,如果用户不同意就不创建,系统默认的设置,不是那么容易改的!