From 62f1912a7af3bdfcb0c7909c439ed29e7b19e26d Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Thu, 3 Nov 2022 15:19:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=8F=96=E5=86=85?= =?UTF-8?q?=E5=AD=98=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/yunbao/common/utils/DeviceUtils.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/yunbao/common/utils/DeviceUtils.java b/common/src/main/java/com/yunbao/common/utils/DeviceUtils.java index afce551d2..282fc17c2 100644 --- a/common/src/main/java/com/yunbao/common/utils/DeviceUtils.java +++ b/common/src/main/java/com/yunbao/common/utils/DeviceUtils.java @@ -5,6 +5,7 @@ import android.app.ActivityManager; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; +import android.text.format.Formatter; import android.util.DisplayMetrics; /** @@ -78,6 +79,12 @@ public class DeviceUtils { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo(); am.getMemoryInfo(mi); - return mi.lowMemory;// 将获取的内存大小规格化 + return mi.lowMemory; + } + public static String getMemory(Context context) { + ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); + ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo(); + am.getMemoryInfo(mi); + return Formatter.formatFileSize(context, mi.availMem);// 将获取的内存大小规格化 } } \ No newline at end of file