Posts

Showing posts with the label nullpointerexception

Handle OnErrorResponse Method - Volley

Handle OnErrorResponse Method - Volley I'm fetching data from a server in json format using volley. Everything works fine when connected to Wifi. But when user is connected to mobile data and especially if mobile data connection is slow OnErrorResponse method is called. I have put a Toast message in OnErrorResponse method. In some devices this toast message crashes with NullPointerException while in others it runs fine. Also if I wait for a long time, and the results are not yet displayed then app crashes with outofmemory error. Please help me. How to handle these problems efficiently? Code: private RequestQueue songQueue = songQueue = Volley.newRequestQueue(getContext()); private void getNewSongs() { JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, newSongsUrl, null, new Response.Listener<JSONObject>() { @SuppressLint("LongLogTag") @Override public void onResponse(JSONObject response) { JSONObj...

Order button is not binding to firebase

Order button is not binding to firebase I'm creating cart button and cart inside the food order app. I get error after clicking on cart floatingaction button,following is the log cat and CartaAdapter.java. In the logcat I get error on the line 72 and 89. Also the screenshot of expected output is given and error output.i again got error on clicking the Place order button and after giving the addrress.unfortunately stops after clicking on order. error pic1 expected ouput after clicking yes on order pic2 Logcat error java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.example.sharma.digimenu.Model.User.getPhone()' on a null object reference at com.example.sharma.digimenu.Cart$2.onClick(Cart.java:95) at android.support.v7.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android...