有没有办法处理小部件/服务中的关键事件?
我想在我的应用程序小部件中处理音量增大
和音量减小
keyEvents。 它确实应该发生在应用程序小部件
或服务中,而不是在活动中(应该显示主屏幕)。
但据我所知,似乎不可能通过应用程序小部件或服务与用户做出反应,因此我无法获取 keyEvents。
所以我的问题是,如果我错了,是否有可能获得 keyEvents 或者可能使活动不可见?
I would like to handle the volume up
and volume down
keyEvents in my App Widget.
It really should happen in the app widget
or a Service, not in an Activity (the homescreen should be displayed).
But as far as i know there don't seems to be a possibility to react with the user from an app widget or service, so i can't get the keyEvents.
So my Question is if I'm wrong and there is a possibility to get the keyEvents or maybe one to make the acitivity invisible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果“小部件”指的是“应用程序小部件”,那么,不,您无法响应来自应用程序小部件的关键事件。
If by "Widget" you mean "app widget", then, no, you cannot respond to key events from an app widget.
我找到了一个窍门。它并不是最好的,但就我而言我可以使用它。
通过分配主题
或
在 Android Manifest 中,可以有一个看起来像对话框或透明的活动。因此主屏幕是可见的,并且在活动中我可以获取 keyEvents。
尽管用户不可能在活动运行期间与主屏幕进行交互,但在我的情况下,这不一定是必需的。
I have found a trick. It's not really the best, but in my case I can use it.
With assigning the themes
or
in the Android Manifest, it's possible to have an Activity that looks like an Dialog or which is transparent. So the home screen is visible and in the Activity I can get the keyEvents.
Although it isn't possible that the user can interact with the home screen during the activity is running, but in my case this isn't needed necessarily.