system.getInfo()

Type Function
Library system.*
Return value various
Revision Current Public Release (2014.2511)
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 hdpi 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 "androidDisplayXDpi" and "androidDisplayYDpi".

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
xxxhdpi 640
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"
  • "xxxhdpi"
  • "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.

  • Android — Returns the app's Version Name.
  • iOS — Returns the app's CFBundleVersionString.
  • Windows Phone 8 — Not supported.
  • Corona Simulator — Not supported.

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

OS X may return i386, x86\_64, ppc, or ppc64 (currently only i386 is available).

Windows Desktop and Windows Phone can return x86, x64, IA64, or ARM.

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 iOS6 and later, "deviceID" returns a MD5 hash of the device's "identifierForVendor".

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.

On Windows Phone, this will return "Not Supported Yet".

environment

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

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

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" (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"

This is not currently supported on Windows Phone.

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".

This is not supported on Android or Windows Phone.

platformName

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

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

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.

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)
  • "windows" — targets the Windows app store (only returned on Windows Phone)
  • "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