Returns the Memory Class of the App or Context provided. - Android Hardware

Android examples for Hardware:Memory

Description

Returns the Memory Class of the App or Context provided.

Demo Code


//package com.java2s;

import android.app.ActivityManager;
import android.content.Context;

public class Main {
    /**/*from w w  w  .  jav  a  2s. c  o m*/
     * Returns the Memory Class of the App or Context provided.
     * <br><br>
     * Memory Class defines the application's maximum heap size. They are based on the
     * device's overall memory. The values are in base of 16. You may use
     * it to manage your application's memory properly.
     * <br><br>
     * Example Classes: 16, 24, 48, 64, 80, 96, 112, 128 etc...
     */
    public static int getMemoryClass(Context context) {

        if (context == null)
            return -1;

        ActivityManager am = (ActivityManager) context
                .getSystemService(Context.ACTIVITY_SERVICE);
        return am.getMemoryClass();
    }
}

Related Tutorials