1

my goal is to run a php script and to GET the values returned. I work under Neccesitas SDK (Qt for Android) To do this I do:

m_NetworkAccessMNGR = new QNetworkAccessManager(this);
QEventLoop loop;
QNetworkReply* m_reply = m_NetworkAccessMNGR->get(QNetworkRequest(url));
connect(m_reply, SIGNAL(finished()),
        this, SLOT(slothttpFinished()));
connect(m_reply, SIGNAL(readyRead()),
        this, SLOT(slothttpReadyRead()));
connect(m_reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();

ONLY on Android I get in this::slothttpReadyRead

m_reply->error() is QNetworkReply::HostNotFoundError

and m_reply->errorString() outputs:

ERROR: Host www.google.com not found

On Windows this works perfectly. Should I do some adaptations to Android? Maybe AndroidManifest.xml needs some setup made?
My AndroidManifest.xml contains, among others :

uses-permission android:name="android.permission.INTERNET"/>
uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Thank you

Lucian
  • 874
  • 11
  • 33
  • android.permission.INTERNET should be enough, that's all I have set for an Android application (based on Qt 5.1.1) with working networking. What's the complete url you pass there? – Frank Osterfeld Oct 17 '13 at 17:15
  • Actual code:QEventLoop loop; QString address = "http://0-virus.com/checklogin.php?un="+qUserName+"&pw="+qPass; QNetworkReply *reply = m_NetworkAccessMNGR->get(QNetworkRequest(QUrl(address))); connect(reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead())); connect(reply, SIGNAL(finished()) – Lucian Oct 17 '13 at 18:18
  • 1
    SO messed with the URL - make sure you prepend http:// – Frank Osterfeld Oct 17 '13 at 18:41
  • Or the server was dead exactly on that periods that i was trying to connect or i don't know exaclty what I did, i tried all sorts of different implementations after that I switched on my laptop instead of pc and it worked. Yes the url contained http://. Thank you – Lucian Oct 17 '13 at 19:11

0 Answers0