2013-01-17 2 views
0

사용자로부터 오류 보고서가 표시되고 코드에 무슨 문제가 있는지 잘 모릅니다. 로그 캣은 이것이다 :runOnUiThread의 Nullpointerexception

java.lang.NullPointerException 
at com.laurenswuyts.find.it.MainActivity$LoadPlaces$1.run(MainActivity.java:299) 
at android.app.Activity.runOnUiThread(Activity.java:4244) 
at com.laurenswuyts.find.it.MainActivity$LoadPlaces.onPostExecute(MainActivity.java:293) 
at com.laurenswuyts.find.it.MainActivity$LoadPlaces.onPostExecute(MainActivity.java:1) 
at android.os.AsyncTask.finish(AsyncTask.java:602) 
at android.os.AsyncTask.access$600(AsyncTask.java:156) 
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:615) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:137) 
at android.app.ActivityThread.main(ActivityThread.java:4697) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:511) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554) 
at dalvik.system.NativeStart.main(Native Method) 

그리고이 코드 조각에 관하여 :

protected void onPostExecute(String file_url) { 
      // dismiss the dialog after getting all products 
      pDialog.dismiss(); 
      // updating UI from Background Thread 
      runOnUiThread(new Runnable() { 
       public void run() { 
        /** 
        * Updating parsed Places into LISTVIEW 
        * */ 
        // Get json response status 
        String status = nearPlaces.status; 

        // Check for all possible status 
        if(status.equals("OK")){ 
         // Successfully got places details 
         if (nearPlaces.results != null) { 

          // loop through each place 
          for (Place p : nearPlaces.results) { 

이 사람이 나를 도울 수 있습니까? 나는이 라인이기 때문에

+2

MainActivity의 299 행을 표시 할 수 있습니까? – WarrenFaith

+0

또한 스택 추적에 따라 줄 번호를 참조하지 않고 말할 수 없습니다. 내 생각 엔 "상태"null이 될 것입니다,하지만 또한이 엿볼을 기반으로 nearPlaces 수 있습니다. MainActivity 299에는 무엇이 있습니까? –

+0

@ syb0rg 신경 쓰지 마세요, 미안 해요 :) – WarrenFaith

답변

1

로그는 당신에게 MainActivity

을 라인 299을 의미

(MainActivity.java:299) 

을 알려줍니다 ...이 하나에 정말 붙어 :

String status = nearPlaces.status; 

그건 단지 nearPlaces가 null이라는 것을 의미합니다. 그 문제를 해결하기 위해 더 이상 할 수있는 것이 없습니다.

일부 데이터로 초기화하십시오!