android get json response -


hey guys new android networking concepts.i want send username,password,imei number , location php server android app.i done sending part.now question how receive response.i want status (1 or 0) according want move next page.so know how welcome.

       private static final string register_url="http://vpc70.com/app/login.php";      username =  edittextusername.gettext().tostring().tolowercase();      userpassword=edittextpassword.gettext().tostring().tolowercase();      loc="11.295756,77.001890";       imeino = "12312312456";      register(username, userpassword, imeino, loc);       private void register(final string username, final string userpassword,        string imeino, string loc) {       string urlsuffix = "?       username="+username+"&userpassword="+userpassword+"&imeino="+imeino      +"&location="+loc;       class registeruser extends asynctask<string,string , string>{          progressdialog loading;           @override         protected void onpreexecute() {             super.onpreexecute();             loading = progressdialog.show(loginactivity.this, "please         wait",null, true, true);         }          @override         protected void onpostexecute(string s) {             super.onpostexecute(s);             loading.dismiss();              }          @override         protected string doinbackground(string... params) {             string s = params[0];             bufferedreader bufferedreader = null;             try {                 url url = new url(register_url+s);                 httpurlconnection con = (httpurlconnection)             url.openconnection();                 bufferedreader = new bufferedreader(new             inputstreamreader(con.getinputstream()));                  string result;                  result = bufferedreader.readline();                 return result;              }catch(exception e){                 return null;             }          }       }       registeruser ru = new registeruser();       ru.execute(urlsuffix); 

this response

      {"login":[{"status":"1","message":"login !!!"}]}       {"login":[{"status":"0","message":"invalid password !!!"}]} 

if response 1 toast message login sucessfully if response 0 toast message invalid password in post execute

after getting response server,based on status display message in toast

try {                     jsonobject jobj = new jsonobject(response);                       string status = jobj.getstring("status");                      string msg = jobj.getstring("message");                      if (status.equals("1")) {                         //move next page                         toast.maketext(loginactivity.this, msg,toast.length_short).show();                      } else {                         toast.maketext(loginactivity.this, msg,toast.length_short).show();                  } catch (exception e) {                     e.printstacktrace();                 } 

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -