how to create shortcut on home screen

Not every Android device's users are geeks, it would be nice to provide shortcuts on home screen when your app instlled. After searching for a while, I found some answers about:

    <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
    <uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT"/>

but they doesn't work out and they are also undocumented.

The work around way is providing a widget instead of shorcut. Widget is fatastic, it can not only launch whatever you want but also update it's own state by intervel.

Creating widget is easy, just following this guide: http://developer.android.com/guide/topics/appwidgets/index.html#Basics

Hint:

If you don't want to update widget periodically,updatePeriodMillis should be configed in widget info file:

                    android:updatePeriodMillis="0"

If the widgets you provide do not show up in widget list, reset or restart the home launcher would help.


你可能感兴趣的:(how to create shortcut on home screen)