将他的应用程序添加到“添加到主屏幕”/“快捷方式”部分
在我的 Android 应用程序中,我通过代码创建应用程序中某些活动的快捷方式。我通过使用广播来实现此功能:
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
sendBroadcast(intent);
这很酷,真的很有效!
现在我想做一些不同的事情:我已经看到,当您长按主页时,某些操作可以“注册”到 Android 菜单中的某个位置,如下所示
: androidtapp.com/wp-content/uploads/2010/02/UltimateFaves-Add-Home-Screen-Shortcut.jpg" rel="nofollow noreferrer">http://www.androidtapp.com/wp-content/uploads/2010 /02/UltimateFaves-Add-Home-Screen-Shortcut.jpg
所以我的主要问题是下一个:
如何注册此菜单。我想清单中需要添加一些行,但看不到在哪里添加!
非常感谢您的帮助!
顺便说一句,还有一个次要问题:一旦我成功做到这一点,我可以在菜单中添加不同数量的快捷方式吗(想象一下,我想为多帐户 Twitter 客户端这样做,我希望看到一个此列表中的每个 Twitter 帐户都不同。)因此快捷方式的数量是通过编程计算的。
In my android application, I create shortcuts by code to some activities within my application. I do this feature by using the broadcast:
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
sendBroadcast(intent);
and that's cool, that really work!
Now I would like to do something different: I have seen that some actions can "register" somewhere to be added in the Android menu, when you long press on the Home like this one:
http://www.androidtapp.com/wp-content/uploads/2010/02/UltimateFaves-Add-Home-Screen-Shortcut.jpg
So my main question is the next one:
How is that possible to register for this menu. I guess there is some line to add in the manifest, but cannot see where to do that!
Thank a lot for any help!
BTW, there is a secondary question: once i will have succeed doing that, may I add a different number of shortcuts in my menu ( imagine That I would like to do that for a multi-account twitter client, I would like to see a different for each twitter account in this list.) So the number of shortcut is programmaticaly computed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
刚刚在 SDK 示例中找到了我的答案:
Just found my answer in the SDK samples:
至于你的第二个问题:
我不知道如何准确地实现你所要求的,但一种可能的解决方案可能是让你的 CreateShortcuts 活动(或同等活动)打开一个包含可能选择的对话框,你的活动将从中返回与所选项目对应的快捷方式。当然,还有一些附加信息(请参阅 Intent.putExtra()),详细说明用户选择的项目(在您的情况下是 twitter 用户)。
As for your secondary question:
I don't know how to achieve exactly what you are asking for, but one possible solution might be to have your CreateShortcuts activity (or equivalent) open up a dialog with the possible choices, from which your activity would return a shortcut corresponding to the selected item. Of course with some additional info (see Intent.putExtra()) detailing which item, in your case twitter user, the user selected.