Get Current Operating System In Adobe Air

14,745

Solution 1

Use Capabilities class:

import flash.system.Capabilities;

trace(Capabilities.os);

Solution 2

if((Capabilities.os.indexOf("Windows") >= 0))
{
     // in windows
}
else if((Capabilities.os.indexOf("Mac") >= 0))
{
// in mac
 } 
 else if((Capabilities.os.indexOf("Linux") >= 0))
 {
// in linux
 }

Solution 3

For clarity sake, I use this code (although it does the same thing as Mudasir's)

if(Capabilities.os.search("Windows")>=0)
     //do something

Here are what the docs say:

flash.system.Capabilities.os():String [Read Only] Specifies the current operating system. The os property can return the following strings: Operating system Value

Windows 7
Windows Vista
Windows Server 2008 R2
Windows Server 2008
Windows Home Server
Windows Server 2003 R2
Windows Server 2003
Windows Server XP 64
Windows XP
Windows 98
Windows 95
Windows NT
Windows 2000
Windows ME
Windows CE
Windows SmartPhone
Windows PocketPC
Windows CEPC
Windows Mobile
Mac OS "Mac OS X.Y.Z" (where X.Y.Z is the version number, for example: "Mac OS 10.5.2")
Linux "Linux" (Flash Player attaches the Linux version, such as "Linux 2.6.15-1.2054_FC5smp"
iPhone OS 4.1 "iPhone3,1"

The server string is OS.

Do not use Capabilities.os to determine a capability based on the operating system if a more specific capability property exists. Basing a capability on the operating system is a bad idea, since it can lead to problems if an application does not consider all potential target operating systems. Instead, use the property corresponding to the capability for which you are testing. For more information, see the Capabilities class description.

Language Version: 3.0 Player Version: Flash 9, AIR 1.0, Lite 4

Share:
14,745
Joel
Author by

Joel

I'm primarily a C# and Java developer. I also know Objective-C and have done some work with the iPhone SDK. I know some PHP, ASP.net, C++, and dabbled in some other languages.

Updated on June 03, 2022

Comments

  • Joel
    Joel about 2 years

    I'm making an App using Adobe Flex/Air. I was wondering if there is any way to get the Operating System the Air app is running on?

  • Adrian Pirvulescu
    Adrian Pirvulescu almost 15 years
    This is available in flash too :) not just in AIR :)
  • Asad
    Asad over 8 years
    but how can we identify Solaris OS
  • Asad
    Asad over 8 years
    how can we identify Solaris OS