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);
}
试试这个。
对不起,但不适合我。 Imho InstallShortcutReceiver在发送广播以创建快捷方式时将一些额外的数据存储在LauncherModel中,而当您只是从列表中拖动图标而不发送广播系统时,会执行其他操作。有什么建议么? –
codinggeekorg.wordpress.com/tag/home-screen-shortcuts/#-检查此链接也许你会得到一些帮助。 –
http://android.stackexchange.com/questions/37327/how-can-i-remove-unwanted-app-icons-from-the-screen这一个也。 –