use of android.app.ActivityManager in project android_frameworks_base by DirtyUnicorns.
the class AppLaunch method reportError.
private void reportError(String appName, String processName) {
ActivityManager am = (ActivityManager) getInstrumentation().getContext().getSystemService(Context.ACTIVITY_SERVICE);
List<ProcessErrorStateInfo> crashes = am.getProcessesInErrorState();
if (crashes != null) {
for (ProcessErrorStateInfo crash : crashes) {
if (!crash.processName.equals(processName))
continue;
Log.w(TAG, appName + " crashed: " + crash.shortMsg);
mResult.putString(mNameToResultKey.get(appName), crash.shortMsg);
return;
}
}
mResult.putString(mNameToResultKey.get(appName), "Crashed for unknown reason");
Log.w(TAG, appName + " not found in process list, most likely it is crashed");
}
use of android.app.ActivityManager in project android_frameworks_base by DirtyUnicorns.
the class SurfaceCompositionMeasuringActivity method getMemoryInfo.
private MemoryInfo getMemoryInfo() {
ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
MemoryInfo memInfo = new MemoryInfo();
activityManager.getMemoryInfo(memInfo);
return memInfo;
}
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;
}
use of android.app.ActivityManager in project android_frameworks_base by DirtyUnicorns.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mBackgroundPolling = new Runnable() {
// Poll lock task state and set background pink if locked, otherwise white.
@Override
public void run() {
if (!mRunning) {
return;
}
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
final int color = activityManager.getLockTaskModeState() != ActivityManager.LOCK_TASK_MODE_NONE ? 0xFFFFC0C0 : 0xFFFFFFFF;
findViewById(R.id.root_launch).setBackgroundColor(color);
mHandler.postDelayed(this, 500);
}
};
mHandler = new Handler(Looper.getMainLooper());
}
use of android.app.ActivityManager in project android_frameworks_base by DirtyUnicorns.
the class MemoryUsageTest method reportError.
private void reportError(String appName, String processName, Bundle results) {
ActivityManager am = (ActivityManager) getInstrumentation().getContext().getSystemService(Context.ACTIVITY_SERVICE);
List<ProcessErrorStateInfo> crashes = am.getProcessesInErrorState();
if (crashes != null) {
for (ProcessErrorStateInfo crash : crashes) {
if (!crash.processName.equals(processName))
continue;
Log.w(TAG, appName + " crashed: " + crash.shortMsg);
results.putString(mNameToResultKey.get(appName), crash.shortMsg);
return;
}
}
results.putString(mNameToResultKey.get(appName), "Crashed for unknown reason");
Log.w(TAG, appName + " not found in process list, most likely it is crashed");
}
Aggregations