Saving login and password with WebView on Android
-
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
-
@CharlieG The QML
WebView
actually loads the native web component where it is available as said here.
In case of android it is available asWebView
.
I think the problem is because androidWebView
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.
-
@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 ... -
@CharlieG Sorry I too dont know. You can try asking it on Qt Interest Mailing List.
-
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