Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.app.Activity;
import android.app.ActivityManager;

public class Main {
    public static int getRamUsing(Activity mActivity) {
        ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
        ActivityManager activityManager = (ActivityManager) mActivity.getSystemService(Activity.ACTIVITY_SERVICE);
        activityManager.getMemoryInfo(mi);

        float availableMegs = (mi.totalMem - mi.availMem) / 1048576L;
        return (int) availableMegs;
    }
}