/** * 程序是否在前台运行 * @return */ public
boolean isAppOnForeground(String packageName) {
// Returns a list of application processes that are running on the device
List<RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses();
if
(appProcesses == null)
return false;
for
(RunningAppProcessInfo appProcess : appProcesses) {
// The name of the process that this object is associated with.
if
(appProcess.processName.equals(packageName) && appProcess.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
return true;
}
}
return
false; }

被折叠的 条评论
为什么被折叠?



