简体   繁体   English

有什么方法可以从后台跟踪当前正在运行的应用程序?

[英]Any way to keep track of current running app from background?

I would like to create an application which, while in the background, keeps track of the current app which is loaded and being used. 我想创建一个在后台运行的应用程序,该应用程序跟踪当前正在加载和使用的应用程序。

Is there any way to have my app, periodically check which app is currently being run? 有什么办法可以让我的应用程序定期检查当前正在运行哪个应用程序? My thought is to keep track of the time when an app is loaded and then when it is closed and find the difference in time but I'm unsure if I can give my app access to this data. 我的想法是跟踪应用程序的加载时间以及关闭时间,然后找出时间差,但是我不确定是否可以让我的应用程序访问此数据。

Thanks 谢谢

You can´t execute code in the background in you iOS device. 您无法在iOS设备的后台执行代码。 There are a few exceptions but what you´re trying to do is not included in that. 有一些例外,但是您要执行的操作未包含在其中。

This might be possible - there's an app called Moment which tracks your screen time while in the background. 可能是可能的-有一个名为Moment的应用程序,它可以在后台跟踪您的屏幕时间。 It does so by using always-on GPS, one of (if not the only) thing that can run in the background. 它通过使用永远在线的GPS来做到这一点,该GPS可以在后台运行(如果不是唯一的话)。 Maybe that's a place to start looking. 也许这是一个开始寻找的地方。

An app can execute code in the background, but Apple will reject App store submissions that do so, except for a few allowed purposes. 应用程序可以在后台执行代码,但是Apple会拒绝这样做的应用程序商店提交,除非出于某些允许的目的。 For private developer and Ad Hoc apps, maybe OK though. 对于私人开发人员和Ad Hoc应用程序,也许可以。

However, Apple currently hides all information about other app processes from your app's sandbox for privacy and security reasons. 但是,出于隐私和安全原因,Apple当前会在您的应用的沙箱中隐藏有关其他应用进程的所有信息。 They will be invisible to your background code. 它们将对您的背景代码不可见。 So, no way, on stock OS iOS devices. 因此,绝对不能在普通OS iOS设备上使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM