java - Exception raisedJava.lang.illegalargumentexception in android application -
hello every body when trying post date database in android saying exception in such way "java.lang.illegalargumentexception" can 1 help in fixation of issue
& here code
my calendar format code is..
cal = calendar.getinstance(timezone.getdefault()); currentdatetimestring = dateformat.getdatetimeinstance().format(new date()); // textview textview view should display tv.settext(currentdatetimestring); simpledateformat formatter = new simpledateformat("mmm dd, yyyy hh:mm:ss a"); seek { date = formatter.parse(currentdatetimestring); system.out.println("the date value is..."+date); system.out.println("demo *******"+formatter.format(date)); } grab (parseexception e) { e.printstacktrace(); } sdf = new simpledateformat("hh:mm:ss a", locale.getdefault()); system.out.println("local time is...."+sdf.format(cal.gettime()));
after clicking button it'll implements doing background action
& posting database code is.. private class postaftershake extends asynctask{
//context context; string jsonstr; @override protected string doinbackground(string... arg0) { // todo auto-generated method stub string pinstr = "a5139"; servicehandler sh = new servicehandler(); string dstr = date.tostring(); // http://192.168.3.125:8090/shakeapp/rest/shake/shaketime/pin/shaketime1 string loginurl = "http://202.65.154.108:8080/shakeapp/rest/shake/shaketime/"+pinstr+ "/" +dstr; system.out.println("login url test....."+loginurl); jsonstr = sh.makeservicecall(loginurl, servicehandler.post); log.d("o ", ">" +jsonstr); system.out.println(jsonstr);
and service handler class is...
public class servicehandler { static string response = null; public final static int = 1; public final static int post = 2; public httpentity httpentity; public servicehandler() { } /** * making service phone call * @url - url create request * @method - http request method * */ public string makeservicecall(string url, int method) { homecoming this.makeservicecall(url, method, null); } public string makeservicecaller(string url_category, int method) { homecoming this.makeservicecall(url_category, method, null); } /** * making service phone call * @url - url create request * @method - http request method * @params - http request params * */ public string makeservicecall(string url, int method, list<namevaluepair> params) { seek { // http client defaulthttpclient httpclient = new defaulthttpclient(); httpentity = null; httpresponse httpresponse = null; // checking http request method type if (method == post) { httppost httppost = new httppost(url); // adding post params if (params != null) { httppost.setentity(new urlencodedformentity(params)); } httpresponse = httpclient.execute(httppost); } else if (method == get) { // appending params url if (params != null) { string paramstring = urlencodedutils .format(params, "utf-8"); url += "?" + paramstring; } httpget httpget = new httpget(url); httpresponse = httpclient.execute(httpget); } httpentity = httpresponse.getentity(); system.out.println(httpentity); response = entityutils.tostring(httpentity); } grab (unsupportedencodingexception e) { e.printstacktrace(); } grab (clientprotocolexception e) { e.printstacktrace(); } grab (ioexception e) { e.printstacktrace(); } homecoming response; }
and exception facing is...
10-15 10:54:58.517: e/androidruntime(32287): fatal exception: asynctask #2 10-15 10:54:58.517: e/androidruntime(32287): java.lang.runtimeexception: error occured while executing doinbackground() 10-15 10:54:58.517: e/androidruntime(32287): @ android.os.asynctask$3.done(asynctask.java:278) 10-15 10:54:58.517: e/androidruntime(32287): @ java.util.concurrent.futuretask$sync.innersetexception(futuretask.java:273) 10-15 10:54:58.517: e/androidruntime(32287): @ java.util.concurrent.futuretask.setexception(futuretask.java:124) 10-15 10:54:58.517: e/androidruntime(32287): @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:307) 10-15 10:54:58.517: e/androidruntime(32287): @ java.util.concurrent.futuretask.run(futuretask.java:137) 10-15 10:54:58.517: e/androidruntime(32287): @ android.os.asynctask$serialexecutor$1.run(asynctask.java:208) 10-15 10:54:58.517: e/androidruntime(32287): @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1076) 10-15 10:54:58.517: e/androidruntime(32287): @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:569) 10-15 10:54:58.517: e/androidruntime(32287): @ java.lang.thread.run(thread.java:856) 10-15 10:54:58.517: e/androidruntime(32287): caused by: java.lang.illegalargumentexception: illegal character in path @ index 66: http://202.65.154.108:8080/shakeapp/rest/shake/shaketime/a5139/wed oct 15 00:54:54 pst 2014 10-15 10:54:58.517: e/androidruntime(32287): @ java.net.uri.create(uri.java:727) 10-15 10:54:58.517: e/androidruntime(32287): @ org.apache.http.client.methods.httpget.<init>(httpget.java:75) 10-15 10:54:58.517: e/androidruntime(32287): @ com.android.hits.charlesdeals.servicehandler.makeservicecall(servicehandler.java:76) 10-15 10:54:58.517: e/androidruntime(32287): @ com.android.hits.charlesdeals.servicehandler.makeservicecall(servicehandler.java:38) 10-15 10:54:58.517: e/androidruntime(32287): @ com.android.hits.charlesdeals.shakescreen$postaftershake.doinbackground(shakescreen.java:197) 10-15 10:54:58.517: e/androidruntime(32287): @ com.android.hits.charlesdeals.shakescreen$postaftershake.doinbackground(shakescreen.java:1) 10-15 10:54:58.517: e/androidruntime(32287): @ android.os.asynctask$2.call(asynctask.java:264) 10-15 10:54:58.517: e/androidruntime(32287): @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:305) 10-15 10:54:58.517: e/androidruntime(32287): ... 5 more
thanks in advance
you have illegal character in url (:). seek encoding uri properly.
java android date
No comments:
Post a Comment