Code example for ActivityManager

Methods: getProcessMemoryInfo

0
        return sb.toString();
    } 
 
    private String getMemoryInfo(ActivityManager am, int id) {
        StringBuilder sb = new StringBuilder();
        Debug.MemoryInfo[] mem = am.getProcessMemoryInfo(new int[]{id});
        Debug.MemoryInfo memoryInfo = mem[0];
 
        sb.append(String.format("dalvikPss: %d KB%n", memoryInfo.dalvikPss));
        sb.append(String.format("dalvikSharedDirty: %d KB%n", memoryInfo.dalvikSharedDirty));
        sb.append(String.format("dalvikPrivateDirty: %d KB%n", memoryInfo.dalvikPrivateDirty));
 
        sb.append(String.format("totalPssDirty: %d KB%n", memoryInfo.getTotalPss()));
        sb.append(String.format("totalSharedDirty: %d KB%n", memoryInfo.getTotalSharedDirty()));
        sb.append(String.format("totalPrivateDirty: %d KB%n", memoryInfo.getTotalPrivateDirty()));
 
        return sb.toString();
    } 
 
    public int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {
        // Raw height and width of image