Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Determ in code - if running in simulator?

Hi,

Is it possible to "determ" if the device is running in a simulator or in a real phone by code?

When coding for geolocation, it would have been nice to manually code my long and latitude positions…..

Joakim

— asked November 10th 2010 by Joakim Krassman
  • gps
  • sdk
0 Comments

1 Answer

  • Accepted Answer

    if (Titanium.Platform.model == 'google_sdk' || Titanium.Platform.model == 'Simulator') { //Whatever is unique to simulator }

    Something in this lines…

    — answered November 10th 2010 by Jeffrey Messick
    permalink
    2 Comments
    • Perhaps the API has changed since this answer was posted, but the string to test for the iPhone Simulator should say 'iPhone Simulator' and not 'Simulator'. The 'google_sdk' string is still correct to test for the Android Emulator.

      — commented September 12th 2011 by Vui Nguyen
    • Things keep changing. Currently when I debug my device model as provided by Titanium, it just says "Simulator" when testing on iPhone Simulator or iPad Simulator.

      — commented February 19th 2013 by remko posthuma
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.