How to close app after browser is closed

Forside Forum Developer discussions How to close app after browser is closed

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #3901
    Laurynas
    Participant

    Hi,I have an another question regarding native browser functionality. It would be nice, when user press back button, and browser closes, it would close whole application automatically. Is it possible to achieve?

    #3918
    mikek
    Participant

    Sure, first you make a call from the onDestroy() function in the WebkitActivity back to the C++ code (through JNI), then you call the Qt function QCoreApplication::exit() from this native c++ function (the function you called from onDestroy())You can get inspired on making JNI calls from the PlatformWebBrowser constructor where the JNI function for the JS interface are defined.Let me know if you need more detailed info.^__^Mike

    #3919
    Laurynas
    Participant

    Thanks, that was very helpful  ;DWhile doing this change, I have ran into issue - when I tried to map Java -> C++ function in WebkitActivity, the activity failed to start. Does it related somehow, that it is an Activity, and I can not define native methods in it? It is more theoretical question, because I relocated native method to FSDC2JSGateway and now it works for me.

    #3920
    mikek
    Participant

    Happy to help  🙂  You are right it will not work if you just copy that code for the WebkitActivity – I'm no JNI or Android expert, but I guess this is because when setting up the native calls we actually instantiates the activity object, but not with the correct arguments (for the constructor) or not in the correct context – hence when we try to launch the activity it doesn't actually show on the display.  There are other ways to use the JNI or initialize the activity object, but if you found a solution that works, then I'll not dig into it now.Let me know if I should search for a solution.^__^Mike

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.