tags:

views:

33

answers:

1
+1  Q: 

Desktop Icon link

Hi,

I would like to know if there is an option of setting an auto icon link of my application in the user's desktop, after installing it?

The only way I know to do it, is that the user could drag it manually to his desktop from the applications list. Is there any way of doing it automaticlly for the user(withouth his touch) ?

Thanks,

Moshic.

+1  A: 

Please don't do that automatically!!! Let the user choose wether or not he want your shortcut!

Here is the code you need:

        //Create shortcutIntent here with the intent that will launch you app.
        Intent shortcutIntent = (...)
        shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

        final Intent intent = new Intent();
        intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
        // Sets the custom shortcut's title
        intent.putExtra(Intent.EXTRA_SHORTCUT_NAME,sName);
        intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon);

        // add the shortcut
        intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
        sendBroadcast(intent);

Don't forget an extra permission in the Manifest!

        <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
Profete162
Is it possible to do it automaticlly when the user INSTALL the app?
Moshik
I've never heard about self-launched app In android...You can execute this piece of code at the first manual launch of your application.
Profete162
But the problem is: each time i run my app i create new shortcut on desktop to my app.. how ill avoid it ?(I want only one shortcut)
Moshik
What I do for my application is I create a boolean preference "actiondone", that is by default "false"If (!actiondone)then I set this preference to true and make my "firstboot" action.Hope you are familiar with the preferences...
Profete162
Not so much.. could you give me past me some example? thanks.
Moshik
http://downloadandroid.info/2010/06/how-to-check-if-its-the-first-run-of-your-app/
Profete162
And how would you delete the shortcut?
Moshik