当前位置: 首页>>代码示例>>Java>>正文


Java RunningAppProcessInfo.IMPORTANCE_BACKGROUND属性代码示例

本文整理汇总了Java中android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND属性的典型用法代码示例。如果您正苦于以下问题:Java RunningAppProcessInfo.IMPORTANCE_BACKGROUND属性的具体用法?Java RunningAppProcessInfo.IMPORTANCE_BACKGROUND怎么用?Java RunningAppProcessInfo.IMPORTANCE_BACKGROUND使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.app.ActivityManager.RunningAppProcessInfo的用法示例。


在下文中一共展示了RunningAppProcessInfo.IMPORTANCE_BACKGROUND属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isBackground

/**
 * 判断当前应用程序是否后台运行
 */
public static boolean isBackground(Context context) {
    ActivityManager activityManager = (ActivityManager) context
            .getSystemService(Context.ACTIVITY_SERVICE);
    List<RunningAppProcessInfo> appProcesses = activityManager
            .getRunningAppProcesses();
    for (RunningAppProcessInfo appProcess : appProcesses) {
        if (appProcess.processName.equals(context.getPackageName())) {
            if (appProcess.importance == RunningAppProcessInfo.IMPORTANCE_BACKGROUND) {
                // 后台运行
                return true;
            } else {
                // 前台运行
                return false;
            }
        }
    }
    return false;
}
 
开发者ID:inexistence,项目名称:VideoMeeting,代码行数:21,代码来源:SystemUtils.java

示例2: isBackground

/**
 * foreground or background
 */
public static boolean isBackground(Context context) {
    ActivityManager activityManager = (ActivityManager) context
            .getSystemService(Context.ACTIVITY_SERVICE);
    List<RunningAppProcessInfo> appProcesses = activityManager
            .getRunningAppProcesses();
    for (RunningAppProcessInfo appProcess : appProcesses) {
        if (appProcess.processName.equals(context.getPackageName())) {
            if (appProcess.importance == RunningAppProcessInfo.IMPORTANCE_BACKGROUND) {
                // background
                return true;
            } else {
                // foreground
                return false;
            }
        }
    }
    return false;
}
 
开发者ID:xwiki-contrib,项目名称:android-authenticator,代码行数:21,代码来源:SystemTools.java

示例3: isBackground

/**
 * @param context
 * @return
 */
public static boolean isBackground(final Context context) {

    final ActivityManager activityManager = (ActivityManager) context
            .getSystemService(Context.ACTIVITY_SERVICE);
    final List<RunningAppProcessInfo> appProcesses = activityManager
            .getRunningAppProcesses();
    for (final RunningAppProcessInfo appProcess : appProcesses) {
        if (appProcess.processName.equals(context.getPackageName())) {
            if (appProcess.importance == RunningAppProcessInfo.IMPORTANCE_BACKGROUND) {
                return true;
            } else {
                return false;
            }
        }
    }
    return false;
}
 
开发者ID:soarcn,项目名称:COCO-Accessory,代码行数:21,代码来源:Utils.java

示例4: getImportance

private String getImportance( RunningAppProcessInfo proc )
{
	String impt = "Empty"; //$NON-NLS-1$

	switch ( proc.importance )
	{
		case RunningAppProcessInfo.IMPORTANCE_BACKGROUND :
			impt = "Background"; //$NON-NLS-1$
			break;
		case RunningAppProcessInfo.IMPORTANCE_FOREGROUND :
			impt = "Foreground"; //$NON-NLS-1$
			break;
		case RunningAppProcessInfo.IMPORTANCE_PERCEPTIBLE :
			impt = "Perceptible"; //$NON-NLS-1$
			break;
		case RunningAppProcessInfo.IMPORTANCE_SERVICE :
			impt = "Service"; //$NON-NLS-1$
			break;
		case RunningAppProcessInfo.IMPORTANCE_VISIBLE :
			impt = "Visible"; //$NON-NLS-1$
			break;
	}

	return impt;
}
 
开发者ID:qauck,项目名称:qsysinfo,代码行数:25,代码来源:SysInfoManager.java

示例5: isBackground

public static boolean isBackground(Context context) {
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    List<RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses();
    for (RunningAppProcessInfo appProcess : appProcesses) {
        if (appProcess.processName.equals(context.getPackageName())) {
            return appProcess.importance == RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
        }
    }
    return false;
}
 
开发者ID:jeasinlee,项目名称:AndroidBasicLibs,代码行数:10,代码来源:SystemUtils.java

示例6: isSPARunnung

public boolean isSPARunnung() {
	ActivityManager activityManager = (ActivityManager) getSystemService( ACTIVITY_SERVICE );
	List<RunningAppProcessInfo> procInfos = activityManager.getRunningAppProcesses();
	for( int i = 0; i < procInfos.size(); i++ ) {
		if( procInfos.get( i ).processName.equals( Constants.SPA_PACKAGE_NAME ) ) {
			if( procInfos.get( i ).importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND || procInfos.get( i ).importance == RunningAppProcessInfo.IMPORTANCE_VISIBLE ) {
				return true;
			} else if( procInfos.get( i ).importance == RunningAppProcessInfo.IMPORTANCE_BACKGROUND && procInfos.get( i ).lru == Constants.BG_IMPORTANCE_LIVE ) {
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:SilentCircle,项目名称:silent-text-android,代码行数:14,代码来源:ConversationListActivity.java

示例7: includeAppFromProcess

private void includeAppFromProcess(MatrixCursor result, String docId, AndroidAppProcess processInfo, String query ) {

		String process = processInfo.name;
		final String packageName = processInfo.getPackageName();
		process = process.substring(process.lastIndexOf(".") + 1, process.length());
		String summary = "";
		String displayName = "";
		ApplicationInfo appInfo = null;
		try {
			appInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES).applicationInfo;
			displayName = process ;
		} catch (Exception e) { }

		if (TextUtils.isEmpty(displayName)) {
			displayName = process;
		}

		if (null != query && !displayName.toLowerCase().contains(query)) {
			return;
		}
		final String path = null != appInfo ? appInfo.sourceDir : "";
		final String mimeType = Document.MIME_TYPE_APK;

		int flags = Document.FLAG_SUPPORTS_DELETE | Document.FLAG_SUPPORTS_THUMBNAIL;
		if(isTelevision()) {
			flags |= Document.FLAG_DIR_PREFERS_GRID;
		}

		int importance = processInfo.foreground ? RunningAppProcessInfo.IMPORTANCE_FOREGROUND : RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
		summary = processTypeCache.get(importance);
		final long size = getProcessSize(processInfo.pid);


		final RowBuilder row = result.newRow();
		row.add(Document.COLUMN_DOCUMENT_ID, getDocIdForApp(docId, packageName));
		row.add(Document.COLUMN_DISPLAY_NAME, displayName);
		row.add(Document.COLUMN_SUMMARY, summary);
		row.add(Document.COLUMN_SIZE, size);
		row.add(Document.COLUMN_MIME_TYPE, mimeType);
		//row.add(Document.COLUMN_LAST_MODIFIED, lastModified);
		row.add(Document.COLUMN_PATH, path);
		row.add(Document.COLUMN_FLAGS, flags);
	}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:43,代码来源:AppsProvider.java

示例8: includeAppFromService

private void includeAppFromService(MatrixCursor result, String docId, RunningServiceInfo processInfo, String query ) {

		String process = processInfo.process;
		final String packageName = processInfo.process;
		process = process.substring(process.lastIndexOf(".") + 1, process.length());
		String summary = "";
		String displayName = "";
		ApplicationInfo appInfo = null;
		try {
			appInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES).applicationInfo;
			displayName = process ;
		} catch (Exception e) { }

		if (TextUtils.isEmpty(displayName)) {
			displayName = process;
		}

		if (null != query && !displayName.toLowerCase().contains(query)) {
			return;
		}
		final String path = null != appInfo ? appInfo.sourceDir : "";
		final String mimeType = Document.MIME_TYPE_APK;

		int flags = Document.FLAG_SUPPORTS_DELETE | Document.FLAG_SUPPORTS_THUMBNAIL;
		if(isTelevision()) {
			flags |= Document.FLAG_DIR_PREFERS_GRID;
		}

		int importance = processInfo.foreground ? RunningAppProcessInfo.IMPORTANCE_FOREGROUND : RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
		summary = processTypeCache.get(importance);
		final long size = getProcessSize(processInfo.pid);

		final RowBuilder row = result.newRow();
		row.add(Document.COLUMN_DOCUMENT_ID, getDocIdForApp(docId, packageName));
		row.add(Document.COLUMN_DISPLAY_NAME, displayName);
		row.add(Document.COLUMN_SUMMARY, summary);
		row.add(Document.COLUMN_SIZE, size);
		row.add(Document.COLUMN_MIME_TYPE, mimeType);
		//row.add(Document.COLUMN_LAST_MODIFIED, processInfo.lastActivityTime);
		row.add(Document.COLUMN_PATH, path);
		row.add(Document.COLUMN_FLAGS, flags);
	}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:42,代码来源:AppsProvider.java

示例9: runProcessGC

private void runProcessGC() {
    if (mHostContext == null) {
        return;
    }
    ActivityManager am = (ActivityManager) mHostContext.getSystemService(Context.ACTIVITY_SERVICE);
    if (am == null) {
        return;
    }

    List<RunningAppProcessInfo> infos = am.getRunningAppProcesses();
    List<RunningAppProcessInfo> myInfos = new ArrayList<RunningAppProcessInfo>();
    if (infos == null || infos.size() < 0) {
        return;
    }

    List<String> pns = mStaticProcessList.getOtherProcessNames();
    pns.add(mHostContext.getPackageName());
    for (RunningAppProcessInfo info : infos) {
        if (info.uid == android.os.Process.myUid()
                && info.pid != android.os.Process.myPid()
                && !pns.contains(info.processName)
                && mRunningProcessList.isPlugin(info.pid)
                && !mRunningProcessList.isPersistentApplication(info.pid)
                /*&& !mRunningProcessList.isPersistentApplication(info.pid)*/) {
            myInfos.add(info);
        }
    }
    Collections.sort(myInfos, sProcessComparator);
    for (RunningAppProcessInfo myInfo : myInfos) {
        if (myInfo.importance == RunningAppProcessInfo.IMPORTANCE_GONE) {
            doGc(myInfo);
        } else if (myInfo.importance == RunningAppProcessInfo.IMPORTANCE_EMPTY) {
            doGc(myInfo);
        } else if (myInfo.importance == RunningAppProcessInfo.IMPORTANCE_BACKGROUND) {
            doGc(myInfo);
        } else if (myInfo.importance == RunningAppProcessInfo.IMPORTANCE_SERVICE) {
            doGc(myInfo);
        } /*else if (myInfo.importance == RunningAppProcessInfo.IMPORTANCE_CANT_SAVE_STATE) {
            //杀死进程,不能保存状态。但是关我什么事?
        }*/ else if (myInfo.importance == RunningAppProcessInfo.IMPORTANCE_PERCEPTIBLE) {
            //杀死进程
        } else if (myInfo.importance == RunningAppProcessInfo.IMPORTANCE_VISIBLE) {
            //看得见
        } else if (myInfo.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
            //前台进程。
        }
    }

}
 
开发者ID:amikey,项目名称:DroidPlugin,代码行数:49,代码来源:MyActivityManagerService.java


注:本文中的android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。