package com.test.basd.onecleanmaster.display

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

object RamMemoryEx {
    fun getMemoryUsage(context: Context): Float {
        val activityManager: ActivityManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
        val memoryInfo: ActivityManager.MemoryInfo = ActivityManager.MemoryInfo()
        activityManager.getMemoryInfo(memoryInfo)
        val totalMemory: Long = memoryInfo.totalMem
        val availableMemory: Long = memoryInfo.availMem
        val usedMemory = (totalMemory - availableMemory).toDouble()
        return ((usedMemory / totalMemory) * 100).toFloat()
    }
}

