Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Saving login and password with WebView on Android
Forum Updated to NodeBB v4.3 + New Features

Saving login and password with WebView on Android

Scheduled Pinned Locked Moved Solved QML and Qt Quick
9 Posts 2 Posters 7.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CharlieG
    wrote on 28 Sept 2016, 10:00 last edited by CharlieG
    #1

    Re: Saving login and password with WebView on Android

    @p3c0
    You can test with minibrowser example. In my case, if use the example on my PC, login and password are saved. But not in my Android Device. Here, a simple code for example :

    //main.cpp
    #include <QtCore/QUrl>
    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    #include <QtWebView/QtWebView>
    
    
    int main(int argc, char *argv[])
    {
    
        QGuiApplication app(argc, argv);
        QtWebView::initialize();
    
    
        QQmlApplicationEngine engine;
    
        engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
        if (engine.rootObjects().isEmpty())
            return -1;
    
        return app.exec();
    }
    
    //main.qml
    import QtQuick 2.2
    import QtQuick.Controls 1.1
    import QtWebView 1.0
    import QtQuick.Layouts 1.1
    import QtQuick.Controls.Styles 1.2
    
    
    ApplicationWindow {
        property bool showProgress: webView.loading
                                    && Qt.platform.os !== "ios"
                                    && Qt.platform.os !== "winphone"
                                    && Qt.platform.os !== "winrt"
        visible: true
        width: 800
        height: 600
        title: webView.title
    
        Component.onCompleted: console.log(initialUrl)
    
    
    
        statusBar: StatusBar {
            id: statusBar
            visible: showProgress
            RowLayout {
                anchors.fill: parent
                Label { text: webView.loadProgress == 100 ? qsTr("Done") : qsTr("Loading: ") + webView.loadProgress + "%" }
            }
        }
    
        WebView {
            id: webView
            anchors.fill: parent
            url: Qt.resolvedUrl("http://www.google.fr")
        }
    }
    
    //.*pro file
    #TEMPLATE = app
    #TARGET = minibrowser
    
    QT += qml quick webview
    
    SOURCES += main.cpp
    
    RESOURCES += qml.qrc
    
    #INSTALLS += target
    

    Thank you for your help

    1 Reply Last reply
    0
    • P Offline
      P Offline
      p3c0
      Moderators
      wrote on 28 Sept 2016, 10:05 last edited by
      #2

      @CharlieG Sorry but I dont understand what do you mean by "save" here ?

      157

      1 Reply Last reply
      0
      • C Offline
        C Offline
        CharlieG
        wrote on 28 Sept 2016, 10:26 last edited by
        #3

        If you compile this code on PC and use the program, your login and password (google account for example) are saved ==> if you close the application and if you return, you are logged automaticly.

        This features doesn't work on Android device.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          p3c0
          Moderators
          wrote on 28 Sept 2016, 10:44 last edited by
          #4

          @CharlieG The QML WebView actually loads the native web component where it is available as said here.
          In case of android it is available as WebView.
          I think the problem is because android WebView itself doesnot allow it. As per its docs here:

          getSavePassword()
          This method was deprecated in API level 18.
          Saving passwords in WebView will not be supported in future versions.

          I'm not sure if this is the exact problem.

          157

          C 1 Reply Last reply 28 Sept 2016, 12:11
          1
          • P p3c0
            28 Sept 2016, 10:44

            @CharlieG The QML WebView actually loads the native web component where it is available as said here.
            In case of android it is available as WebView.
            I think the problem is because android WebView itself doesnot allow it. As per its docs here:

            getSavePassword()
            This method was deprecated in API level 18.
            Saving passwords in WebView will not be supported in future versions.

            I'm not sure if this is the exact problem.

            C Offline
            C Offline
            CharlieG
            wrote on 28 Sept 2016, 12:11 last edited by
            #5

            @p3c0
            Thank you for your help.

            It's a pity ... I do not see how to get out of me once?
            Could there be a way to force the storage in a personal file?
            Fill out the form automatically? I tried this track but I have not managed to get a decent result ...

            1 Reply Last reply
            0
            • P Offline
              P Offline
              p3c0
              Moderators
              wrote on 29 Sept 2016, 05:15 last edited by
              #6

              @CharlieG Sorry I too dont know. You can try asking it on Qt Interest Mailing List.

              157

              C 1 Reply Last reply 2 Oct 2016, 11:26
              0
              • P p3c0
                29 Sept 2016, 05:15

                @CharlieG Sorry I too dont know. You can try asking it on Qt Interest Mailing List.

                C Offline
                C Offline
                CharlieG
                wrote on 2 Oct 2016, 11:26 last edited by
                #7

                @p3c0

                I finally opted for the use of Setting (Qt.labs.settings) for storing identifiers. I then use the method void runJavaScript (string script, ranging callback) WebView and so a bit of JavaScript (document.getElementById ...) to inject what is right where it should, which can be quite painful when target lack some "standard" items (id, name, ...).

                Thank you for you help.

                Bye Bye

                Charlie

                1 Reply Last reply
                1
                • P Offline
                  P Offline
                  p3c0
                  Moderators
                  wrote on 3 Oct 2016, 07:11 last edited by
                  #8

                  @CharlieG Ok. Lets hope they wont change the id in future :)

                  157

                  C 1 Reply Last reply 5 Oct 2016, 06:53
                  0
                  • P p3c0
                    3 Oct 2016, 07:11

                    @CharlieG Ok. Lets hope they wont change the id in future :)

                    C Offline
                    C Offline
                    CharlieG
                    wrote on 5 Oct 2016, 06:53 last edited by
                    #9

                    @p3c0 Oh yes .... I hope ;)

                    1 Reply Last reply
                    0

                    1/9

                    28 Sept 2016, 10:00

                    • Login

                    • Login or register to search.
                    1 out of 9
                    • First post
                      1/9
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved