I'm sorry I'm using google translate.
I am trying to send data from a Fragment to an Activity with no success, the purpose of this is to update a TextView. I can't validate that the Intent brings the data and if I eliminate the validation they have a null value, I detail my code.
Fragment
private void sendData()
{
Intent i = new Intent(Context,Activity.Class);
//PACK DATA
i.PutExtra("COUNT", "1");
//START ACTIVITY
Activity.StartActivity(i);
}
Invoked
void ButtonClicked2(object sender, EventArgs args)
{
sendData();
}
Activity
protected override void OnResume()
{
base.OnResume();
//Intent i = Intent;
Bundle sender = Intent.Extras;
////IF ITS THE FRAGMENT THEN RECEIVE DATA
if (sender != null)
{
receiveData();
Android.Widget.Toast.MakeText(this, "Received", Android.Widget.ToastLength.Short).Show();
}
}
private void receiveData()
{
//RECEIVE DATA VIA INTENT
Intent i = Intent;
string count = i.GetStringExtra("COUNT");
//SET DATA TO TEXTVIEWS
Android.Widget.TextView CountView = FindViewById<Android.Widget.TextView>(Resource.Id.itemCount);
CountView.SetText(count, Android.Widget.TextView.BufferType.Normal);
Android.Widget.Toast.MakeText(this, count, Android.Widget.ToastLength.Short).Show();
}
