简体   繁体   English

如何检测到某个特定的应用程序已启动?

[英]How can I detect that a particular application has been launched?

The Context 上下文

There's a certain app that competes with my app for a hardware resource that should be mutex-locked, but isn't. 有一个与我的应用程序竞争的应用程序,其硬件资源应该是互斥锁,但不是。 The hardware resource has no API in the public Android SDK, and the competing app expects to be the only app to ever need it. 硬件资源在公共Android SDK中没有API,并且竞争的应用程序有望成为有需要的唯一应用程序。 The hardware resource's governing firmware also expects it to only ever be acquired by one app at a time. 硬件资源的控制固件也希望一次只能被一个应用程序获取。

The Problem 问题

Collisions over the hardware resource are not handled well in the firmware, and my test device will often need a reboot if the user launches the competing app while my app is running (I'm able to check for the competing app's service with ActivityManager.getRunningServices() and stop my app from trying to acquire the hardware resources if the user starts my app while the competing app is running). 固件无法很好地处理硬件资源上的冲突,并且如果用户在我的应用程序运行时启动竞争应用程序,我的测试设备通常需要重新启动(我可以使用ActivityManager.getRunningServices检查竞争应用程序的服务() ,如果用户在竞争应用程序运行时启动了我的应用程序,则可以停止我的应用程序尝试获取硬件资源)。
I don't have access to the competing app's source code, or the system image source code, so my app has to be responsible for handling the competing app's bad behavior and/or the firmware's poor handling of competition for this hardware resource. 我无权访问竞争应用程序的源代码或系统映像源代码,因此我的应用程序必须负责处理竞争应用程序的不良行为和/或固件对硬件资源竞争的不良处理。

The Question 问题

Is there a way for a normal (ie non-system) app running on Android Marshmallow to receive a callback when an app Activity or Service with a known component name is launched? 当启动具有已知组件名称的应用活动或服务时,是否可以让运行在Android Marshmallow上的常规(即非系统)应用接收回调?

Is there a way for a normal (ie non-system) app running on Android Marshmallow to receive a callback when an app Activity or Service with a known component name is launched? 当启动具有已知组件名称的应用活动或服务时,是否可以让运行在Android Marshmallow上的常规(即非系统)应用接收回调?

No. In fact, Android 5.0+ takes pains to hide the real-time knowledge of other running apps from you, for privacy and security reasons. 不会。事实上,出于隐私和安全原因,Android 5.0+会竭尽全力向您隐藏其他正在运行的应用程序的实时知识。

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

相关问题 如何检测第三方应用程序已在Android中完成? - How can i detect third party application has been finished in android? 检测哪个应用已在Android中启动 - Detect which app has been launched in android 我可以检测到我的android应用已删除特定权限吗? - Can I detect that a particular permission has been removed for my android app? 如何在服务启动的窗口中更新列表视图? - How can I update a listview within a window that has been launched by a service? 我如何检测到活动已开始 - How can i detect that the activity has been started 如何检测何时接受拨出电话 - How can I detect when outgoing call has been accepted 如何检测Android MapView是否已被平移或缩放? - How can I detect if an Android MapView has been panned or zoomed? 我怎么知道该应用程序已使用了多长时间? - How can I know how long the application has been used? 如何检测我的 Android 应用程序是否已使用 AndroidJUnitRunner 启动? - How to detect if my Android application has been started using AndroidJUnitRunner? Android是否可以检测Applicaton的启动方式? - Android Can Applicaton Detect How it is being Launched?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM