簡體   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