how do I get a string from my http response android?

后端 未结 2 2354
旧时难觅i
旧时难觅i 2021-02-19 23:11

I\'ve seen some really ugly looking code from people writing up their own methods of converting an HttpResponse to a string to use later, that looks something like this:

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-19 23:21

    YES, THERE IS! YOU CAN DO ALL OF THAT IN ONE LINE! Just like this:

    response = client.execute(post);
    String responseStr = EntityUtils.toString(response.getEntity());
    

    happy app making

提交回复
热议问题