com.jaredrummler.android.processes.ProcessManager Java Examples

The following examples show how to use com.jaredrummler.android.processes.ProcessManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DataHelper.java    From AppPlus with MIT License 6 votes vote down vote up
/**
 * get the running app list info
 * @param ctx
 * @return
 */
public static Observable<List<AppEntity>> getRunningAppEntity(final Context ctx) {
    return RxUtil.makeObservable(new Callable<List<AppEntity>>() {
        @Override
        public List<AppEntity> call() throws Exception {
            List<ActivityManager.RunningAppProcessInfo> runningList = ProcessManager.getRunningAppProcessInfo(ctx);
            Logger.i("=====","runing size is "+runningList.size());
            List<AppEntity> list = new ArrayList<>();
            for (ActivityManager.RunningAppProcessInfo processInfo : runningList) {
                String packageName = processInfo.processName;
                if (isNotShowSelf(ctx, packageName)) continue;
                AppEntity entity = DataHelper.getAppByPackageName(packageName);
                if (entity == null) continue;
                list.add(entity);
            }
            return list;
        }
    });
}