How to detect which device my app is running on?

Hi,

as there seems to be some variance with across the different devices I need to be able to query the device to find out which on it is.

Is there a call I can make to do this, cannot see one in the docs.

This is probably a key requirement for the SDK.

Ta
  • I think that currently only "simple" solution is to make string resource for each device type in which you define some string, i.e. deviceName.



    And then, in the constructor or in onLayout() method you can load this string..

    var deviceName = Ui.loadResource(Rez.Strings.deviceName);
    if (!deviceName.equals("fenix3") && !deviceName.equals("d2bravo")) {
    // do something
    }
  • This isn't available in the API. The original idea was to allow apps to be written once and run on any Connect IQ device, removing the need for the developer to check the device at runtime. Some of this is accomplished through the resource compiler and layout system, which you're probably acquainted with.

    Of course, the reality is that we have some fragmentation in our devices because they are purpose-made and don't all have the exact same feature set. This is an issue that we have discussed on more than one occasion, and we're working on ways to give the developer more control without straying from our original vision. I'm being intentionally vague, but in the end I think we'll have a more flexible approach.

    In the meantime, leveraging the resource compiler and the [FONT=courier new]has[/FONT] operator are your best tools for handling device-specific nuances.