use of android.app.ActivityManager in project android-gpuimage-ndkbuild-sample by mugku.
the class GPUImage method supportsOpenGLES2.
/**
* Checks if OpenGL ES 2.0 is supported on the current device.
*
* @param context the context
* @return true, if successful
*/
private boolean supportsOpenGLES2(final Context context) {
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
return configurationInfo.reqGlEsVersion >= 0x20000;
}
use of android.app.ActivityManager in project UltimateAndroid by cymcsg.
the class BasicUtils method isServiceRunning.
/**
* Check if the service is running
*
* @param context
* @param cls
* @return
*/
public static boolean isServiceRunning(Context context, Class<?> cls) {
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningServiceInfo> services = activityManager.getRunningServices(Integer.MAX_VALUE);
for (ActivityManager.RunningServiceInfo serviceInfo : services) {
ComponentName componentName = serviceInfo.service;
String serviceName = componentName.getClassName();
if (serviceName.equals(cls.getName())) {
return true;
}
}
return false;
}
use of android.app.ActivityManager in project superCleanMaster by joyoyao.
the class AppUtil method getAvailMemory.
/**
*
* 描述:解析数据.
*
* @param info
* User 39%, System 17%, IOW 3%, IRQ 0%
* @return
*/
// public static AbCPUInfo parseCPUInfo(String info) {
// AbCPUInfo CPUInfo = new AbCPUInfo();
// String tempString = "";
// String[] rows = null;
// String[] columns = null;
// rows = info.split("[\n]+");
// // 使用正则表达式分割字符串
// for (int i = 0; i < rows.length; i++) {
// tempString = rows[i];
// //AbLogUtil.d(AbAppUtil.class, tempString);
// if (tempString.indexOf("User") != -1 && tempString.indexOf("System") !=
// -1) {
// tempString = tempString.trim();
// columns = tempString.split(",");
// for(int j = 0; j < columns.length; j++){
// String col = columns[j].trim();
// String[] cpu = col.split(" ");
// if(j == 0){
// CPUInfo.User = cpu[1];
// }else if(j == 1){
// CPUInfo.System = cpu[1];
// }else if(j == 2){
// CPUInfo.IOW = cpu[1];
// }else if(j == 3){
// CPUInfo.IRQ = cpu[1];
// }
// }
// }
// }
// return CPUInfo;
// }
/**
* 描述:获取可用内存.
*
* @param context
* @return
*/
public static long getAvailMemory(Context context) {
// 获取android当前可用内存大小
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
MemoryInfo memoryInfo = new MemoryInfo();
activityManager.getMemoryInfo(memoryInfo);
return memoryInfo.availMem;
}
use of android.app.ActivityManager in project superCleanMaster by joyoyao.
the class AppUtil method getRunningAppProcesses.
/**
* 描述:获取运行的进程列表.
*
* @param context
* @return
*/
public static List<AppProcessInfo> getRunningAppProcesses(Context context) {
ActivityManager activityManager = null;
List<AppProcessInfo> list = null;
PackageManager packageManager = null;
try {
activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
packageManager = context.getApplicationContext().getPackageManager();
list = new ArrayList<AppProcessInfo>();
// 所有运行的进程
List<RunningAppProcessInfo> appProcessList = activityManager.getRunningAppProcesses();
ApplicationInfo appInfo = null;
AppProcessInfo abAppProcessInfo = null;
PackageInfo packageInfo = getPackageInfo(context);
if (mProcessList != null) {
mProcessList.clear();
}
mProcessList = getProcessRunningInfo();
for (RunningAppProcessInfo appProcessInfo : appProcessList) {
abAppProcessInfo = new AppProcessInfo(appProcessInfo.processName, appProcessInfo.pid, appProcessInfo.uid);
appInfo = getApplicationInfo(context, appProcessInfo.processName);
if (appInfo != null) {
if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
abAppProcessInfo.isSystem = true;
} else {
abAppProcessInfo.isSystem = false;
}
Drawable icon = appInfo.loadIcon(packageManager);
String appName = appInfo.loadLabel(packageManager).toString();
abAppProcessInfo.icon = icon;
abAppProcessInfo.appName = appName;
} else {
// :服务的命名
if (appProcessInfo.processName.indexOf(":") != -1) {
appInfo = getApplicationInfo(context, appProcessInfo.processName.split(":")[0]);
Drawable icon = appInfo.loadIcon(packageManager);
abAppProcessInfo.icon = icon;
}
abAppProcessInfo.isSystem = true;
abAppProcessInfo.appName = appProcessInfo.processName;
}
/*
* AbPsRow psRow = getPsRow(appProcessInfo.processName);
* if(psRow!=null){ abAppProcessInfo.memory = psRow.mem; }
*/
ProcessInfo processInfo = getMemInfo(appProcessInfo.processName);
abAppProcessInfo.memory = processInfo.memory;
abAppProcessInfo.cpu = processInfo.cpu;
abAppProcessInfo.status = processInfo.status;
abAppProcessInfo.threadsCount = processInfo.threadsCount;
list.add(abAppProcessInfo);
}
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
use of android.app.ActivityManager in project QLibrary by DragonsQC.
the class AppUtils method isServiceRunning.
/**
* 检测服务是否运行
*
* @param context Context
* @param className 类名
* @return 服务是否运行
*/
public static boolean isServiceRunning(Context context, String className) {
boolean isRunning = false;
ActivityManager activityManager = (ActivityManager) context.getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningServiceInfo> servicesList = activityManager.getRunningServices(Integer.MAX_VALUE);
for (ActivityManager.RunningServiceInfo si : servicesList) {
if (className.equals(si.service.getClassName())) {
isRunning = true;
}
}
return isRunning;
}
Aggregations