java - Android studio expected class or package -
hello guys trying acces class works asynctasks, strangely annoying error maybe can me, error shows on serverrequest.storenaryste();
here code: ................................................................................
uzsisakyti.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { global.naryste = trukme +" "+ "rad" +" "+ kaina.gettext().tostring(); naris(); } }); private void naris() { serverrequests serverrequest = new serverrequests(this); serverrequest.storenaryste(); }
serverrequest class :
public class storenaryste extends asynctask<void, void, void> { @override protected void doinbackground(void... params) { arraylist<namevaluepair> datatosend = new arraylist<>(); datatosend.add(new basicnamevaluepair("pastas",global.elpastas )); datatosend.add(new basicnamevaluepair("slaptazodis",global.slaptazodis )); datatosend.add(new basicnamevaluepair("naryste",global.naryste)); httpparams httprequestparams = gethttprequestparams(); httpclient client = new defaulthttpclient(httprequestparams); httppost post = new httppost(server_address + "naryste.php"); try { post.setentity(new urlencodedformentity(datatosend)); client.execute(post); } catch (exception e) { e.printstacktrace(); } return null; } private httpparams gethttprequestparams() { httpparams httprequestparams = new basichttpparams(); httpconnectionparams.setconnectiontimeout(httprequestparams, connection_timeout); httpconnectionparams.setsotimeout(httprequestparams, connection_timeout); return httprequestparams; } @override protected void onpostexecute(void result) { super.onpostexecute(result); progressdialog.dismiss(); } }
you trying start asynctask
this:
serverrequests serverrequest = new serverrequests(this); serverrequest.storenaryste();
this seems little strange me, should instead:
new storenaryste().execute();
which should work.
also check docs asynctask how use correctly:
http://developer.android.com/reference/android/os/asynctask.html
Comments
Post a Comment