本文整理匯總了Java中android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_EMPTY屬性的典型用法代碼示例。如果您正苦於以下問題:Java RunningAppProcessInfo.IMPORTANCE_EMPTY屬性的具體用法?Java RunningAppProcessInfo.IMPORTANCE_EMPTY怎麽用?Java RunningAppProcessInfo.IMPORTANCE_EMPTY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.app.ActivityManager.RunningAppProcessInfo
的用法示例。
在下文中一共展示了RunningAppProcessInfo.IMPORTANCE_EMPTY屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isRunning
/**
* Helper to query whether an application is currently running and its code has not been evicted from memory.
*
* @param context the Context
* @param appName the package name or process name of the application.
* @return true if the application is running, false otherwise.
*/
public static boolean isRunning(final Context context, String appName) {
List<RunningAppProcessInfo> runningProcessInfo = Process.getRunningProcessInfo(context);
List<RunningServiceInfo> services = Service.getRunningServiceInfo(context);
for (RunningAppProcessInfo info : runningProcessInfo) {
if (info.processName.equals(appName) &&
info.importance != RunningAppProcessInfo.IMPORTANCE_EMPTY) {
return true;
}
}
for (RunningServiceInfo service: services) {
String name = StringHelper.formatProcessName(service.process);
if (name.equals(appName)) return true;
}
return false;
}
示例2: includeAppFromProcess
private void includeAppFromProcess(MatrixCursor result, String docId, RunningAppProcessInfo processInfo, String query ) {
if (processInfo.importance != RunningAppProcessInfo.IMPORTANCE_EMPTY
&& processInfo.importance != RunningAppProcessInfo.IMPORTANCE_PERCEPTIBLE) {
String process = processInfo.processName;
process = process.substring(process.lastIndexOf(".") + 1, process.length());
String summary = "";
String displayName = "";
ApplicationInfo appInfo = null;
try {
appInfo = packageManager.getPackageInfo(processInfo.processName, PackageManager.GET_ACTIVITIES).applicationInfo;
displayName = process ;//(String) (appInfo.loadLabel(packageManager) != null ? appInfo.loadLabel(packageManager) : appInfo.packageName);
} 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;
}
summary = processTypeCache.get(processInfo.importance);
final long size = getProcessSize(processInfo.pid);
final String packageName = processInfo.processName;
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);
}
}
示例3: 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) {
//前台進程。
}
}
}