title: How I can return data from fragment to activity?
body: <p>I have trouble to return data from fragment to activity.  </p>
  
  <p>I have <strong>Activity A</strong>: is main activity for add product, user when click the text view (selectCategory) this activity show to user <strong>activity B</strong> which content <strong>fragment Bb</strong>(all type of Category), when user clicks in some of this categories, the app going to show user activity C which has <strong>fragment Cc</strong> (subcategories).</p>
  
  <p>Here my problem: I need when the user clicks in some of this subcategory which content in <strong>fragment Cc</strong> to return data to <strong>activity A</strong> then show to the user.</p>
  
  <p>A call --> B </p>
  
  <pre><code>categoryTextView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      Intent i= new Intent(A.this,B.class);
      i.putExtra("fragmenttype","CategoryFragment");
      startActivityForResult(i,10);
    }
  }); 
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 10) {
      if (resultCode == RESULT_OK) {
        titleProduct.setText(data.getStringExtra("nodecategory"));
      }
    }
  }
  </code></pre>
  
  <p>return data from <strong>Cc fragment</strong> to <strong>A</strong> but nothing happened (I need from code to go to <strong>activity A</strong> to catch data in <code>onActivityResult</code>):</p>
  
  <pre><code>@Override
  public void onClick(TreeNode node, Object value) {
    Intent i = new Intent();
    i.putExtra("nodecategory","hi");
    getActivity().setResult(Activity.RESULT_OK, i);
    getActivity().finish();
  }
  </code></pre>