Android shortcut can not remove in other app instance
<p>I am trying to add/remove shortcut for my app. The "add" code works perfect. But removing works only if I run it at the same app instance it was created. If I create the shortcut, then restart app and finally execute the "remove" code it fails (don't remove the icon).</p>

<p>This is my code:</p>

<pre><code>public static void add(Class&lt;? extends Activity&gt; activity, String name, Bitmap icon) {
    Context context = ...;

    icon = scaleIcon(context, icon);

    Intent shortcutIntent = new Intent(context, activity);
    shortcutIntent.setAction(Intent.ACTION_MAIN);
    int flags = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT;
    shortcutIntent.setFlags(flags);

    Intent addIntent = new Intent();
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name);
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon);
    addIntent.setAction(SHORTCUT_INSTALL);

    context.sendBroadcast(addIntent);
}

public static void remove(Class&lt;? extends Activity&gt; activity, String name) {
    Context context = ...;

    Intent shortcutIntent = new Intent(context, activity);
    shortcutIntent.setAction(Intent.ACTION_MAIN);
    int flags = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT;
    shortcutIntent.setFlags(flags);

    Intent removeIntent = new Intent(SHORTCUT_UNINSTALL);
    removeIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
    removeIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name);

    context.sendBroadcast(removeIntent);
}
</code></pre>

<p>BTW, I couldn't find android docs about shortcuts.
Thanks for helping me.</p>