Android - 从小部件调用 Activity
目前,我的应用程序 HireADroid 的小部件与主应用程序捆绑在一起。我想解除该小部件的捆绑并将其作为单独的产品发布。但是 - 该小部件依赖于主应用程序中的 Activity,因此我需要在这两个小部件之间导航,主要从小部件调用主应用程序的特定 Activity。所以基本的想法是——应用程序可以在没有小部件的情况下工作,并且小部件成为“附加”选项。
从独立小部件调用应用程序活动的“正确”方法是什么?我是否要将主应用程序转换为内容提供商?您能给我指出任何代码示例吗?
新年快乐!
PS 我不是问如何从捆绑在同一个 APK 中的小部件调用 Activity。该问题特别指出小部件与它所调用的应用程序分开分发
I currently have widget for my app HireADroid bundled with the main application. I would like to unbundle the widget and release it as a separate offering. However - the widget is relying on Activities
from the main app so I need to navigate between these two mainly calling particular Activity
of the main app from the widget. So the basic idea - app can work without widget and the widget becomes the "add-on" option.
What is the "right" way to call app activities from the stand-alone widget? Do I convert the main app into a content provider? Can you point me to any code samples perhaps?
Happy New Year!
P.S. I'm not asking how to call Activities from the widget that is bundled in the same APK. The question specifically states that widget is distributed separately from the app it's calling
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本思想是使用意图:
响应某些操作。android.content.Intent
类的实例,并在 Intent 实例上调用startActivity
。如果活动是上下文相关的,您可以使用内容 URI(您可以为操作/URI 对创建 Intents),还可以通过“extras”包传递额外信息(请参阅
Intent.getExtras
)。更多信息请参阅此处的文档:
The basic idea is to use Intents:
<intent-filter>
.android.content.Intent
class for the action you've set your activity to respond to, and callstartActivity
on the Intent instance.If the activity is contextual, you can use content URIs (you can create Intents for action/URI pairs) and also pass extra information via an 'extras' bundle (see
Intent.getExtras
).More information available in the docs here: