[英]How to know the application name which the user was using?
I am a beginner in the field of android development.我是android开发领域的初学者。 I am trying to build a keyboard app in the android studio so that the user can use it for typing in applications like Whatsapp, Facebook...etc My query is if the user is using this app for typing some text, is it possible to know in which application he is typing?
我正在尝试在 android 工作室中构建一个键盘应用程序,以便用户可以使用它来输入诸如 Whatsapp、Facebook 等应用程序我的问题是如果用户使用这个应用程序来输入一些文本,是否可以知道他在哪个应用程序中输入? If it is not possible is there any other way to know about the application which was being used by the user?
如果不可能,还有其他方法可以了解用户正在使用的应用程序吗?
It looks like this is possible using the ActivityManager.使用 ActivityManager 似乎可以做到这一点。
import android.app.ActivityManager;
... ...
final ActivityManager activityManager = (ActivityManager)
final List<ActivityManager.RunningTaskInfo> recentTasks = Objects.requireNonNull(activityManager).getRunningTasks(Integer.MAX_VALUE);
https://www.tutorialspoint.com/how-to-find-the-currently-running-applications-programmatically-in-android https://www.tutorialspoint.com/how-to-find-the-currently-running-applications-programmatically-in-android
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.