I have created two buttons one for create shortcut and another for remove shortcut. create shortcut code works well,but remove shortcut doesn't work above api level 21
here is the code
private void deleteShortCut() {
Intent intent = new Intent();
intent.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT");
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "RAM CLEANER");
intent.putExtra("duplicate", false);
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.short_cut_icon));
Intent i = new Intent();
i.setAction("com.yzy.shortcut");
i.addCategory("android.intent.category.DEFAULT");
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, i);
sendBroadcast(intent);
SharedPreferencesUtils.setIsShortCut(getApplicationContext(), true);
Intent shortcutInt = new Intent(getApplicationContext(),
Setting.class);
Intent addInt = new Intent();
addInt.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutInt);
addInt.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Ram Booster");
// Set Uninstall action in Intent
addInt.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT");
// Broadcast the created intent
getApplicationContext().sendBroadcast(addInt);
}