How to get Android version and device RAM size?

Asked

Viewed 75 times

1

I’m developing an app that checks Versao Android and Memory Ram Size.

How can I get this information?

1 answer

2


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

String release = Build.VERSION.RELEASE;

Values, in Mb, relative to RAM can be obtained thus:

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.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.