1

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);
    }
Ashish
  • 873
  • 10
  • 20
  • Check this out: http://stackoverflow.com/questions/12853443/android-how-to-remove-uninstall-application-shortcuts-from-home-screen – zed Mar 20 '17 at 12:50
  • thanks for reply.i have already used that code. but this code doesn't work for above api level 21 (Lollipop, Marshmallow, N). – Ashish Mar 20 '17 at 12:54

0 Answers0