Steps of passing data between activities :
var intent = new Intent(this, typeof(SecondActivity));
intent.PutExtra("_screenName", "Xamarin");
intent.PutExtra("_moduleId", "1234");
intent.PutExtra("_lattitude", "30.2525478");
intent.PutExtra("_longitude", "70.254789");
StartActivity(intent);
Now open the Second Activity and write the below code :
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
var ScreenName=Intent.Extras.GetString("_screenName");
var ModuleId= Intent.Extras.GetInt("_moduleId");
var Lattitude= Intent.Extras.GetDouble("_lattitude");
var Longitude= Intent.Extras.GetDouble("_longitude");
}
- Open visual studio 2015 and add a new project.
- Create a blank android application from application templates.
- After creating the project right click on the project root folder.
- Add the new item from the item templates.
- Choose the Activity and rename it as Second Activity.
- Go to the MainActivity.cs page and write the below code on button click event :
var intent = new Intent(this, typeof(SecondActivity));
intent.PutExtra("_screenName", "Xamarin");
intent.PutExtra("_moduleId", "1234");
intent.PutExtra("_lattitude", "30.2525478");
intent.PutExtra("_longitude", "70.254789");
StartActivity(intent);
Now open the Second Activity and write the below code :
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
var ScreenName=Intent.Extras.GetString("_screenName");
var ModuleId= Intent.Extras.GetInt("_moduleId");
var Lattitude= Intent.Extras.GetDouble("_lattitude");
var Longitude= Intent.Extras.GetDouble("_longitude");
}
No comments:
Post a Comment