title: Pass callback to startActivityForResult without changing activity class
body: <p>My problem that I need to get a cookie from my site. To solve this I have an API endpoint like <code>http://example.com/cookie</code> which redirects using app schema <code>myapp://cookie=some_cookie</code></p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      if (goToBrowser) { // Going to url which redirects back to this activity
          Intent intent = new Intent(Intent.ACTION_VIEW, uri);
          intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
          startActivityForResult(intent, RESULT_OK);
      } else { // Parcing incoming url
          setResult(RESULT_OK);
          finish();
      }
  }
  </code></pre>
  
  <p>I have an <code>Activity</code> which processes app schema. How can I get <code>some_cookie</code> if I can't change <code>appActivity</code> class?</p>
  
  <p><strong>UPDATE</strong>:
  I managed to get cookie using answers, but when I call <code>finish()</code>, it returns to browser, not to activity, which called browser</p>
  
  <p><strong>UPDATE 2</strong>:
  I updated the code, added flag, but the behaviour is same</p>