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

前端 未结 2 1558
自闭症患者
自闭症患者 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:17

    You pass data along with the Intent using two mechanisms, depending on the needs of your application.

    1. The data field, via Intent.setData(): This is a URI that you can use to indicate the location of a resource the new Activity may need to use
    2. Extras, via Intent.putExtra(): You can attach as many extras to an Intent as you like to represent the data you need to pass (both forwards to the new Activity and backwards with the result). Extras can be any primitive or easily serializable object.

    HTH

提交回复
热议问题