PutExtra doesn't work on the retriever side

前端 未结 4 1152
借酒劲吻你
借酒劲吻你 2021-01-07 06:18

I want to sent intent from one first activity to another.

The first activity sends an intent to the second activity in order to create a new AlertDialog, receive a n

相关标签:
4条回答
  • 2021-01-07 06:28

    in onActivityResult you are not suppposed to call

    intent = getIntent();
    

    directly you have got the

    protected void onActivityResult(int requestCode, int resultCode, Intent data)
    

    where data corresponds to the data sent from the alert box activity. Just directly calling

    data.getIntExtra("data2", -1);
    

    should do. Hope I was clear enough.

    0 讨论(0)
  • 2021-01-07 06:48

    Try

    Bundle extra=data.getExtras();
    

    Insted of

    Bundle extra=getIntent().getExtras();
    
    0 讨论(0)
  • 2021-01-07 06:49

    try this way

      int data1,data2;
      Bundle extra=getIntent().getExtras();
      if(extra!=null){
      data1=extra.getInt("data1");
      data2=extra.getInt("data2");
      }
    
    0 讨论(0)
  • 2021-01-07 06:49

    try with this.

     Bundle extras = getIntent().getExtras();
     int a=extras.getInt("data1");
    
    0 讨论(0)
提交回复
热议问题