获取当前前台应用的名称 [英] Get the name of the current foreground app

查看:104
本文介绍了获取当前前台应用的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要研究一组参与实验的测试用户实际使用的应用程序。我想知道每个随机第三方应用程序用于对其进行统计的时间。如果可能,我计划通过TestFlight分发iOS应用程序。我的应用程序将收集应用程序使用情况统计信息并将其发送到我的服务器。

I need to do a study of what apps are actually used among a group of test users taking part of an experiment. I would like to know the time each of the random 3rd party apps have been used to do statistics on it. If possible, I plan on distributing an iOS app through TestFlight. My app will gather the app usage statistics and send it to my server.

总体目标是从每个基础上获取每个已安装应用程序的总使用时间。参与实验的用户。

The overall goal is to get total usage time for each installed app on a daily base from each of the users taking part of the experiment.

我所拥有的:
我的一个想法是开发一个使用VoIP后台配置文件的应用程序(或类似的) )在后台运行并定期(如每10秒)记录当前前台应用程序的名称或包标识符(如果有的话)。

What I have: One of my ideas are to develop an app that will use the VoIP backgrounding profile (or similar) to run in the background and periodically (like every 10 secs) log the name or bundle identifier of the current foreground app (if any).

我找到了一个方法获取当前正在运行的进程:我们可以检索当前在iPhone和iPad上运行的应用程序
上面发布的方法给出了一个struct kinfo_proc ,其中包含其他结构,其中包含进程名称等信息,优先级和运行时间(包括在后台花费的时间)。我无法确定一个标志,揭示前景中的进程。优先事项似乎也不是一个可靠的指标。我在这里缺少的东西?

I have found a method to get the current running processes: Can we retrieve the applications currently running in iPhone and iPad The method described in the above post gives a struct kinfo_proc that includes other structs with information such the process name, priority and running time (including time spent in the background). I have not been able to identify a flag revealing what process is in the foreground. Also the priority does not seem to be a reliable indictor. Something I'm missing here?

以上方法可用于获取流程的当前运行时间,但因为每个应用程序都可以在后台休眠几天(或几周)这是一个糟糕的指标,表明该应用实际使用了多少。如果我可以每小时左右杀死所有正在运行的用户安装的应用程序,我就可以获得应用程序使用频率的指标。最常用的应用程序将由用户更频繁地冷启动。但随着应用程序被随机杀死,这会给测试人员带来不愉快的体验。但无论如何,有没有办法可以杀死另一个进程?

The above method can be used to get the current running time for a process, but as each app can be sleeping in the background for days (or weeks) this is a poor indicator for how much the app has actually been used. If I could kill all the running user installed apps every hour or so I could get an indicator of how often apps are used. The most used apps would be cold-started by the user more often. But that would give an unpleasant experience for the testers as apps are killed randomly. But anyway, is there a way I can kill another process?

另一个想法是遍历视图层次结构以探测任务栏中最左边应用程序的标签。关于如何可能破解的任何想法?

Another idea is to traverse through the view hierarchy to probe the label of the leftmost app in the task bar. Any ideas of how this might be possible to hack?

我还有另一个想法,就是分析设备日志并以这种方式收集应用程序使用情况统计信息。但是,似乎应用程序后台前台切换活动未记录到系统控制台。是否有其他日志包含此信息,或者我可以通过启用能源诊断日志记录获得它吗?

I had another idea of analyzing device logs and gathering app usage statistics that way. However it seems that app background-foreground switching activity is not logged to the system console. Is there some other logs containing this information or can I get it somehow by enabling energy diagnostics logging?

如果我的测试用户设置为使用Apple Mobile Device Management( MDM)那么我能收集我感兴趣的信息吗?

If I had my test users set up to use Apple Mobile Device Management (MDM) would I then be able to collect the information I am interested in?

非常感谢任何想法。

一些注释:
我的测试用户没有越狱设备,但我可以使用私有API,因为我没有通过App Store分发。

A few notes: My test users does not have jailbroken devices, but I can use private APIs as I am not distributing through the App Store.

推荐答案

我会使用像 Flurry Analytics 获取有关使用情况统计数据的数据,然后您可以使用其API <下载到您的应用中/ A>。他们可以为您提供有关用户如何使用您的应用程序,频率等的详细信息。这是一个很棒的工具,而且它是免费的!

I would use an analytics tool like Flurry Analytics to get the data concerning usage statistics, which you could then download into your app using their API. They can get you very details stats on how your users are using your app, how frequently, etc. It's a great tool, plus it's free!

这篇关于获取当前前台应用的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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