跟踪第三方应用程序的启动

编程入门 行业动态 更新时间:2024-10-25 00:27:07
本文介绍了跟踪第三方应用程序的启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否可以跟踪设备上第三方应用程序的启动?

Is it possible to track the launch of a third-party application on the device? Maybe the android sends a broadcast when the applications are launched.

更新

public class ServiceAppControl extends IntentService { private boolean serviceStarted = true; public ServiceAppControl() { super("ServiceAppControl"); } @Override protected void onHandleIntent(@Nullable Intent intent) { while (serviceStarted){ String appIsForeground = isAppOnForeground(getBaseContext()); Log.d(AppGlobal.LOG_TAG, "Запущено приложение " + appIsForeground); try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } } } private String isAppOnForeground(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses(); String appIsForeground = ""; if (appProcesses == null) { return appIsForeground; } final String packageName = context.getPackageName(); for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) { if (appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) { appIsForeground = appProcess.processName; return appIsForeground; } } return appIsForeground; }

}

推荐答案

没有广播这样的消息来通知其他人可以收听的应用程序的启动,因为这可能是安全威胁。人们可以将其用于恶意目的。否则,您可以从日志中了解当前启动的应用程序。

There is no broadcast as such to inform about launch of an application to which others can listen because that can be a security threat. People can use it for malicious purpose. Otherwise from the logs you can get to know about currently launched application.

更多推荐

跟踪第三方应用程序的启动

本文发布于:2023-11-27 03:31:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636393.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:第三方   应用程序

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!