繁体   English   中英

我如何将 otp 对象从服务器传递到下一个活动

[英]how can i pass otp object from server to next activity

我如何将 otp 对象从服务器传递到下一个活动

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() 代替。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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