1

I have a code like this:

@Override
public void onSuccess(int statusCode, Header[] headers,
        byte[] responseBody) {
    // TODO Auto-generated method stub
    String response = new String(responseBody);

    text.setText(response+"aa");

}

Textview is like this: [B@4104dc30aa is it byte array, if it how can I convert to normal text?

1
  • Note that the toString for a byte array ([B@4104dc30aa) is simply the array symbol [ followed by B for byte, @, and the array's hash value -- not a helpful dump of the array for diagnostic purposes. What you need to know is the encoding of the byte array (assuming it's character data at all). One would hope it's UTF8, but could be others. Commented Aug 26, 2014 at 12:00

1 Answer 1

3

Try this:

String response = new String(responseBody, "UTF-8");
text.setText(response);
System.out.println("text set: " + text.getText().toString());

That might help.

Sign up to request clarification or add additional context in comments.

3 Comments

Isn't the value returned from getText already a String? Is there any point in doing toString on it?
@HotLicks No. Added that just out of habit. :)
To be picky, getText returns a CharSequence.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.