eclipse - Pass List array as params to Android AsynTask -


i have small huge problem in android app, i'm trying pass array list asynctask post data external api. eclipse allways returning data type error , cannot figure how pass params activity asynctask. please help

  public void login(view view){     string usern = username.gettext().tostring();     string pwd = password.gettext().tostring();      list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>();     namevaluepairs.add(new basicnamevaluepair("username", usern));     namevaluepairs.add(new basicnamevaluepair("password", pwd));                     namevaluepairs.add(new basicnamevaluepair("external-login", "true"));      if(isnetworkavailable()){         getaxiomacredentials axiomacredentials = new getaxiomacredentials();         axiomacredentials.execute();     }else{         toast.maketext(this, "network not available.", toast.length_long).show();     } } 

so there can pass namevaluepairs execute parameter bad type error asynctask private class

  private class getaxiomacredentials extends asynctask<arraylist<string>, integer, string>{      private static final string post_url = "http://192.168.0.105/index.php/r=rsite/heartbeat";      @override     protected string doinbackground(arraylist<string>... params) {         int responsecode = -1;         httpclient httpclient = new defaulthttpclient();         httppost httppost = new httppost(post_url);         try {             // add data             arraylist<string> data = params[0];             httppost.setentity(new urlencodedformentity(data));              // execute http post request             httpresponse response = httpclient.execute(httppost);          } catch (clientprotocolexception e) {             // todo auto-generated catch block         } catch (ioexception e) {             // todo auto-generated catch block         }          return "code: " + responsecode;     }      @override     protected void onprogressupdate(integer... progress) {      }      public void postdata(string name, string email, string password,string mobile) {         // create new httpclient , post header      } } 

the eclipse compile error i'm getting in line:

  arraylist<string> data = params[0];         httppost.setentity(new urlencodedformentity(data)); 

so how can fix pass parameters login action in activity asynctask? thanks

change input doinbackground arraylist. remove cast exception.

private class getaxiomacredentials extends asynctask<object, integer, string>{ ... 

change arraylist object

protected string doinbackground(object... params) {     int responsecode = -1;     list<namevaluepair> data = (list<namevaluepair>) params[0];     ... 

then when call execute, pass in namevaluepairs

if(isnetworkavailable()){     getaxiomacredentials axiomacredentials = new getaxiomacredentials();     axiomacredentials.execute(namevaluepairs); 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -