TwitterApi json不接受阿拉伯语和其他语言

时间:2015-12-06 08:46:24

标签: java android json android-twitter

您好我正在Twitter客户端工作,当我撰写推文并以阿拉伯语或日语发布时它不接受它。为什么?

这是发布推文的方法:

public void postTweet(String body, AsyncHttpResponseHandler handler) {
    Log.i(CLASS, "statuses/update.json");
    String apiUrl = getApiUrl("statuses/update.json");
    RequestParams params = new RequestParams();
    params.put("status", body);
    getClient().post(apiUrl, params, handler);
}

这是在点击发送按钮之后:

  send.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            TwitterClient client = RestApplication.getRestClient();
            client.postTweet(tweet.getText().toString(), new AsyncHttpResponseHandler() {
                @Override
                public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                    Toast.makeText(getActivity(), "Sent Successfully", Toast.LENGTH_LONG).show();
                    dismiss();
                }

                @Override
                public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                    Log.e(CLASS, "Error sending the tweet. Status: " + statusCode, error);
                    Toast.makeText(getActivity(), "Error sending the tweet, please try again.", Toast.LENGTH_LONG).show();
                }
            });
        }
    });

任何帮助,请

1 个答案:

答案 0 :(得分:0)

您应该为它指定字符集:

试试这个:

ContentType.create("application/json", CharSet.forName("UTF-8"));