Search in sources :

Example 16 with ActivityManager

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;
}
Also used : ActivityManager(android.app.ActivityManager) ConfigurationInfo(android.content.pm.ConfigurationInfo)

Example 17 with ActivityManager

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;
}
Also used : ComponentName(android.content.ComponentName) ActivityManager(android.app.ActivityManager)

Example 18 with ActivityManager

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;
}
Also used : MemoryInfo(android.app.ActivityManager.MemoryInfo) ActivityManager(android.app.ActivityManager)

Example 19 with ActivityManager

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;
}
Also used : PackageInfo(android.content.pm.PackageInfo) ApplicationInfo(android.content.pm.ApplicationInfo) Drawable(android.graphics.drawable.Drawable) ProcessInfo(com.yzy.supercleanmaster.bean.ProcessInfo) AppProcessInfo(com.yzy.supercleanmaster.bean.AppProcessInfo) RunningAppProcessInfo(android.app.ActivityManager.RunningAppProcessInfo) ActivityManager(android.app.ActivityManager) AppProcessInfo(com.yzy.supercleanmaster.bean.AppProcessInfo) RunningAppProcessInfo(android.app.ActivityManager.RunningAppProcessInfo) IOException(java.io.IOException) PackageManager(android.content.pm.PackageManager) RunningAppProcessInfo(android.app.ActivityManager.RunningAppProcessInfo)

Example 20 with ActivityManager

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;
}
Also used : ActivityManager(android.app.ActivityManager)

Aggregations

ActivityManager (android.app.ActivityManager)612 Intent (android.content.Intent)61 RunningAppProcessInfo (android.app.ActivityManager.RunningAppProcessInfo)55 PackageManager (android.content.pm.PackageManager)50 Context (android.content.Context)47 ComponentName (android.content.ComponentName)44 RunningServiceInfo (android.app.ActivityManager.RunningServiceInfo)36 ArrayList (java.util.ArrayList)31 View (android.view.View)29 IOException (java.io.IOException)29 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)27 SuppressLint (android.annotation.SuppressLint)26 ImageView (android.widget.ImageView)25 TextView (android.widget.TextView)25 IActivityManager (android.app.IActivityManager)19 Point (android.graphics.Point)19 RemoteException (android.os.RemoteException)19 MemoryInfo (android.app.ActivityManager.MemoryInfo)18 Bitmap (android.graphics.Bitmap)18 AdapterView (android.widget.AdapterView)18