检测机器人活动启动机器人

2023-09-05 05:55:25 作者:你并不孤单

我已经搜查了计算器的这个问题,并发现: Android,检测时,其他应用程序的推出并 Reliable办法从家里/台式机检测应用程序启动?,哪一种回答我的问题,但它仍然是不够的。

I have searched the stackoverflow for this question and found : Android, Detect when other apps are launched and Reliable way to detect application launch from home / desktop? , which kind of answers my question but it's still not enough.

我想做的事情什么 我想创建一个小部件/应用程序,显示设备的用户最近的应用程序列表和最常用的应用程序列表。

What I want to do I want to create a widget/app that shows the user of the device a list of recent apps and a list of most used apps.

问题 怎样才可以有,以建立最常用的应用程序的列表有关的应用程序的准确数据。

Problem How can I have accurate data about the apps in order to build a list of most used apps.

基本信息

在我编译我自己的Andr​​oid操作系统(4.2型)code,所以我有机会获得 一切。 在我开发的启动为好。 这需要通过CTS和是谷歌认可。 我可以让应用程序以系统权限。 我知道,这可能是一个安全问题对谷歌。 I am compiling my own Android OS (4.2 based) code so I have access to everything. I am developing the launcher as well. It needs to pass the CTS and be Google approved. I can make the app with system privileges. I know that this might be a security issue for Google.

有些解决方案

最近的应用程序可以通过ActityManager,getRecentApps方法来发现,所以现在问题出在那里。

The recent apps can be found via ActityManager, getRecentApps method, so now problem there.

我在网上搜索了这一点,并已经找到了以下解决方案:

I have searched the web for this and already found the following solutions:

使用服务来查询activityManager,getRunningTasks方法每X秒,并生成列表(innacurate信息,还使用了大量batery的)。 使用的logcat来获取此信息(似乎是一个黑客对我来说,需要系统权限) 更改activityManager本身,以提供该信息(极有可能失败的CTS测试) 使用发射器来验证被推出的应用程序(惦记内其他应用程序推出的应用程序)

别的我错过了什么?

在此先感谢, 蒂亚戈科斯塔

Thanks in advance, Tiago Costa

推荐答案

默认的Andr​​oid应用程序最近的对话框实施,是你最好的参考, 看here..check reloadButtons()

Android default recent apps dialog implementation is best reference for you, look here..check reloadButtons()

final ActivityManager am = (ActivityManager)
                context.getSystemService(Context.ACTIVITY_SERVICE);
        final List<ActivityManager.RecentTaskInfo> recentTasks =
                am.getRecentTasks(MAX_RECENT_TASKS, ActivityManager.RECENT_IGNORE_UNAVAILABLE);

您可以用类似的方式尝试。

You can try in similar way..