• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Null Pointer Exception In Method

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I designed app to make order for pizza food restaurant
I show userid,menu id ,address,longtiude,latitude then press on button make order
Error show after I press button and found in async task doin background
It give me fatal exception error
An error occurred while executing doInBackground()
and it show to me two lines have proplem
AddNewOrder.doInBackground(Summary.java:113)
AddNewOrder.doInBackground(Summary.java:77)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean org.json.JSONObject.getBoolean(java.lang.String)' on a null object reference




Class AppConfig

json parser
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your makeHttpRequest() call is returning a null object.
I can't really tell why as I can't follow the flow of the code to see what is happening, as the code is completely unformatted.

Is your original code really unindented like that?
Can I suggest reposting that JSONParser class but with proper formatting? Don't worry about the other classes for now.

Anyway, is there anything else in the logs that will tell you what has happened inside that method?
I see lots of logging, so you should be able to trace the route it took.
 
ahmed abed elaziz
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
json parser class based on your request

The error i show to me is  is
json parser End of input at character 0 of
after i run code below as you mention before
try {
jObj = new JSONObject(json);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's still unformatted.
There's no indentation.
So step 1 is to format it correctly.

Also, as I said, there's lots of logging in there so you should be able to post what the logs look like up to the error, at least the ones leading up to the exception.
You should also print the stack trace of the exception, which will be done automatically for you if you change your Log call to:

You should do that for all your catch blocks.

One thing I will note is that it looks to me like you continue processing if the load attempt fails, which means that 'json' is unlikely to have anything in it at all.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic