pressing通过服务机器人后退按钮 [英] pressing the back button on android through service
问题描述
是否有可能以编程方式通过服务于Android preSS后退按钮?
我知道我可以覆盖pssed()方法,如果我是一个活动的onBack $ P $,但我期待为在后台运行的服务的解决方案。
是否有可能以编程方式通过服务于Android preSS后退按钮?
块引用>没有。
我知道我可以覆盖onBack pressed()方法,如果我是一个活动,
块引用>这已经无关编程preSS返回按钮。
我要寻找,对在后台运行的服务的解决方案。
块引用>您服务,欢迎发送邮件到的您的活动引起的活动来调用
完成()
。可以使用以下任何这样的消息:
LocalBroadcastManager
- 事件总线像奥托
- 一个常规的广播
意图
- 在
使者
- 等
不过,如果你的期望是,你将能够攻击活动的其他应用程序的的,强制的他们的调用
完成()
,这是不可能的。Is it possible to programmatically press the back button on android through a service ?
I know I can override the onBackPressed() method if I were in an Activity, but I am looking for a solution that works for a service running in the background.
解决方案Is it possible to programmatically press the back button on android through a service ?
No.
I know I can override the onBackPressed() method if I were in an Activity,
That has nothing to do with "programmatically press the back button".
I am looking for a solution that works for a service running in the background.
Your service is welcome to send a message to your activity which causes the activity to call
finish()
. You could use any of the following for such a message:
LocalBroadcastManager
- an event bus like Otto
- a regular broadcast
Intent
- a
Messenger
- etc.
However, if your expectation is that you will be able to attack the activities of other apps, forcing them to call
finish()
, that is not possible.这篇关于pressing通过服务机器人后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!