开发者

Desktop Icon link

I would like to know if there i开发者_高级运维s 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.


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" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜