Android 快捷方式

/** * * [添加快捷方式]<BR> * [功能详细描述] */ private void addShortcut() { Intent shortcut = new Intent( "com.android.launcher.action.INSTALL_SHORTCUT"); shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name)); shortcut.putExtra("duplicate", false); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setClass(this, TestActivty.class); shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent); ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext( this, R.drawable.icon); shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes); sendBroadcast(shortcut); } /** * * [快捷方式是否安装]<BR> * [功能详细描述] * * @return */ private boolean isInstallShortcut() { boolean flag = false; final ContentResolver cr = this.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[] {getResources().getString(R.string.app_name) }, null);// XXX表示应用名称,需要判断什么就修改成什么 if (c != null && c.getCount() > 0) { flag = true; } return flag; }

你可能感兴趣的:(c,android,String,null)