How to send data to new activity from current activity via intent?

前端 未结 2 1556
自闭症患者
自闭症患者 2021-01-16 07:38

How I can use the intent to send the data to the second class?

I am doing this actually

Intent connectGetData = new Intent(Main.this, GetData.class);         


        
2条回答
  •  隐瞒了意图╮
    2021-01-16 08:19

    At sending activity...

    Intent intent = new Intent(current.this, next.class);
    intent.putextra("keyName","value");
    startActivity(intent);
    

    At receiving activity...

    String data = getIntent().getExtras().getString("keyName");
    

    Thus you can have data at receiving activity from sending activity...

提交回复
热议问题