Is there a way for a widget to know it's running in the simlator vs real device

I'm working on a widget that used phoneConnected (with the proper "HAS") so that it only tries to do a makeJsonRequest if the phone is connected, and if there is no phone, I just display a message to the effect.

It works fine on the real devices, but with the simulator, there is no way to toggle phoneConnect. Therefore, I need to manually set a boolean (so it can ignore phoneConnected) and build that way I want to test it in the simultor, and then change it again to test on the real device.

If there was some way to know if it's running in the simulator during run time, it would make things a bit easier.

No biggie, but it would be nice.
  • Former Member
    Former Member over 10 years ago
    You can use some hack, and get diff between other settings (is24Hour, vibrateOn etc).

    var phoneConnected;
    if (DeviceSettings.is24Hour) {
    // device
    phoneConnected=DeviceSettings.phoneConnect;
    }
    else {
    // symulator
    phoneConnected=true;
    }

    But You must remember make changes, but only before make .iq for shop.
  • There isn't a way to tell if you're running on the sim or not. We have a task to make these settings configurable in the simulator, as many device settings are just currently hard coded. Ideally you shouldn't need to know if you're running in the sim or not, but we're not at that point yet. If there is a real need to know, we could add a DeviceSettings.isSimulator, but I think we'd need some good reasons to add that field.