Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    /**
     * 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();
    }
}