當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。