2012-05-17 59 views
0

嗨,我正在创建应用程序快捷方式到我的应用程序。我的应用程序快捷方式位于主屏幕的前端。当时我关闭应用程序时如何关闭/删除应用程序快捷方式。我需要源代码。请任何人帮助我。谢谢。如何在android中关闭应用程序快捷方式?

代码在这里。帮我。

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); 

回答

0

要卸载快捷方式,你可以使用意向与"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的一部分。

+0

谢谢。但是图标显示在主屏幕上。 – Balamurugan

相关问题