简体   繁体   English

如何确定前景中正在使用哪个应用程序?

[英]How do I determine what app is currently in the foreground?

I need a way to log what app is currently running in the foreground, preferably without requiring root access or using the NDK. 我需要一种方法来记录当前在前台运行的应用程序,最好不需要root访问权限或使用NDK。 Is there any way to do this? 有什么办法吗?

If I remember correctly, onResume() gets triggered any time an activity gets on foreground. 如果我没记错的话,只要活动进入前台,就会触发onResume()。 If your app contains more than one activity, you should check all of them. 如果您的应用包含多个活动,则应检查所有活动。

You can check activities lifecycle here 您可以在此处查看活动生命周期

暂无
暂无

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

相关问题 如何获得前台的活动窗口? - How do I get active window that is on foreground? 如何确定哪个android小部件正在调用我的函数? - How do I determine what android widget is calling my function? 如何确定android中输入设备的来源? - How do I determine what is the source of Input Device in android? 如何让“p:focus”在这个简单的应用程序中正常工作(它目前根本没有“聚焦”) - How do I get “p:focus” to work properly in this simple app (its currently not “focusing” at all) 如何禁用前景视图以在背景上掠过 - How do I disable foreground views to do fling on background 知道变量的内容之后,如何确定要放置在&lt;&gt;中的内容以消除“原始类型”警告? - Knowing what the contents of variables are going to be, how do I determine what to place inside the <> to eliminate “raw type” warnings? 如何确定Java中所请求字体的字体? - How do I determine what font I get for a requested font in Java? 如何确定当前正在运行的Play版本? - How to determine currently running Play version? 如何确定当前格式化的TableView单元格的索引 - How to determine index of currently formatted TableView Cell 如何全局获取当前键盘状态? (即,无论查询应用程序是否关注焦点,当前按下了哪些键) - How do you get the current keyboard state globally? (i.e. what keys are currently depressed regardless of if the inquiring application has focus)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM