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 boolean isProessRunning(Context context, String proessName) { boolean isRunning = false; android.app.ActivityManager am = (android.app.ActivityManager) context .getSystemService(Context.ACTIVITY_SERVICE); List<android.app.ActivityManager.RunningAppProcessInfo> lists = am.getRunningAppProcesses(); for (android.app.ActivityManager.RunningAppProcessInfo info : lists) { if (info.processName.equals(proessName)) { isRunning = true;/*from ww w . j av a2s . c om*/ return isRunning; } } return isRunning; }
From source file:Main.java
private static long getAvailabeMemoryM(final Context cxt) { MemoryInfo mi = new MemoryInfo(); ActivityManager activityManager = (ActivityManager) cxt.getSystemService(Context.ACTIVITY_SERVICE); activityManager.getMemoryInfo(mi);/*from w w w . j ava 2 s . c o m*/ return mi.availMem / 1024 / 1024; }
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)) { return true; }//from w w w . j a v a 2 s. com } return false; }
From source file:Main.java
public static boolean isServerRunning(Class server) { if (server == null) { return false; }// w w w . j ava2 s.c om ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); // am.getRunningServiceControlPanel() return false; }
From source file:Main.java
public static boolean isServiceRunning(Context context, String service) { ActivityManager actManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ArrayList<ActivityManager.RunningServiceInfo> serviceList = (ArrayList<ActivityManager.RunningServiceInfo>) actManager .getRunningServices(50);// ww w. j a va 2s .c o m for (int n = 0; n < serviceList.size(); n++) { if (serviceList.get(n).service.getClassName().toString().equals(service)) { return true; } } return false; }
From source file:Main.java
public static String getApplicationState(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses(); if (appProcesses == null) { return ""; }/*from w w w. ja va 2s .com*/ String packageName = context.getPackageName(); for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) { if (appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND && appProcess.processName.equals(packageName)) { return "Foreground"; } } return "Background"; }
From source file:Main.java
public static String getCurrentProcessName(Context context) { String currentProcName = ""; int pid = android.os.Process.myPid(); ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); if (manager == null) { return ""; }/*from w w w. ja v a 2 s . c o m*/ for (ActivityManager.RunningAppProcessInfo processInfo : manager.getRunningAppProcesses()) { if (processInfo.pid == pid) { currentProcName = processInfo.processName; } } return currentProcName; }
From source file:Main.java
public static ActivityManager getActivityManager(Context context) { if (context == null) { throw new NullPointerException("context can not be empty"); }/*from ww w . j a v a 2s . c o m*/ return (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); }
From source file:Main.java
public static boolean isAppOnForeground(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); // Returns a list of application processes that are running on the // device//from ww w .j a v a 2 s .c o m List<RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses(); if (appProcesses == null) return false; for (RunningAppProcessInfo appProcess : appProcesses) { if (appProcess.processName.equals(context.getPackageName()) && appProcess.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) { return true; } } return false; }
From source file:Main.java
public static String getCurrentProcessName(Context pContext) { int pid = android.os.Process.myPid(); ActivityManager mActivityManager = (ActivityManager) pContext.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningAppProcessInfo appProcess : mActivityManager.getRunningAppProcesses()) { if (appProcess.pid == pid) { return appProcess.processName; }//from ww w .ja v a 2 s . c o m } return ""; }