0

Hi i am creating application shortcut to my application. My application shortcut is in the front of home screen. When i close the application at that time how to close/delete application shortcut. I need source code. Please any one help me. Thanks.

Code is here. Help me.

Intent shortcutintent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
shortcutintent.putExtra("duplicate", false);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
Parcelable icon = Intent.ShortcutIconResource.fromContext(
    getApplicationContext(), R.drawable.icon);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, 
    new Intent(getApplicationContext() , FirstScreenActivity.class));
sendBroadcast(shortcutintent);
4

1 回答 1

0

要卸载快捷方式,您可以使用 Intent 和"com.android.launcher.action.UNINSTALL_SHORTCUT"操作。您还应该"com.android.launcher.permission.UNINSTALL_SHORTCUT"在清单中获得许可。

Intent uninstallShortcutIntent = new Intent("com.android.launcher.action.UNINSTALL_SHORTCUT");
uninstallShortcutIntent.putExtra("duplicate", false);
uninstallShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
uninstallShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, 
    new Intent(getApplicationContext() , FirstScreenActivity.class));
sendBroadcast(uninstallShortcutIntent);

我没有测试它。从启动器源获取它:AndroidManifest.xmlUninstallShortcutReceiver 注意:AFAIK,它可能在某些第三方启动器中不起作用,它不是 Android SDK 的一部分。

于 2012-05-17T13:09:33.163 回答