In App Device Detection

Former Member
Former Member
Is it possible to detect which device the app is running on? I would like to change on screen text prompts so that they reflect correct input methods for the given watch.
  • what I did was this..

    Main folder
    -Resources
    -- resources.xml (with string fenix3)
    -resources-VivoActive
    -- resources.xml (with string VivoActive)
    -resources-fr920xt
    -- resources.xml (with string fr920xt)

    After that, in the source, I just made a test with the following on the onLayout()
    var device = Ui.loadResource(Rez.Strings.device);
    Sys.println("device:" + device);


    After that, I run the simulator, explicitly calling it to be run as a VivoActive (for example).
    My expectation was that it is working.. I would be getting the device = VivoActive printed out. But.. It still printed out fenix3

    Obviously doing something wrong. ???
  • Obviously doing something wrong. ???

    Yes, you're doing something wrong. This trick isn't something special. It is simply using the resource system to define a string as documented in the developers guide.

    I'm betting that you don't use eclipse and you are building the program from the command line incorrectly. You have to compile with -d <device> and then you have to run the simulator with <device>...

    C:\Users\Travis\workspace\Device>monkeyc -o bin\Device.prg -m manifest.xml -z resources\resources.xml;resources-d2bravo\resources.xml;resources-epix\resources.xml;resources-fenix3\resources.xml;resour
    ces-fr920xt\resources.xml;resources-vivoactive\resources.xml -d fr920xt source\DeviceApp.mc

    C:\Users\Travis\workspace\Device>monkeydo bin\Device.prg fr920xt
    ... snipped ...
    Device id 1 name "A garmin device"
    Shell Version 0.1.0
    device:fr920xt


    C:\Users\Travis\workspace\Device>monkeyc -o bin\Device.prg -m manifest.xml -z resources\resources.xml;resources-d2bravo\resources.xml;resources-epix\resources.xml;resources-fenix3\resources.xml;resour
    ces-fr920xt\resources.xml;resources-vivoactive\resources.xml -d fenix3 source\DeviceApp.mc

    C:\Users\Travis\workspace\Device>monkeydo bin\Device.prg fenix3
    ... snipped...
    Device Version 0.1.0
    Device id 1 name "A garmin device"
    Shell Version 0.1.0
    device:fenix3


    Of course if you just used eclipse it would work automatically.
  • You are absolutely correct. I did a try early this morning.. using eclipse (on a Mac) and it works.
    but when I use the command line on a windows box (it does not work - I don't have eclipse on the windows box) and you are right - it's just due to the way i am calling the compiler.

    I noticed in (mac)eclipse it calls
    -u c:/Users/Documents/ConnectIQ/connectiq-sdk-mac-1.1.3/bin/devices.xml
    -p c:/Users/Documents/ConnectIQ/connectiq-sdk-mac-1.1.3/bin/projectInfo.xml


    which I then tried it on the windows box on the command line - calling those devices.xml file it does not work.

    Hmm.. re-reading you post - you indicated -d <device> which I am not using.
    Okay.. I'll try that..

    Thanks