Skip to content

Instantly share code, notes, and snippets.

@sergeioff
sergeioff / IsDeviceLowEnd.java
Last active November 15, 2017 14:01 — forked from Ray33/IsDeviceLowEnd.java
Check if device is low end.Low end= Low Memory || Bad Network
private boolean getIsLowDevice(Context context) {
ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
ActivityManager activityManager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
activityManager.getMemoryInfo(mi);
double availableMegs = (double)mi.availMem / 0x100000L;
String networkType = getNetworkClass(context);
return "2G".equalsIgnoreCase(networkType) || availableMegs <= 400;
}