简体   繁体   中英

how can i pass otp object from server to next activity

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();
                }
            }

getString() 在为 null 时抛出错误,您可以使用 get() 代替。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM