• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Can't get info back into android app from php webpage

christiaan89

Lurker
Dec 25, 2019
4
0
Hello

My english is very bad, so i hope you understand.

I make my own apps, and most off the time in fragment activities
On my website i have a php script, that will check if the username and password is correct filled in in the application.

I hace to get back from the website the userID, firstname and email address from the database, this info is stored in a json format like below:
Code:
$result1["rol"] = $rol;
        $result1["login"] = $login;
        $result1["username"] = $Qusername;
        $result1["userid"] = $userID;
        $result1["mail"] = $Qmail;
        echo json_encode($result1);

login is a 0 or 1 for check if the user is correct login.

ut how to get the $result1 back to android.....

I have the following on my website visible

Code:
{"rol":"9","login":"1","username":"christiaan","userid":"9998","mail":"c.***@h***e.nl"}


And I tried to read that in android with:


Code:
val apiResponse = URL(urlW).readText()


val url = URL(urlW)

val urlConnection = url.openConnection() as HttpURLConnection

val text = urlConnection.inputStream.bufferedReader().readText()

tUser.text = text

urlConnection.disconnect()

urlW contains the full link.


I write app in kotlin.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones