Calling web API and Receive return value in Android -


i've googled topics , don't useful information.

i want use web api in android projects, don't know how call them android or java

i've got web api this site , want use in android project. example, web api url : /api/uname2uid/{uname}.

that convert user name user numeric id

i want display user id returned api textview. need return value string or number. please me this.

edit
want learn how use web api
for more simplicity: in program have textview, aedittext , button
when press button textview update corresponding user id username given in edittext field thats all. working example great me understanding this.

a simple async call thing you.:

mainactivity.java

new yourasync(){              protected void onpostexecute(object[] result) {                  string response = result[1].tostring();                 try{                 jsonobject jsonobject=(new jsonobject(jsonresult)).getjsonobject("data"); //parsing json object named 'data'                 yourtextview.settext(jsonobject.getstring("uname"));          }.execute(yoururl); 

yourasync.java

public class yourasync extends asynctask<string, integer, object[]> {      @override     protected object[] doinbackground(string... params) {         // todo auto-generated method stub          httpclient httpclient = new defaulthttpclient();         httppost httppost = new httppost(params[0].tostring());         log.d("http client post set","");          try{             httpresponse response = httpclient.execute(httppost);             log.d("yourasync","executed");             return new object[]{response, new basicresponsehandler().handleresponse(response)};         }catch(exception e){             log.d("" + e, "");         }         return new object[0];     } 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -