pressing通过服务机器人后退按钮 [英] pressing the back button on android through service

查看:178
本文介绍了pressing通过服务机器人后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能以编程方式通过服务于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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆