title: How to implement startActivityForResult
body: <p>In my app I create two activities and I want to get input from the second activity and use it in the first activity, I use startActivityForResult but there is a problem in it!</p>
  
  <p>That is the code of first activity:</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_my);
      final Button b=(Button)findViewById(R.id.button);
  
      b.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent i=new Intent("net.naif.action.GETDATA");
              startActivityForResult(i,77);
          }
      });
  
  }
  
  protected void onActivityForResult (int requestCode,int resultCode,Intent data){
      if (requestCode ==77 &amp;&amp; resultCode ==RESULT_OK){
          String msg =data.getStringExtra("text");
  
          Toast.makeText(getBaseContext(),msg,Toast.LENGTH_SHORT).show();
      }
  }
  </code></pre>
  
  <p>And this for the second:</p>
  
  <pre><code> protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_second);
      final Button b=(Button)findViewById(R.id.button);
        final EditText t=(EditText)findViewById(R.id.editText);
      b.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              String s=t.getText().toString();
              Intent i=new Intent();
              i.putExtra("text",s);
              setResult(Activity.RESULT_OK,i);
              finish();
  
          }
      });
  }
  </code></pre>
  
  <p>Android studio notify me that is the method ( <code>protected void onActivityForResult (int requestCode, int resultCode, Intent data)</code> is never used.</p>