2016-01-19 66 views
-2

我有我需要解析URL的代碼。如果我直接通過URL解析,然後完成,但如果我試圖讓我的URL動態地接受數據,那麼它顯示空指針異常.. Plzz幫助我..如何解析URL到Android

我的URL的格式是這樣的..

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

,如果我把URL這樣

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

那麼它working.Please讓我知道我在做錯誤..

我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 
+0

當你談論** Crash **,'NullPointerException',**不幸的是應用程序已經停止**等時,總是發佈logcat錯誤跟蹤。這是解決方案的關鍵。 – Rohit5k2

+0

您是否確認在調用代碼之前,'id'和'date'都設置了它們的值? 'date.toString()'的輸出是否與你期待的格式相符? – ScouseChris

+0

是的,我做了,我能看到我的Id和日期值LogCat – kitkat

回答

0

看起來你有一個空的KidSummary對象。嘗試在1351行打印內容。重要的是發佈KidSummary類代碼和ASyncTask實現。