Null Pointer Exception In Method Boolean.Org.Json.Jsonobject Do in background async task
-
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 package com.pizza_final_project_app.pizza_final_project; import android.app.Activity; import android.app.ProgressDialog; import android.content.Intent; import android.content.SharedPreferences; import android.os.AsyncTask; import android.preference.PreferenceManager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; import java.util.List; public class Summary extends Activity { SharedPreferences preferences; private ProgressDialog pDialog; //JSONParser jsonParser = new JSONParser(); boolean errorFound; TextView textaddress; TextView textlongtiude; TextView textlatitude; TextView text2; TextView textuser; Button btnorder; private static final String TAG_SUCCESS = "success"; private static final String TAG = Summary.class.getSimpleName(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_summary); text2=(TextView)findViewById(R.id.textView3); textaddress=(TextView)findViewById(R.id.textaddress); textuser=(TextView)findViewById(R.id.textView4); textlongtiude=(TextView)findViewById(R.id.textlongtiude); textlatitude=(TextView)findViewById(R.id.textlatitude); Intent i = getIntent(); String id = i.getStringExtra("Data4"); String address = i.getStringExtra("Data8"); String longtiude = i.getStringExtra("Data9"); String latitude = i.getStringExtra("Data10"); text2.setText(id); textaddress.setText(address); textlongtiude.setText(longtiude); textlatitude.setText(latitude); preferences= PreferenceMana
-
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 package com.pizza_final_project_app.pizza_final_project; import android.app.Activity; import android.app.ProgressDialog; import android.content.Intent; import android.content.SharedPreferences; import android.os.AsyncTask; import android.preference.PreferenceManager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; import java.util.List; public class Summary extends Activity { SharedPreferences preferences; private ProgressDialog pDialog; //JSONParser jsonParser = new JSONParser(); boolean errorFound; TextView textaddress; TextView textlongtiude; TextView textlatitude; TextView text2; TextView textuser; Button btnorder; private static final String TAG_SUCCESS = "success"; private static final String TAG = Summary.class.getSimpleName(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_summary); text2=(TextView)findViewById(R.id.textView3); textaddress=(TextView)findViewById(R.id.textaddress); textuser=(TextView)findViewById(R.id.textView4); textlongtiude=(TextView)findViewById(R.id.textlongtiude); textlatitude=(TextView)findViewById(R.id.textlatitude); Intent i = getIntent(); String id = i.getStringExtra("Data4"); String address = i.getStringExtra("Data8"); String longtiude = i.getStringExtra("Data9"); String latitude = i.getStringExtra("Data10"); text2.setText(id); textaddress.setText(address); textlongtiude.setText(longtiude); textlatitude.setText(latitude); preferences= PreferenceMana
Post only relevant code next time. The error text plainly states that
jObj
isnull
."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Post only relevant code next time. The error text plainly states that
jObj
isnull
."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
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 package com.pizza_final_project_app.pizza_final_project; import android.app.Activity; import android.app.ProgressDialog; import android.content.Intent; import android.content.SharedPreferences; import android.os.AsyncTask; import android.preference.PreferenceManager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; import java.util.List; public class Summary extends Activity { SharedPreferences preferences; private ProgressDialog pDialog; //JSONParser jsonParser = new JSONParser(); boolean errorFound; TextView textaddress; TextView textlongtiude; TextView textlatitude; TextView text2; TextView textuser; Button btnorder; private static final String TAG_SUCCESS = "success"; private static final String TAG = Summary.class.getSimpleName(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_summary); text2=(TextView)findViewById(R.id.textView3); textaddress=(TextView)findViewById(R.id.textaddress); textuser=(TextView)findViewById(R.id.textView4); textlongtiude=(TextView)findViewById(R.id.textlongtiude); textlatitude=(TextView)findViewById(R.id.textlatitude); Intent i = getIntent(); String id = i.getStringExtra("Data4"); String address = i.getStringExtra("Data8"); String longtiude = i.getStringExtra("Data9"); String latitude = i.getStringExtra("Data10"); text2.setText(id); textaddress.setText(address); textlongtiude.setText(longtiude); textlatitude.setText(latitude); preferences= PreferenceMana
-
Post only relevant code next time. The error text plainly states that
jObj
isnull
."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
don't forget: use "pre" tags to format it
M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.