Class MemoryInformation
- java.lang.Object
-
- com.zendesk.sdk.model.MemoryInformation
-
public class MemoryInformation extends java.lang.Object
This class is used to get information about the physical memory (RAM) that is available on the device
-
-
Field Summary
Fields Modifier and Type Field and Description static double
BYTES_MULTIPLIER
static int
EXPECTED_TOKEN_COUNT
-
Constructor Summary
Constructors Constructor and Description MemoryInformation(Context context)
Creates and initialises a MemoryInformation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description java.lang.String
formatMemoryUsage()
Formats the current memory usage of the device in megabytesint
getTotalMemory()
Gets the total memory in megabytes that this device has.int
getTotalMemoryApi()
Gets the total memory that this device has from the Android APIs directly.int
getTotalMemoryCompat()
Gets the total memory that this device has by reading /proc/meminfoint
getUsedMemory()
Returns the used memory in megabytesboolean
isLowMemory()
Determines whether the device is currently experiencing a low memory warning.
-
-
-
Field Detail
-
EXPECTED_TOKEN_COUNT
public static final int EXPECTED_TOKEN_COUNT
- See Also:
- Constant Field Values
-
BYTES_MULTIPLIER
public static final double BYTES_MULTIPLIER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MemoryInformation
public MemoryInformation(Context context)
Creates and initialises a MemoryInformation.This will also call
MemoryInformation.getTotalMemory()
to initialise the class.- Parameters:
context
- A context, used to query the system for memory information.
-
-
Method Detail
-
formatMemoryUsage
public java.lang.String formatMemoryUsage()
Formats the current memory usage of the device in megabytesThe display will look like the following.
300MB / 512MB
The formula used is (total - available) / total, i.e 300 is (total - available) and 512 is (total).
- Returns:
- the formatted memory usage
-
getUsedMemory
public int getUsedMemory()
Returns the used memory in megabytes- Returns:
- the used memory in megabytes
-
getTotalMemory
public int getTotalMemory()
Gets the total memory in megabytes that this device has.This version will automatically pick the best way of determining the total amount of memory depending on what Android API level the device is running on. If the API level is 17 or later the memory is read directly from the
MemoryInfo API
.If the API level is lower than 17 then the memory will be determined by examining the /proc/meminfo file.
- Returns:
- The total memory in megabytes
-
getTotalMemoryCompat
public int getTotalMemoryCompat()
Gets the total memory that this device has by reading /proc/meminfoPrefer the user of
getTotalMemory()
because this will select the best method of determining the total amount of memory.- Returns:
- the total memory in megabytes
-
getTotalMemoryApi
public int getTotalMemoryApi()
Gets the total memory that this device has from the Android APIs directly.Prefer the user of
getTotalMemory()
because this will select the best method of determining the total amount of memory.- Returns:
- the total memory in megabytes
-
isLowMemory
public boolean isLowMemory()
Determines whether the device is currently experiencing a low memory warning.- Returns:
- true if this device is experiencing a low memory warning at this instant, false otherwise.
-
-