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 long getAvailMemory(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); MemoryInfo memoryInfo = new MemoryInfo(); activityManager.getMemoryInfo(memoryInfo); return memoryInfo.availMem; }
From source file:Main.java
@SuppressWarnings("deprecation") public static String getRunningActivityName(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); return activityManager.getRunningTasks(1).get(0).topActivity.getClassName(); }
From source file:Main.java
/** * @param context/*from w ww .j a v a2 s. c o m*/ * @return */ public static int getMemoryClass(Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); int heapSize = manager.getMemoryClass(); return heapSize; }
From source file:Main.java
public static String getRunningActivityName(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); return activityManager.getRunningTasks(1).get(0).topActivity.getClassName(); }
From source file:Main.java
/** * @param context// w ww . j a v a 2 s . com * @return */ public static int getLargeMemoryClass(Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); int heapSize = manager.getLargeMemoryClass(); return heapSize; }
From source file:Main.java
public static ActivityManager getActivityManager(Context context) { ActivityManager result = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); if (result == null) throw new UnsupportedOperationException("Could not retrieve ActivityManager"); return result; }
From source file:Main.java
public static boolean isRun(Context context, Class<?> clazz) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningServiceInfo> serviceList = activityManager .getRunningServices(Integer.MAX_VALUE); if (!(serviceList.size() > 0)) { return false; }/*from w w w . j a va2 s. c o m*/ for (int i = 0; i < serviceList.size(); i++) { if (serviceList.get(i).service.getClassName().equals(clazz.getName())) { return true; } } return false; }
From source file:Main.java
public static String getSystemMemory(Context ctx) { String memory = ""; try {//from w w w .j ava 2 s .com ActivityManager _ActivityManager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE); ActivityManager.MemoryInfo minfo = new ActivityManager.MemoryInfo(); _ActivityManager.getMemoryInfo(minfo); memory = String.valueOf(minfo.availMem / (1024 * 1024)) + "MB"; } catch (Exception e) { } return memory; }
From source file:Main.java
public static boolean isTopActivy(Activity activity) { ActivityManager manager = (ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningTaskInfo> runningTaskInfos = manager.getRunningTasks(1); String cmpNameTemp = null;/* ww w .ja v a 2 s. c o m*/ if (null != runningTaskInfos) { cmpNameTemp = (runningTaskInfos.get(0).topActivity).toString(); } return null != cmpNameTemp && cmpNameTemp.equals(activity.getComponentName().toString()); }
From source file:Main.java
public static String getCurProcessName(Context context) { int pid = android.os.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 ww .j a v a2 s . c o m } return null; }