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:
encodedText.setText(data.getData().toString());
However I get an exception error when I try to do this. I then tried to do it the following way(See arrow):
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); <------
}
}
}
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?
encodedTextis null it isn't found in the layout. Are you sure you have thisTextViewin your activity layout?Intentin thesetResult(resultCode, intent)method ? Maybe you should try putting extras into the intent before setting result and trying to read that instead.