title: Xamarin - update current tab fragment in viewPager
body: <p>I have 3 Fragments in a <code>viewPager</code>. Each fragment class has its own method to update fragment's views (for example, in TabFragment1.cs):</p>
  
  <pre><code>public void UpdateContent(View v)
      {
  
          // Sample values to read
          string locationCode = "528454";
  
          // Mapping views
          TextView tv_currentConditions = v.FindViewById&lt;TextView&gt;(Resource.Id.currentConditions);
          TextView tv_currentTemperature = v.FindViewById&lt;TextView&gt;(Resource.Id.currentTemperature);
          TextView tv_currentRealFeel = v.FindViewById&lt;TextView&gt;(Resource.Id.currentRealFeel);
          TextView tv_minMaxTemperature = v.FindViewById&lt;TextView&gt;(Resource.Id.minMaxTemperature);
  
          // Update view from database
          tv_currentConditions.Text = Sql.ReadValue(locationCode,"currentConditions");
          tv_currentTemperature.Text = Sql.ReadValue(locationCode, "currentTemperature") + "°C";
          tv_currentRealFeel.Text = GetString(Resource.String.feelLike) + " " + Sql.ReadValue(locationCode, "currentRealFeel") + "°C";
          tv_minMaxTemperature.Text = Sql.ReadValue(locationCode, "minTemperature") + " " + Sql.ReadValue(locationCode, "maxTemperature") + "°C";
  
      }
  </code></pre>
  
  <p>The challenge is: to define which fragment tab is selected now and launch the method from active fragment class. </p>
  
  <p>UPD: I know, how to get current tab number:</p>
  
  <pre><code>    public int currentTabNum;
  
      void setupViewPager(ViewPager viewPager)
      {
          var adapter = new Adapter(SupportFragmentManager);
          adapter.AddFragment(new tabFragment1(), GetString(Resource.String.tab1));
          adapter.AddFragment(new tabFragment2(), GetString(Resource.String.tab2));
          adapter.AddFragment(new tabFragment3(), GetString(Resource.String.tab3));
          viewPager.Adapter = adapter;
          viewPager.Adapter.NotifyDataSetChanged();
          viewPager.PageSelected += (object sender, ViewPager.PageSelectedEventArgs e) =&gt; {
              //Snackbar.Make(drawerLayout, e.Position.ToString(), Snackbar.LengthLong).Show();
              currentTabNum = e.Position;
          };
      }
  
      class Adapter: Android.Support.V4.App.FragmentPagerAdapter
      {
          List&lt;Android.Support.V4.App.Fragment&gt; fragments = new List&lt;Android.Support.V4.App.Fragment&gt;();
          List&lt;string&gt; fragmentTitles = new List&lt;string&gt;();
          public Adapter(Android.Support.V4.App.FragmentManager fm) : base(fm) { }
          public void AddFragment(Android.Support.V4.App.Fragment fragment, String title)
          {
              fragments.Add(fragment);
              fragmentTitles.Add(title);
          }
          public override Android.Support.V4.App.Fragment GetItem(int position)
          {
              return fragments[position];
          }
          public override int Count
          {
              get
              {
                  return fragments.Count;
              }
          }
          public override Java.Lang.ICharSequence GetPageTitleFormatted(int position)
          {
              return new Java.Lang.String(fragmentTitles[position]);
          }
      }
  </code></pre>
  
  <p>So, the question: how to send from intentService from its onDesroy() method, a command to mainActivity to update current tab?</p>