i'm sending data app external server.
public class postkey extends asynctask<string, string, string> { public asyncresponse delegate = null; @override protected string doinbackground(string... params) { postdata(params[0]); return null; } @override protected void onpostexecute(string result){ log.d(string.valueof(result), " result?"); delegate.processfinish(result); // returns nullpointerexception } public void postdata(string valueiwanttosend) { httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("http://domain.com/post.php"); try { list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(); namevaluepairs.add(new basicnamevaluepair("hoi", "test")); httppost.setentity(new urlencodedformentity(namevaluepairs)); httpresponse response = httpclient.execute(httppost); string responsestr = entityutils.tostring(response.getentity()); log.d(responsestr, ""); } catch (clientprotocolexception e) { // todo auto-generated catch block } catch (ioexception e) { // todo auto-generated catch block } } public interface asyncresponse { void processfinish(string output); } } log.d(responsestr, ""); return true or false, depending on data send, , logs it.
delegate.processfinish(result); returns nullpointerexception mentioning public class postkey extends asynctask<string, string, string> eventhough parameters declared strings.
i've tried replacing result responsestr didn't work either.
problem method call delegate.processfinish(result); delegate not initialized. calling method on null object.
Comments
Post a Comment