Android Getting RESULT_CANCELED when I expecifically add RESULT_OK
<p>This is my problem, I have the main view which only shows one button, pressing this button another view is shown. This view has only another button, when this button is push this current view finishs and the control backs to the previous view.</p>

<p>To show the second view I use startActivityForResult, I put the code here.</p>

<pre><code>private void startNewview() {       
    Intent it = new Intent(getApplicationContext(), newView.class);
    startActivityForResult(it,VIEW_ID);

}
</code></pre>

<p>The view called only has a button event, here is the code</p>

<pre><code>Button b = (Button) findViewById(R.id.close);
    b.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            setResult(RESULT_OK);               
            finish();

        }
    });
</code></pre>

<p>And finally, the method onActivityResult in the main view, here is the code</p>

<pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    super.onActivityResult(requestCode, resultCode, data);
    if(requestCode == VIEW_ID &amp;&amp; resultCode == RESULT_OK) {
        tv = (TextView) findViewById(R.id.tv);
        tv.setText("The result ok is  here :)");
    }

}
</code></pre>

<p>The problem is resultCode always is 0 = RESULT_CANCELED and I do not know how to solve it, can anyone help me?</p>

<p>Thank you very much!</p>
