简体   繁体   English

如何知道用户正在使用的应用程序名称?

[英]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.

相关问题 如何知道在Java应用程序中登录的用户是谁? - How know which is the user who is login in java application? 图书馆有没有办法知道使用它的应用程序的 package 名称? - Is there a way for a Library to know the package name of the application using it? 如何知道Java应用程序安装在哪个驱动器上? - How to know on which drive an Java Application is installed? 访问 - 了解用户访问我的应用程序的国家/地区 - Access - To know from which country the user is accessing my application 在不使用soap消息中使用操作名称的情况下,webservice应用程序如何知道soap调用特定方法? - How does webservice application know soap call for a particular method,without using operation name in soap message? 如何在我的Android应用程序中使用firebase-ui时,用户是否已经创建了一个帐户? - How can I know if a user already created an account while using firebase-ui on my android application? 我想知道我的应用程序使用的是哪个 .net CLR 版本 - i want to know which .net CLR version my application is using 如何知道Intellij使用哪个构建工具? - How to know which build tool is Intellij using? 使用getItemViewType() - 我如何知道哪个布局为0,哪个布局为1? - Using getItemViewType() - How do I know which layout is 0 and which is 1? CDI扩展,如何知道bean所属的应用程序名称 - CDI extension, how to know the Application name that a bean belongs to
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM