I create a shortcut when the application opens, but the problem is that always create a shortcut that opens the application if I open the application 20 times and then create 20 shortcuts
I need to create only one shortcut, the first to open no more
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ShortcutIcon(); } private void ShortcutIcon(){ Intent shortcutIntent = new Intent(getApplicationContext(), Main.class); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Intent addIntent = new Intent(); addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Whatsapp Imagenes"); addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.drawable.icono)); addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); getApplicationContext().sendBroadcast(addIntent); }
android
Gatiko06 Jan 01 '14 at 1:19
source share