0

ホーム画面からアプリのショートカットを削除しようとしています。この 2 つのアクションを使用します。

  1. com.android.launcher.action.INSTALL_SHORTCUT
  2. com.android.launcher.action.UNINSTALL_SHORTCUT

私にとっては完璧に機能しますが、アイコンをアプリリストからホーム画面にドラッグするとUNINSTALL_SHORTCUT機能しません。では、この 2 つの方法と、それぞれの状況でシステムがどのように動作するかに違いはありますか?

4

1 に答える 1

0
private void deleteShortCut(Context context) {

    Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
    shortcutIntent.setClassName("com.example.androidapp", "SampleIntent");
    shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    shortcutIntent.putExtra("someParameter", "HelloWorld");

    Intent removeIntent = new Intent();
    removeIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
    removeIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "ShortcutName");
    removeIntent.putExtra("duplicate", false);

    removeIntent
            .setAction("com.android.launcher.action.UNINSTALL_SHORTCUT");       
    context.sendBroadcast(removeIntent);
}

これを試して。

于 2013-09-23T10:54:24.810 に答える