system.getInfo()

Type Function
Library system.*
Return value various
Revision Current Public Release (2014.2189)
Keywords system info

Overview

Returns information about the system on which the application is running.

Syntax

system.getInfo( property )
property (required)

String. The name of the property corresponding to the desired information — see Properties below.

Properties

androidAppVersionCode

On Android, "androidAppVersionCode" returns the application's version code as a number. Returns nil on all other platforms.

androidAppPackageName

On Android, "androidAppPackageName" returns the application's unique dot-separated package name. Returns nil on all other platforms.

androidDisplayApproximateDpi

On Android, "androidDisplayApproximateDpi" returns the approximate DPI (dots per inch) of the screen as a number. This DPI value is based on the device's assigned density name, such as hdp or xhdpi, which provide standardized DPI values on Android. This value is typically not the actual DPI of the display, which you can fetch using the "androidDisplayXDpi" and "androidDisplayYDpi" property names instead.

The following table lists the DPI values that will be returned for each display density type. This function returns nil on all other platforms.

Density DPI
ldpi 120
mdpi 160
hdpi 240
xhdpi 320
xxhdpi 480
tvdpi 213

androidDisplayDensityName

On Android, "androidDisplayDensityName" returns the device's screen density as a string, which can be one of the following. This function returns nil on all other platforms.

  • "ldpi"
  • "mdpi"
  • "hdpi"
  • "xhdpi"
  • "xxhdpi"
  • "tvdpi"
  • "unknown"

androidDisplayWidthInInches

On Android, "androidDisplayWidthInInches" returns the width of the application window in inches, relative to the orientation of the application. Returns nil on all other platforms.

androidDisplayHeightInInches

On Android, "androidDisplayHeightInInches" returns the height of the application window in inches, relative to the orientation of the application. Returns nil on all other platforms.

androidDisplayXDpi

On Android, "androidDisplayXDpi" returns the DPI (dots per inch) of the screen along the x axis, relative to the orientation of the application. This can be used to convert pixels to inches and vice-versa. Returns nil on all other platforms.

androidDisplayYDpi

On Android, "androidDisplayYDpi" returns the DPI (dots per inch) of the screen along the y axis, relative to the orientation of the application. This can be used to convert pixels to inches and vice-versa. Returns nil on all other platforms.

appName

"appName" returns the application's name that is displayed to the end user.

appVersionString

"appVersionString" returns the application's version as a string. For Android apps, this is the Version Name.

architectureInfo

"architectureInfo" returns a string describing the underlying CPU architecture of the device you are running on. This API is mostly for internal debugging but may have uses. Strings may be subject to changes in the future depending on the changing landscape of devices and CPUs.

Android on ARM devices will return "ARM" (typically for ARMv6) or "ARM Neon" (ARMv7). iOS will return values such as "iPhone1,1" or "iPhone1,2", where mappings are:

  • "iPhone1,1" = iPhone 1G
  • "iPhone1,2" = iPhone 3G
  • "iPhone2,1" = iPhone 3GS
  • "iPod1,1" = iPod touch 1G
  • "iPod2,1" = iPod touch 2G

Mac may return i386, x86\_64, ppc, or ppc64 (currently only i386 is available). Windows is currently unsupported.

build

"build" returns the Corona build string as it appears in the About box of the Corona Simulator.

deviceID

On iOS, "deviceID" returns a "unique" id for the device. Per Apple's policies, on iOS 6 and later, "deviceID" returns a MD5 hash of the device's "identifierForVendor" (see below); on iOS 5 it returns a MD5 of a GUID (Globally Unique Identifier) that is unique for each app install.

On Android, if your app uses the "android.permission.READ\_PHONE\_STATE" permission, the following will be returned:

  • IMEI for GSM phones.
  • MEID or ESN for CDMA phones.
  • The operating system's unique ID for devices that are not phones.

If your Android app does not use the "android.permission.READ\_PHONE\_STATE" permission, then the operating system's unique ID will be returned for all devices. Note that the operating system's unique ID may change after re-installing the operating system on the device.

environment

"environment" returns the environment that the app is running in. These include:

  • "simulator" — the Corona Simulator
  • "device" — iOS, Android device, and Xcode Simulator

GL_VENDOR

Returns the company responsible for the GL implementation on this device. See here for details.

GL_RENDERER

Returns the name of the GL renderer. See here for details.

GL_VERSION

Returns the GL version. See here for details.

GL_SHADING_LANGUAGE_VERSION

Returns the GL version or release number for the GLSL shading language. See here for details.

GL_EXTENSIONS

Returns the list of extensions supported on this device. See here for details.

gpuSupportsHighPrecisionFragmentShaders

Returns a boolean indicating whether HIGHP is supported in fragment shaders on this device.

iosIdentifierForVendor

On iOS, "iosIdentifierForVendor" returns the value of "identifierForVendor" for use in advertising logic (see here).

model

"model" returns the device model (as specified by the manufacturer). Note that most Android devices return a model number instead of a model name. Examples include:

  • "iPhone"
  • "iPad"
  • "iPhone Simulator"
  • "iPad Simulator"
  • "Nexus One"
  • "Droid"
  • "Galaxy Tab"

name

"name" returns the human-readable model name. On iPhone, this would be the name of the phone as it appears in iTunes, for example "Steve's iPhone".

platformName

"platformName" returns the platform name (the OS name), for example:

  • "Mac OS X" — Corona Simulator on Mac
  • "Win" — Corona Simulator on Windows
  • "iPhone OS" — all iOS devices and Xcode Simulator
  • "Android" — all Android devices

platformVersion

"platformVersion" returns a string representation of the platform version. This is sometimes, but not always, a number — for example, a Droid X currently returns 2.1-update1.

maxTextureSize

"maxTextureSize" returns the maximum texture width or height supported by the device.

maxTextureUnits

"maxTextureUnits" returns the maximum number of texture units available on the device. This number is based on the hardware limits of the device itself. Each image, mask, or text object consumes one texture unit. Typically, you'd care about the number of texture units when you want to achieve multiple nested masks. In other words, this number determines the depth of the nested masking you can achieve. For example, consider an image with a mask applied to it that is inside a group with a mask applied to it. In this case, 3 texture units are required: one for the image, one for the image's mask, and one for the group's mask.

targetAppStore

"targetAppStore" returns the name of the app store that the application was built for.

  • "apple" — always returned on iOS
  • "amazon" — targets the Amazon app store (only returned on Android)
  • "gameStick" — targets the GameStick console's app store (only returned on Android)
  • "google" — targets Google Play (only returned on Android)
  • "nook" — targets Barnes & Noble's Nook app store (only returned on Android)
  • "ouya" — targets the Ouya game console's app store (only returned on Android)
  • "samsung" — targets the Samsung app store (only returned on Android)
  • "none" — indicates that the app is not targeting a specific app store. This is always returned by the Corona Simulator.

textureMemoryUsed

"textureMemoryUsed" returns the texture memory usage (in bytes). Texture memory for graphics/images tends to be the most sharply limited resource in mobile development since it runs out before normal memory.

version

"version" is now deprecated. Use "build" to distinguish between different Corona build versions.

Example

The following checks to see if user is running the app in the simulator:

local environment = system.getInfo( "environment" )
if environment == "simulator" then
    print( "You're in the simulator." )
end