List of usage examples for android.content Context ACTIVITY_SERVICE
String ACTIVITY_SERVICE
To view the source code for android.content Context ACTIVITY_SERVICE.
Click Source Link
From source file:Main.java
public static void disableRecentAppsClick(Activity activity) { ActivityManager activityManager = (ActivityManager) activity.getApplicationContext() .getSystemService(Context.ACTIVITY_SERVICE); activityManager.moveTaskToFront(activity.getTaskId(), 0); }
From source file:Main.java
public static boolean isSystemMemoryLow(Context context) { ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo(); ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); activityManager.getMemoryInfo(mi);// www. java 2 s . co m return mi.lowMemory; }
From source file:Main.java
public static long getSystemMemoryThreshold(Context context) { ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo(); ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); activityManager.getMemoryInfo(mi);/*w w w . j a va 2 s .c o m*/ return mi.threshold; }
From source file:Main.java
public static boolean isAppAlive(Context context, String packageName) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningAppProcessInfo> processInfos = activityManager.getRunningAppProcesses(); for (int i = 0; i < processInfos.size(); i++) { if (processInfos.get(i).processName.equals(packageName)) { Log.i("NotificationLaunch", String.format("the %s is running, isAppAlive return true", packageName)); return true; }/*from w w w . j a va2 s . com*/ } Log.i("NotificationLaunch", String.format("the %s is not running, isAppAlive return false", packageName)); return false; }
From source file:Main.java
public static ActivityManager.RunningServiceInfo getServiceInfo(Context context, Class<? extends Service> cls) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo info : manager.getRunningServices(Integer.MAX_VALUE)) { if (cls.getName().equals(info.service.getClassName())) { return info; }// w w w . j a v a 2 s .c om } return null; }
From source file:Main.java
public static List<RunningAppProcessInfo> getRunningProcesses(Context ctx) { ActivityManager am = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE); return am.getRunningAppProcesses(); }
From source file:Main.java
public static boolean isAppRunning(Context context, String packageName) { if (packageName == null) return false; ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses(); if (appProcesses == null) return false; for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) { if (appProcess.processName.equals(packageName)) { return true; }/*from w w w.j a va 2 s .co m*/ } return false; }
From source file:Main.java
private static String getCurProcessName(Context context) { int pid = Process.myPid(); ActivityManager mActivityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningAppProcessInfo appProcess : mActivityManager.getRunningAppProcesses()) { if (appProcess.pid == pid) { return appProcess.processName; }//from w w w.j a va2 s. c om } return null; }
From source file:Main.java
public static boolean isServiceRunning(Context context, String serviceName) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { //Log.d(LOG_TAG,"Service: " + service.service.getClassName() + "; " + service.pid + "; " + service.clientCount + "; " + service.foreground + "; " + service.process); if (serviceName.equals(service.service.getClassName())) { return true; }//w w w . j av a 2 s .c o m } return false; }
From source file:Main.java
public static boolean isServiceRunning(Context context, String className) { boolean isRunning = false; ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningServiceInfo> serviceList = activityManager .getRunningServices(Integer.MAX_VALUE); if (serviceList == null || serviceList.isEmpty()) return false; for (int i = 0; i < serviceList.size(); i++) { if (serviceList.get(i).service.getClassName().equals(className) && TextUtils.equals(serviceList.get(i).service.getPackageName(), context.getPackageName())) { isRunning = true;// ww w .ja v a2 s . c om break; } } return isRunning; }