0

I am getting the exception while parsing the content from am url. The exception i am getting is given below.

10-16 12:46:59.373: E/AndroidRuntime(4362): FATAL EXCEPTION: Thread-12
10-16 12:46:59.373: E/AndroidRuntime(4362): java.lang.NullPointerException
10-16 12:46:59.373: E/AndroidRuntime(4362): at com.android.gyan.SearchResults4ドル.run(SearchResults.java:162)
10-16 12:46:59.373: E/AndroidRuntime(4362): at java.lang.Thread.run(Thread.java:1019)
10-16 12:46:59.783: E/WindowManager(4362): Activity com.android.gyan.SearchResults has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@4056d3b0 that was originally added here
10-16 12:46:59.783: E/WindowManager(4362): android.view.WindowLeaked: Activity com.android.gyan.SearchResults has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@4056d3b0 that was originally added here
10-16 12:46:59.783: E/WindowManager(4362): at android.view.ViewRoot.<init>(ViewRoot.java:258)
10-16 12:46:59.783: E/WindowManager(4362): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
10-16 12:46:59.783: E/WindowManager(4362): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
10-16 12:46:59.783: E/WindowManager(4362): at android.view.Window$LocalWindowManager.addView(Window.java:424)
10-16 12:46:59.783: E/WindowManager(4362): at android.app.Dialog.show(Dialog.java:241)
10-16 12:46:59.783: E/WindowManager(4362): at android.app.ProgressDialog.show(ProgressDialog.java:107)
10-16 12:46:59.783: E/WindowManager(4362): at android.app.ProgressDialog.show(ProgressDialog.java:95)
10-16 12:46:59.783: E/WindowManager(4362): at com.android.gyan.SearchResults.ParsingCall(SearchResults.java:147)
10-16 12:46:59.783: E/WindowManager(4362): at com.android.gyan.SearchResults.onCreate(SearchResults.java:137)
10-16 12:46:59.783: E/WindowManager(4362): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-16 12:46:59.783: E/WindowManager(4362): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-16 12:46:59.783: E/WindowManager(4362): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-16 12:46:59.783: E/WindowManager(4362): at android.app.ActivityThread.access1500ドル(ActivityThread.java:117)
10-16 12:46:59.783: E/WindowManager(4362): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-16 12:46:59.783: E/WindowManager(4362): at android.os.Handler.dispatchMessage(Handler.java:99)
10-16 12:46:59.783: E/WindowManager(4362): at android.os.Looper.loop(Looper.java:130)
10-16 12:46:59.783: E/WindowManager(4362): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-16 12:46:59.783: E/WindowManager(4362): at java.lang.reflect.Method.invokeNative(Native Method)
10-16 12:46:59.783: E/WindowManager(4362): at java.lang.reflect.Method.invoke(Method.java:507)
10-16 12:46:59.783: E/WindowManager(4362): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-16 12:46:59.783: E/WindowManager(4362): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-16 12:46:59.783: E/WindowManager(4362): at dalvik.system.NativeStart.main(Native Method)

The which i am using to parse is this.

public void ParsingCall(final String urlFirst) {
 final Bundle b = new Bundle();
 progressDialog = ProgressDialog.show(SearchResults.this, " ",
 "Searching.....", true, false);
 progressDialog.setIcon(-1);
 progressDialog.setIcon(R.drawable.logo);
 new Thread(new Runnable() {
 public void run() {
 LyricsData dataContent = null;
 dataContent = LyricsParse.Parse(urlFirst);
 Message msg = new Message();
 {
 {
 if(dataContent.contentList != null) {
 b.putStringArrayList("contentList",
 dataContent.contentList);
 }else {
 //dataContent.contentList[0] = {"No value"};
 b.putString("contentList",
 "No value");
 }
 if(dataContent.optionNameArrayList != null)
 b.putStringArrayList("optionNameArrayList",
 dataContent.optionNameArrayList);
 else
 b.putString("optionNameArrayList",
 "No value");
 }
 }
 msg.setData(b);
 handler.sendMessage(msg);
 }
 }).start();
}

I have also written an handler which will get the message and from that getting data and setting those to the view i am having in the activity. Please note that this exception is not getting every time. It is getting very rarely.

asked Oct 16, 2012 at 7:40
2
  • what is the line SearchResults.java:162?? Commented Oct 16, 2012 at 7:47
  • what's on line 162 ? (my guess is it is handler.sendMessage, as it is the only element without visible initialization) Commented Oct 16, 2012 at 7:48

3 Answers 3

2

There is error in your run method.Place debug point at starting of run method and you will a variable which is being initialized to NULL.

answered Oct 16, 2012 at 12:04
Sign up to request clarification or add additional context in comments.

Comments

0

You are getting a NullPointerException at line 147 of your SearchResults.java file as per this line:

10-16 12:46:59.783: E/WindowManager(4362): at com.android.gyan.SearchResults.ParsingCall(SearchResults.java:147)

Please make sure that all the variables on this line are initialized and are not set to null. I'm guessing you are calling ProgressDialog.show() but you haven't initialized your ProgressDialog variable or your initialization is out of scope.

answered Oct 16, 2012 at 7:49

Comments

0

remove one line..

progressDialog.setIcon(-1);
progressDialog.setIcon(R.drawable.logo);
MaVRoSCy
17.9k15 gold badges87 silver badges129 bronze badges
answered Oct 16, 2012 at 7:45

1 Comment

if you read the question you'll see that the error is in the run method

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.