Android: launch same instance
<p>I am creating a Home shortcut with the following code:
I would like to get the same opened instance (if exist) of the app launched and not a new instance.</p>

<pre><code>    public void createShortcut() {

    if (app.prefs.getBoolean("prefs_ShortcutCreated", false) == false) {
        Intent shortcutIntent = new Intent();
        shortcutIntent.setClassName(this, this.getClass().getName());

        shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);

        Intent addIntent = new Intent();
        addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
        addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "test");
        addIntent.putExtra("duplicate", false);
        File image = new File(app.DEFAULT_APP_FOLDER_MAIN, "icon.png");
        AssetManager assets = app.getApplicationContext().getResources().getAssets();
        try {
            copy(assets.open("icon.png"), image);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        Bitmap theBitmap = BitmapFactory.decodeFile(app.DEFAULT_APP_FOLDER_MAIN + "icon.png");
        Bitmap scaledBitmap = Bitmap.createScaledBitmap(theBitmap, 128, 128, true);
        addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON, scaledBitmap);

        addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
        sendBroadcast(addIntent);

        theBitmap.recycle();
        scaledBitmap.recycle();

        Editor editor = app.prefs.edit();
        editor.putBoolean("prefs_ShortcutCreated", true);
        editor.commit();
    }

}
</code></pre>
