RT ,我就是想在service 里面 调用一下返回键。 现在网上大多数都是 在 Activity里面调用的返回键。 请问在service里面可以实现吗。
service Android
借助 AccessibilityService 辅助服务的AccessibilityEvent.getSource().performAction(AccessibilityService.GLOBAL_ACTION_BACK); 可以实现,不过还需要用户去开启服务,可行性不高, 或者你试试异步发送 new Instrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_BACK);不知道这个在services里面有没有效果。
Activity 可以响应 KeyEvent ,所以你调用 dispatchKeyEvent 的时候,是 Activity 或者 DecorView 进行响应你的 KeyEvent ,但是 Service 并没有 Window 和它进行绑定,所以你不能在当前上下文中调用返回键。
Activity
KeyEvent
dispatchKeyEvent
DecorView
Service
Window
如果你想在系统级别调用返回键,是需要系统级的签名的(也就是改Android OS的源码,重新编译)
Android的监听来电去电的问题
android intent启动jar包中定义的service出错
我现在做了个SDK,里面有个Service,但是我其他应用引用的时候每个都会启动,怎么让各个应...
请问android app如何启动DexClassLoader动态加载的jar包中定义的ser...
Android将所有网络请求及逻辑都放在Service中处理是否合适
android上搭建mina服务器锁屏后无法接受数据包
Escort Service in Aerocity & Call Girls in Aero...