Search in sources :

Example 76 with ActivityManager

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");
}
Also used : ProcessErrorStateInfo(android.app.ActivityManager.ProcessErrorStateInfo) ActivityManager(android.app.ActivityManager) IActivityManager(android.app.IActivityManager)

Example 77 with ActivityManager

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;
}
Also used : MemoryInfo(android.app.ActivityManager.MemoryInfo) ActivityManager(android.app.ActivityManager)

Example 78 with ActivityManager

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;
}
Also used : ActivityManager(android.app.ActivityManager)

Example 79 with ActivityManager

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());
}
Also used : Handler(android.os.Handler) ActivityManager(android.app.ActivityManager)

Example 80 with ActivityManager

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");
}
Also used : ProcessErrorStateInfo(android.app.ActivityManager.ProcessErrorStateInfo) ActivityManager(android.app.ActivityManager) IActivityManager(android.app.IActivityManager)

Aggregations

ActivityManager (android.app.ActivityManager)325 Intent (android.content.Intent)42 Context (android.content.Context)31 RunningAppProcessInfo (android.app.ActivityManager.RunningAppProcessInfo)28 ComponentName (android.content.ComponentName)24 PackageManager (android.content.pm.PackageManager)21 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)17 IActivityManager (android.app.IActivityManager)16 ConfigurationInfo (android.content.pm.ConfigurationInfo)16 RunningServiceInfo (android.app.ActivityManager.RunningServiceInfo)15 View (android.view.View)15 ImageView (android.widget.ImageView)15 IOException (java.io.IOException)15 Point (android.graphics.Point)14 TextView (android.widget.TextView)14 ArrayList (java.util.ArrayList)13 RunningTaskInfo (android.app.ActivityManager.RunningTaskInfo)12 ResolveInfo (android.content.pm.ResolveInfo)12 RemoteException (android.os.RemoteException)12 TargetApi (android.annotation.TargetApi)11