How do I get the version of Android and the size of the device's RAM?

1

I'm developing an app that checks Android version and Ram Memory Size.

How can I get this information?

    
asked by anonymous 12.03.2017 / 17:13

1 answer

2

The version of Android can be obtained through the class Build.VERSION .

String release = Build.VERSION.RELEASE;

Values, in Mb, relative to RAM can be obtained as follows:

ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
activityManager.getMemoryInfo(mi);
long memoriaLivre = mi.availMem / 1048576L;
long memoriaTotal = mi.totalMem / 1048576L;
long memoriaEmUso = totalMemory - freeMemory;

The value of totalMem is the total memory available to the kernel, which is approximately equal to the total RAM.

    
12.03.2017 / 20:46