Xamarin – Passing Data between Activities in Android Application
Sometimes it is required to pass some information to the next activity; that is called passing data between activities. In this post we would see how we pass data between activities.
In the last post you had experienced how do we open another activity from current activity. Consider that example and we would pass the info to the next activity.
An intent not only allows you to start another activity, but it can carry a bundle of data to the activity as well. So we need Intent again.
For instance I would like to pass a URL to the next activity. We should do the following in the activity from which you are going to pass on.
The PutExtra method has two parameters; the first one is to identify the value with the key, and the second one is the value. The following are the overloaded methods available for different types.
Now in the target activity, to receive the data, we need to do the following.
As you see, for checking null, we are using the null-coalescing operator.
Let’s run the application.
And on the second activity.
Hope this post helps, thanks for reading.
Full Source code: Click Here