Android Tips: 寻找当前的Activity
来源:互联网 发布:猪八戒众包平台数据 编辑:程序博客网 时间:2024/06/06 04:26
通过如下的代码即可知道当前的活动Activity:
public boolean isForeground(String PackageName){ // Get the Activity Manager ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); // Get a list of running tasks, we are only interested in the last one, // the top most so we give a 1 as parameter so we only get the topmost. List< ActivityManager.RunningTaskInfo > task = manager.getRunningTasks(1); // Get the info we need for comparison. ComponentName componentInfo = task.get(0).topActivity; // Check if it matches our package name. if(componentInfo.getPackageName().equals(PackageName)) return true; // If not then our app is not on the foreground. return false;}需要权限 android.permission.GET_TASKS
0 0
- Android Tips: 寻找当前的Activity
- Android Tips-- Activity.runOnUiThread
- Android判断当前的Activity
- android 获取当前的activity
- Android tips #2 存储和恢复activity的状态
- android程序退出当前activity的方法
- android 取当前显示的activity是什么
- android程序退出当前activity的方法
- android程序退出当前activity的方法
- android程序退出当前activity的方法
- android 获取当前正在运行的activity
- android程序退出当前activity的方法
- android中获取当前activity的名称
- android中获取当前activity的名称
- Android获取当前最前面的Activity
- android 如何获取当前运行的activity
- Android 中获取当前的 Activity
- android 获取当前屏幕的Activity
- VS2010 & Qt,版本Release时:Debugging information for "project.exe" cannot be found or does not match.
- sina 微博 Oauth2.0接口
- MVC5+EF6 入门完整教程八
- Nutch1.7学习笔记5:Fetcher源代码分析
- _T “CButton::Create”: 不能将参数 1 从“const char [5]”转换为“LPCTSTR”
- Android Tips: 寻找当前的Activity
- C#字符串与字节数组互转
- 开发中的popwindow
- vtk6.1.0+qt5.3.2+cmake2.8.12.2+win7+64位安装配置过程
- Android编译简略讲解
- C程序的编译过程&阅读工具&debug工具
- Nutch1.7学习笔记6:ParseSegment源代码分析
- AGPS定位基本原理浅析
- Phonegap 3+ iOS和Android配制