如何将URL解析为Android

时间:2016-01-19 12:59:56

标签: android parsing

我有代码,我必须解析URL。如果我直接传递URL然后解析完成但如果我试图动态地使我的URL接受数据,那么它显示Null Pointer Exception .. Plzz帮助我..

我的网址格式是这样的..

String loginUrl = "http://54.152.108.131/iphone111/getParentInput?child_id="+id+"&date="+date.toString();

如果我像这样放置网址

http://54.152.108.131/iphone111/getParentInput?child_id=6272&date=1/19/2016

然后它的工作。请让我知道我在哪里做错了..

我的LogCat在这里

01-19 08:09:43.628: E/AndroidRuntime(18018): FATAL EXCEPTION: AsyncTask #3
01-19 08:09:43.628: E/AndroidRuntime(18018): Process: com.MyKidzDay, PID: 18018
01-19 08:09:43.628: E/AndroidRuntime(18018): java.lang.RuntimeException: An error occured while executing doInBackground()
01-19 08:09:43.628: E/AndroidRuntime(18018):    at android.os.AsyncTask$3.done(AsyncTask.java:300)
01-19 08:09:43.628: E/AndroidRuntime(18018):    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
01-19 08:09:43.628: E/AndroidRuntime(18018):    at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
01-19 08:09:43.628: E/AndroidRuntime(18018):    at java.util.concurrent.FutureTask.run(FutureTask.java:242)
01-19 08:09:43.628: E/AndroidRuntime(18018):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
01-19 08:09:43.628: E/AndroidRuntime(18018):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
01-19 08:09:43.628: E/AndroidRuntime(18018):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
01-19 08:09:43.628: E/AndroidRuntime(18018):    at java.lang.Thread.run(Thread.java:841)
01-19 08:09:43.628: E/AndroidRuntime(18018): Caused by: java.lang.NullPointerException
01-19 08:09:43.628: E/AndroidRuntime(18018):    at com.KidsTabs.KidSummary$ParentInputData.doInBackground(KidSummary.java:1651)
01-19 08:09:43.628: E/AndroidRuntime(18018):    at com.KidsTabs.KidSummary$ParentInputData.doInBackground(KidSummary.java:1)
01-19 08:09:43.628: E/AndroidRuntime(18018):    at android.os.AsyncTask$2.call(AsyncTask.java:288)
01-19 08:09:43.628: E/AndroidRuntime(18018):    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
01-19 08:09:43.628: E/AndroidRuntime(18018):    ... 4 more
01-19 08:09:43.644: W/EGL_genymotion(18018): eglSurfaceAttrib not implemented
01-19 08:09:44.084: I/Inside convertstream method(18018): hello

1 个答案:

答案 0 :(得分:0)

您似乎有一个null KidSummary对象。尝试在第1351行打印内容。发布KidSummary类代码和ASyncTask实现非常重要。