I see any intent has extra
field and a data
field.
is there any difference between them or it's just a conceptual difference?
The Android Intent class is commonly used to move from one activity to another. The Intent class has a method named putExtra() that you can use to put extended data to the intent. The main use of the putExtra() method is to send values you need in the next activity.
Bundles are used with intent and values are sent and retrieved in the same fashion, as it is done in the case of Intent. It depends on the user what type of values the user wants to pass, but bundles can hold all types of values (int, String, boolean, char) and pass them to the new activity.
Using putExtra() and getExtras() in android Intents are asynchronous messages which allow Android components to request functionality from other components of the Android system. For example an Activity can send an Intents to the Android system which starts another Activity .
For this, Intent will start and the following methods will run: putExtra() method is used for sending the data, data in key-value pair key is variable name and value can be Int, String, Float, etc. getStringExtra() method is for getting the data(key) that is sent by the above method.
Data
The URI (a Uri object) that references the data to be acted on and/or the MIME type of that data. The type of data supplied is generally dictated by the intent's action. For example, if the action is ACTION_EDIT, the data should contain the URI of the document to edit.
Data return URI
Extras
Key-value pairs that carry additional information required to accomplish the requested action. Just as some actions use particular kinds of data URIs, some actions also use particular extras.
Extras contains a Bundle which is an implementation of HashMap to store key values of specific data .
Extra Return Bundle
For more information About Intent extra And Data refer this Url
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With