问题描述
如果我正在编写自己的Android应用程序,我知道如何将其构建为服务,以便它将开始在后台运行.
但是,有没有办法启动现有应用程序(例如,来自播放商店的任何随机的.Apk),以便它在后台启动,而无需其屏幕即可占用显示屏? 或者,我愿意启动该应用程序,强迫它进入后台,并重新显示在前台运行的上一个应用程序的窗口(无论是可能的).我不知道如何以编程方式将当前应用程序放在后台,然后确定上一个应用程序并将其带回前景.我愿意以任何方式做到这一点:通过java,通过一个或多个命令行公用事业,通过tasker插件,通过xposed模块或其他.
提前谢谢任何指向文档或任何建议的指针.
推荐答案
我发现"diveSys活动结束"的#0条目给出了当前显示的活动...至少在我的rooted arshmallow设备上.这给了我所需要的.
问题描述
If I'm writing my own Android app, I know how to structure it as a Service so it will start running in the background.
However, is there a way to launch an existing app (for example, any random .apk from the Play Store) so that it starts up in the background, without its screen taking over the display?
Alternatively, I'd be willing to launch the app, force it into the background, and redisplay the window of the previous app (whatever it might have been) that was running in the foreground. I don't know how to programmatically put the current app in the background and then determine the previous app and bring it back to the foreground.
I'm willing to do this any way possible: via Java, via one or more command-line utilities, via a Tasker plugin, via an Xposed module, or whatever.
Thank you in advance for any pointers to docs or any suggestions.
推荐答案
I discovered that the #0 entry of "dumpsys activity recents" gives the currently displayed activity ... at least on my rooted Marshmallow device. This gives me what I need.