title: Android OnActivityResult not being called (C#, Xamarin)
body: <p>I am having quite an interesting issue. Let me emphasize that I haven't been programming much for android and it seems I might have gone off track somewhere.</p>
  
  <p>My problem is the triggering of the event onActivityResult(). I have read the Xamarin receipies but somehow it does not work. The routine does not get called in the MainActivity.</p>
  
  <p>I even tried to do a similar example on java, and there it worked like a charm.</p>
  
  <p>So, now to business. I have a MainActivity, which can start the Configuration Activity. This activity is supposed to collect the IP from the server (user manually puts it in), and return the String back to MainActivity. Fair and simple.</p>
  
  <p>MainActivity code snippet:</p>
  
  <pre><code>[Activity(Label = "Test", MainLauncher = true, Icon = "@drawable/ax")]
  public class MainActivity : Activity
  {
      protected override void OnCreate(Bundle bundle)
      {
          base.OnCreate(bundle);
  
          SetContentView(Resource.Layout.Main);
  
          setBindigs();
  
      }
  
      protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
      {
          base.OnActivityResult(requestCode, resultCode, data);
  
          switch (resultCode)
          {
              case Result.Ok:
                  //do something
                  break;
          }
  
      }
  
      private void setBindigs()
      {
          ImageView ax = FindViewById&lt;ImageView&gt;(Resource.Id.ax);
          ax.Click += HandleImageClick;
      }
  
      private void HandleImageClick(object sender, EventArgs e)
      {
          var conf = new Intent(this, typeof(Configuration));
          StartActivityForResult(conf, Convert.ToInt32(Result.Ok));
  
      }
  </code></pre>
  
  <p>And the Configuration snippet:</p>
  
  <pre><code> [Activity(Label = "Configuration")]
  public class Configuration : Activity
  {
      private Button[] Connects;
  
      protected override void OnCreate(Bundle savedInstanceState)
      {
          base.OnCreate(savedInstanceState);
          SetContentView(Resource.Layout.Configuration);
          setBindigs();
      }
  
      private void setBindigs()
      {
          const int KeyboardLength = 2;
  
          Connects = new Button[KeyboardLength];
  
          for (int I = 0; I &lt; KeyboardLength; ++I)
          {
              Connects[I] = FindViewById&lt;Button&gt;(Resource.Id.ConnectButton + I);
              Connects[I].Click += HandleKeyboardClick;
          }
      }
  
      private void HandleKeyboardClick(object sender, EventArgs e)
      {
          Button Clicked = sender as Button;
          Result ActivityResult = Result.Ok;
          String IpText = String.Empty;
  
          switch(Clicked.Id)
          {
              case Resource.Id.ConnectButton:
                  EditText IP = FindViewById&lt;EditText&gt;(Resource.Id.ServerIP);
                  IpText = IP.Text;
                  break;
  
              case Resource.Id.DisconnectButton:
                  ActivityResult = Result.Canceled;
                  break;
          }
        Intent myIntent = new Intent (this, typeof(MainActivity));
        myIntent.PutExtra ("IP", IpText);
        SetResult (Result.Ok, myIntent);
        Finish();
  
      }
  </code></pre>
  
  <p>Would you have any ideas? In java I used the option <code>getIntent();</code> instead of  <code>Intent myIntent = new Intent (this, typeof(MainActivity));</code></p>