1. Are you ready for the Galaxy S20? Here is everything we know so far!

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

Discussion in 'Android Development' started by christiaan89, May 2, 2021.

  1. christiaan89

    christiaan89 Lurker
    Thread Starter

    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 (Text):
    1.  
    2. $result1["rol"] = $rol;
    3.         $result1["login"] = $login;
    4.         $result1["username"] = $Qusername;
    5.         $result1["userid"] = $userID;
    6.         $result1["mail"] = $Qmail;
    7.         echo json_encode($result1);
    8.  
    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 (Text):
    1.  
    2.  
    3. {"rol":"9","login":"1","username":"christiaan","userid":"9998","mail":"c.***@h***e.nl"}
    4.  
    5.  

    And I tried to read that in android with:


    Code (Text):
    1.  
    2.  
    3. val apiResponse = URL(urlW).readText()
    4.  
    5.  
    6. val url = URL(urlW)
    7.  
    8. val urlConnection = url.openConnection() as HttpURLConnection
    9.  
    10. val text = urlConnection.inputStream.bufferedReader().readText()
    11.  
    12. tUser.text = text
    13.  
    14. urlConnection.disconnect()
    15.  
    16.  
    17.  
    urlW contains the full link.


    I write app in kotlin.
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...

Share This Page

Loading...