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.....
     



    1. Download the Forums for Android™ app!


      Download

       
  2. christiaan89

    christiaan89 Lurker
    Thread Starter

    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.
     
Loading...
Similar Threads - Can't info android
  1. RaulG931
    Replies:
    2
    Views:
    201
  2. hstroph
    Replies:
    7
    Views:
    341
  3. rompecabezas2356
    Replies:
    18
    Views:
    689
  4. Francis Roads
    Replies:
    1
    Views:
    308
  5. RobertK32
    Replies:
    3
    Views:
    799
  6. Silvarro
    Replies:
    3
    Views:
    400
  7. Syahhhh3333
    Replies:
    5
    Views:
    422
  8. dorlow
    Replies:
    22
    Views:
    836
  9. James_Watson
    Replies:
    10
    Views:
    560
  10. oscarvn
    Replies:
    2
    Views:
    361

Share This Page

Loading...