Detect if Android or iOS within Flex Mobile application

Sometimes there is a need when you need to detect what environment your Flex mobile application is running.

Common scenario with my projects is to launch a Link to PDF to a external browser rather than using StegeWebView which is built in to Flex SDK.

There could be many other scenarios that I can think of but it depends on the Application writer why and when its required

Here is the code snippet that will help ya out

  1. public function getOS():String {
  2. switch(true)
  3. {
  4. case (Capabilities.version.indexOf('IOS') > -1):
  5. {
  6.  
  7. return "IOS";
  8. }
  9. case (Capabilities.version.indexOf('QNX') > -1):
  10. {
  11.  
  12. return "BB"; // blackberry
  13. }
  14. case (Capabilities.version.indexOf('AND') > -1):
  15. {
  16.  
  17. return "ANDROID";
  18. }
  19. default:
  20. return "";
  21. break;
  22. }
  23. }

If you would like to add anything to the above code please leave a comment.

 

Cheers

 

.

 

Search Terms:

Jaspreet Chahal

Self-confessed Max Payne and Howzat Cricket game addict. Big fan of Dharmendra, Keanu reeves & Lawrence "Larry" Page. I love my Wife, my son and bit of geeky stuff. I started falling in love with Blog'in last year. Writing is tending out to be fun. I write on situation I was in thus my post always travel around web development stuff. I hope you enjoy my posts.

More Posts - Website

Follow Me:
TwitterFacebookPinterestYouTube

Comments

  1. Cheers little helper says:

    Hi,
    this info was very helpful, but the head of the switch statement is typed wrong.
    It should test for true and not for Capabilities.version

    Linke this:
    switch(true){

    • jaschahal says:

      Thnkx for that. Well even if I would have left it like that It would still work (so the switch header was not wrong) but for clarity sake I’ve changed the switch header. Well this happens, when you try to write code while you are writing an article and not copy pasting the same from where you’ve already used it :)

  2. antonio says:

    thank’s o/

Speak Your Mind

*

CommentLuv badge