"Native calls" to WinRT equivalent to QAndroidJniObject ?



  • I'm trying to port my Android Apps to Windows Phone 8.1 but is there a way/method to
    do "native calls" like we can do with QAndroid to Java with WinRT ?
    Where are the examples/templates ? Should be more direct as it is C++ to C++, so direct lib calls, I suppose but how to start working with it ?
    I need to access the battery level, networks states & status, etc.



  • Have you found an answer to that yet? I'm also looking for a possibility to call native code from Qt on Windows Phone.



  • There are no examples because it' simply C++ code you have to write.
    For the battery level look at this class:
    https://msdn.microsoft.com/en-us/library/windows.phone.devices.power.battery.aspx

    Windows Store/Phone apps usually use C++/CX, an extension to C++. Probably you've seen something like:
    SomeClass^ object = ref new SomeClass();
    That's C++/CX code, it have a little different syntax than plain C++, but every example in the web is written in C++/CX.
    So, where you now have your JNI-calls, put in C++/CX for WinRT.

    But: Qt doesn't enable the C++/CX extension by default and QtCreator have no support for C++/CX.
    I prefer to work with Visual Studio in this case. So, click in Visual Studio on your project --> Properties --> C++ --> General --> Consume Windows Runtime Extension --> Yes (/ZW). This will turn on the C++/CX extension for your code.

    Feel free to ask further questions!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.