title: How to use setText() with a string object in android
body: <p>In the code below, I am reacting to an activity return.  When I get the correct code and result, I want to put the result of "data" into an uneditable text view.  I have tried to set the text view directly to the intent data using the following code:</p>
  
  <pre><code>encodedText.setText(data.getData().toString());
  </code></pre>
  
  <p>However I get an exception error when I try to do this.  I then tried to do it the following way(See arrow):</p>
  
  <pre><code>public void onActivityResult(int requestCode, int resultCode, Intent data)
  {
      if (requestCode == request_Code) {
          if (resultCode == RESULT_OK) {
              String encoded = data.getData().toString();
              TextView encodedText = (TextView) findViewById(R.id.result); 
          encodedText.setText(encoded); &lt;------
          }            
      }
  }
  </code></pre>
  
  <p>I put a break point at the line the arrow points to in the code example, and it is this line the program has a problem with.  I have looked at the setText() function in the textView docs and I still am not sure what I am doing wrong.  Anyone see what I don't?</p>