android - java.io.FileNotFoundException: https://bustracker.rhcloud.com/webapi/test -
i sending json string server. postdata class being called service class service class being launched oncreate() method in mainactivity. have tested code of postdata class before , works well. getting following warning , not getting response server more. mean?
i appreciate help
warning:
05-30 19:15:22.791: w/system.err(8371): java.io.filenotfoundexception: https://bustracker.rhcloud.com/webapi/test 05-30 19:15:22.791: w/system.err(8371): @ com.android.okhttp.internal.http.httpurlconnectionimpl.getinputstream(httpurlconnectionimpl.java:197) 05-30 19:15:22.791: w/system.err(8371): @ com.android.okhttp.internal.http.delegatinghttpsurlconnection.getinputstream(delegatinghttpsurlconnection.java:210) 05-30 19:15:22.801: w/system.err(8371): @ com.android.okhttp.internal.http.httpsurlconnectionimpl.getinputstream(httpsurlconnectionimpl.java:25) 05-30 19:15:22.801: w/system.err(8371): @ com.bustracker.postdata$myasynctask.doinbackground(postdata.java:83) 05-30 19:15:22.801: w/system.err(8371): @ com.bustracker.postdata$myasynctask.doinbackground(postdata.java:1) 05-30 19:15:22.801: w/system.err(8371): @ android.os.asynctask$2.call(asynctask.java:288) 05-30 19:15:22.801: w/system.err(8371): @ java.util.concurrent.futuretask.run(futuretask.java:237) 05-30 19:15:22.801: w/system.err(8371): @ android.os.asynctask$serialexecutor$1.run(asynctask.java:231) 05-30 19:15:22.801: w/system.err(8371): @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1112) 05-30 19:15:22.801: w/system.err(8371): @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:587) 05-30 19:15:22.811: w/system.err(8371): @ java.lang.thread.run(thread.java:818) postdata class:
public class postdata { string jsonstring; private asynctaskcallback callback; public postdata(asynctaskcallback callback) { this.callback = callback; } public string getjsonstring() { return jsonstring; } public void setjsonstring(string jsonstring) { this.jsonstring = jsonstring; } public void post_data(string jsonstring, context context) { this.jsonstring = jsonstring; new myasynctask(context).execute(jsonstring); } class myasynctask extends asynctask<string, integer, arraylist<integer>> { final context mcontext; arraylist<integer> routes = new arraylist<integer>(); double distance; public myasynctask(context context) { mcontext = context; } @override protected arraylist<integer> doinbackground(string... params) { bufferedreader reader = null; try { system.out.println("the output of : doinbackground " + params[0]); url myurl = new url( "https://bustracker.rhcloud.com/webapi/test"); httpurlconnection conn = (httpurlconnection) myurl .openconnection(); conn.setrequestmethod("post"); conn.setdooutput(true); conn.setconnecttimeout(10000); conn.setreadtimeout(10000); conn.setrequestproperty("content-type", "application/json"); conn.connect(); stringbuilder sb = new stringbuilder(); reader = new bufferedreader(new inputstreamreader( conn.getinputstream())); string line; while ((line = reader.readline()) != null) { sb.append(line + "\n"); } gson gson = new gson(); jsonstore data = gson.fromjson(sb.tostring(), jsonstore.class); routes = data.getroutes(); distance = data.getdistance(); system.out.println("the output of stringbulder: " + sb.tostring()); } catch (ioexception e) { e.printstacktrace(); return null; } { if (reader != null) { try { reader.close(); return null; } catch (exception e) { // todo auto-generated catch block e.printstacktrace(); } } } return null; } protected void onpostexecute(arraylist<integer> result) { if (routes != null && !routes.isempty()) { callback.onasynctaskfinished(routes, distance); }else{ log.e("123", "avoiding null pointer in postdata class, routes null!!!"); } } } }
Comments
Post a Comment