loopj ライブラリ ( https://github.com/loopj/android-async-http ) を使用していますが、最近 API 23 と互換性があるように変更されました。
「put」リクエストを送信するとき、次のStringEntity
ように put メソッドに渡します。
client.put(CallApplication.getContext(),url, request.StringEntity, responseHandler);
MyStringEntity
は、次のようにして Json に変換されるオブジェクトです。
public static StringEntity getJsonFromObject(Object object) {
String json = new Gson().toJson(object);
StringEntity stringEntity = null;
try {
stringEntity = new StringEntity(json, HTTP.UTF_8);
stringEntity.setContentType("text/json");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return stringEntity;
}
代わりに使用する必要がありますが、HttpEntity
どうすれば入手できるかが明確ではありません。json 文字列を に取得するにはどうすればよいHttpEntity
ですか?