List of usage examples for android.app ActivityManager getMemoryInfo
public void getMemoryInfo(MemoryInfo outInfo)
From source file:Main.java
public static long getRunningProcess(Context context) { int sdkInt = android.os.Build.VERSION.SDK_INT; if (sdkInt >= 16) { ActivityManager am = (ActivityManager) context.getSystemService(context.ACTIVITY_SERVICE); MemoryInfo outInfo = new MemoryInfo(); am.getMemoryInfo(outInfo); return outInfo.totalMem; } else {//from w w w . j a v a 2 s .com return getRunningProcess(); } }
From source file:Main.java
public static String getSystemMemory(Context ctx) { String memory = ""; try {//from w w w . j a v a 2 s . c o m 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
private static float getMemeorySize(Context context) { if (Build.VERSION.SDK_INT >= 16) { ActivityManager actManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo(); actManager.getMemoryInfo(memInfo); float totalMemory = (memInfo.totalMem / 1073741824.0f); return totalMemory; } else {/*w ww.ja v a 2 s. c om*/ return getTotalRAM(); } }
From source file:com.zjxfood.photoview.activity.ViewPagerActivity.java
public static long getmem_UNUSED(Context mContext) { long MEM_UNUSED; // ActivityManager ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); // ActivityManager.MemoryInfo ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo(); am.getMemoryInfo(mi); // ? //ww w . j ava2 s. c o m MEM_UNUSED = mi.availMem / 1024; Log.i("MEM_UNUSED", MEM_UNUSED + "==========MEM_UNUSED============"); return MEM_UNUSED; }
From source file:count.ly.messaging.CrashDetails.java
/** * Returns the current device RAM amount. *//*from w w w. j a v a 2 s .c o m*/ static String getRamCurrent(Context context) { ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo(); ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); activityManager.getMemoryInfo(mi); return Long.toString(getTotalRAM() - (mi.availMem / 1048576L)); }
From source file:com.ruesga.rview.misc.BitmapUtils.java
public static int calculateMaxAvailableSize(Context context) { if (AndroidHelper.isJellyBeanOrGreater()) { ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo(); ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); activityManager.getMemoryInfo(mi); return (int) ((mi.totalMem / 1073741824) * 1024); }// w ww .j ava 2 s . c om // The minimum for all android devices return 1024; }
From source file:org.opensilk.music.MusicApp.java
/** Disable some features depending on device type */ @SuppressWarnings("NewApi") @DebugLog/*from www .j ava 2 s . co m*/ public static boolean isLowEndHardware(Context context) { ActivityManager am = (ActivityManager) context.getSystemService(ACTIVITY_SERVICE); if (VersionUtils.hasKitkat()) { return am.isLowRamDevice(); } else if (VersionUtils.hasJellyBean()) { ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo(); am.getMemoryInfo(mi); return mi.totalMem < (512 * 1024 * 1024); } else { return Runtime.getRuntime().availableProcessors() == 1; } }
From source file:library.artaris.cn.library.utils.SystemUtils.java
/** * ??/*ww w. java2 s . c o m*/ * @param context * @return */ public static int getDeviceUsableMemory(Context context) { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); MemoryInfo mi = new MemoryInfo(); am.getMemoryInfo(mi); return (int) (mi.availMem / (1024 * 1024)); }
From source file:com.taobao.weex.utils.WXUtils.java
public static long getAvailMemory(Context context) { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo(); am.getMemoryInfo(mi); //mi.availMem; ?? //return Formatter.formatFileSize(context, mi.availMem);// ?? WXLogUtils.w("app AvailMemory ---->>>" + mi.availMem / (1024 * 1024)); return mi.availMem / (1024 * 1024); }
From source file:com.appassit.common.Utils.java
public static long getAvailMemory() { ActivityManager am = (ActivityManager) SLAppication.getContext().getSystemService(Context.ACTIVITY_SERVICE); MemoryInfo mi = new MemoryInfo(); am.getMemoryInfo(mi); // mi.availMem; ?? return mi.availMem;// ?? }