开发者

Push a bookmark to a user's home screen in Android

Android 2.1 (not sure how much that matters) My test hardware is a Motorola Droid (not开发者_运维问答 sure how much that matters either)

I want to push a bookmark/internet-shortcut to a user's home screen as a result of them clicking on a link - via their browser of choice.

I know they can usually set the bookmark themselves and then choose to put it on their home screen. But I'd like to provide a link like "Put a shortcut to this page on your home screen" that takes care of everything kind of in the background/underneath.

Is this even possible? What parts of the framework would I need access to to make it happen?


Yes you can. First of all, you need to request the permission "com.android.launcher.permission.INSTALL_SHORTCUT". Then, broadcast an Intent with the action "com.android.launcher.action.INSTALL_SHORTCUT" and add the following extra: - Type = Intent - Name = Intent.EXTRA_SHORTCUT_INTENT

The Intent you pass as the extra is the shortcut itself.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜