0

when i open this url then https://wa20.nuke.co.in/mpcg/api/sign_in.php direct in browser it shows {"status":"404","message":"Failed"}

Now, i want to fetch status and message value in Android Studio how i can do this? i use volley library but it is not working correctly because i have many mistakes in it. if anyone have idea then guide me. Thanks:)

Qadir Ali
  • 58
  • 8
  • what have you done so far? what `not working corretcly` means? its JSON message, just decode and traverse the `status` or the `message` – zimorok Dec 04 '21 at 05:35
  • Check this https://www.geeksforgeeks.org/json-parsing-in-android-using-volley-library/?ref=rp , your json response is very simple . so this will help you. – Mohammad Arman Dec 04 '21 at 06:02
  • i don't have idea of json response. So, it is confusing me – Qadir Ali Dec 04 '21 at 06:40

1 Answers1

2

You are getting simple response , Try this sample code . It will work

RequestQueue requestQueue = Volley.newRequestQueue(this);
    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, LOGIN_URL, null, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            try {
                String status = response.getString("status");
                String message = response.getString("message");
                Toast.makeText(getApplicationContext(), ""+status+message, Toast.LENGTH_SHORT).show();


            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            error.printStackTrace();
        }
    });

    requestQueue.add(jsonObjectRequest);
Mohammad Arman
  • 508
  • 4
  • 13
  • If you are having issue of ssl then use this answer https://stackoverflow.com/questions/36043324/android-volley-error-trust-anchor-for-certification-path-not-found-only-in-r – Mohammad Arman Dec 16 '21 at 10:41