'Pass Intent from one activity to another activity

I want to transfer Intent to another activity in Xamarin.Android. Basically I need Intent.Data and Intent.ClipData to another activity, so I am using the below code to transfer the Intent but I don't know the proper way to retrieve that.

Here's the code in Main Activity

Intent intent = new Intent(this, typeof(SecondActivity));
intent.PutExtra("FilesURI", 0);
intent.PutExtras(intent);
StartActivity(intent);

In SecondActivity

if (intent.HasExtra("FilesURI"))
{
    var data = (Intent)intent.Extras;
    ProcessIntent(intent);
}

How do I retrieve Intent in second activity?



Solution 1:[1]

The Xamarin documentation has a page that gives an example of doing exactly what you're asking, passing data from one activity to another via intent extras.

In summary you'll need to call the following method in the receiving activity:

string text = Intent.GetStringExtra ("FilesURI") ?? "Data not available";

A more detailed example can be found in the Xamarin documentation, where the above sample was extracted from: Passing Data Between Activities

Solution 2:[2]

This line: intent.PutExtras(intent); will copy all extra data of intent. Assume intent has: "DATA" and "CLIPDATA" keys. You can retrieve like this in your SecondActivity

string text = Intent.GetStringExtra ("DATA") ?? "Data not available";

Solution 3:[3]

from one activity to others activity

Intent intent = new intent(Mainactivity.this,anotheractivityname.class); startactivity(intent)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Benjamin Scholtz
Solution 2 ColdFire
Solution 3 Aaqib Noor