Example usage for android.app ActivityManager getMemoryInfo

List of usage examples for android.app ActivityManager getMemoryInfo

Introduction

In this page you can find the example usage for android.app ActivityManager getMemoryInfo.

Prototype

public void getMemoryInfo(MemoryInfo outInfo) 

Source Link

Document

Return general information about the memory state of the system.

Usage

From source file:Main.java

public static long getAvailableMemorySize(Context app_context) {
    ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
    ActivityManager activityManager = (ActivityManager) app_context.getSystemService(Service.ACTIVITY_SERVICE);
    activityManager.getMemoryInfo(mi);

    return mi.availMem;
}

From source file:Main.java

public static String getAvailMemory(Context c) {

    ActivityManager am = (ActivityManager) c.getSystemService(Context.ACTIVITY_SERVICE);
    MemoryInfo mi = new MemoryInfo();
    am.getMemoryInfo(mi);

    return Formatter.formatFileSize(c, mi.availMem);
}

From source file:Main.java

public static String getAvailMemory(Context context) {
    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    MemoryInfo mi = new MemoryInfo();
    am.getMemoryInfo(mi);
    return Formatter.formatFileSize(context, mi.availMem);
}

From source file:Main.java

public static long getAvailableROM(Context context) {

    ActivityManager am = (ActivityManager) context.getSystemService(context.ACTIVITY_SERVICE);
    MemoryInfo outInfo = new MemoryInfo();
    am.getMemoryInfo(outInfo);
    return outInfo.availMem;
}

From source file:Main.java

public static int getDeviceUsableMemory(Context cxt) {
    ActivityManager am = (ActivityManager) cxt.getSystemService(Context.ACTIVITY_SERVICE);
    MemoryInfo mi = new MemoryInfo();
    am.getMemoryInfo(mi);
    return (int) (mi.availMem / (1024 * 1024));
}

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

public static String getAvailMemory(Context context) {
    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
    am.getMemoryInfo(mi);
    System.out.println("availMem;" + mi.availMem);
    return Formatter.formatFileSize(context, mi.availMem);
}

From source file:Main.java

public static long getAvailMem(Context context) {
    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
    am.getMemoryInfo(memoryInfo);
    return memoryInfo.availMem;
}

From source file:Main.java

public static long getTotalMem(Context context) {
    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
    am.getMemoryInfo(memoryInfo);
    return memoryInfo.totalMem;
}

From source file:Main.java

/**
 * get usable memory for device//  ww w.  j  av  a2 s  .co m
 *
 * @param context
 * @return current usable memory
 */
public static int getDeviceUsableMemory(Context context) {
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
    activityManager.getMemoryInfo(mi);
    return (int) (mi.availMem / (1024 * 1024));
}