-2

how can i pass otp object from server to next activity

private  void savedata (final  String mob){
        StringRequest request =new StringRequest(Request.Method.POST,urltechno, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    JSONObject object=new JSONObject(response);
                    if ( object.names().get(0).equals("success")){
                        Toast.makeText(getApplicationContext(),"Successfully send request",Toast.LENGTH_LONG).show();
                         Intent intent = new Intent(getApplicationContext(), Otp_verification.class);
                         intent.putExtra("mobile",mob);
                         intent.putExtra("otp",object.getString("otp"));//in this section problem occured
                         startActivity(intent);
                    }else{
                        Toast.makeText(getApplicationContext(),"invalid number",Toast.LENGTH_LONG).show();
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
Thangadurai
  • 2,573
  • 26
  • 32

1 Answers1

0

getString()throws a error when its null,you can use get() instead.

Akash Jp
  • 162
  • 1
  • 10