我有一个包含 TextView
的Android活动,它从servlet接收文本值 . servlet响应的活动将请求文本值 . 我试图用不同的区域语言来获得文本值 . 让我们说 Tamil ,这是 India 中的区域语言 .
我有数据库中Android活动的 TextView
的文本值,servlet将其提取并发送到活动 . 我正在使用MySQL数据库,它可以保存 Tamil 语言文本,甚至servlet也可以将 Tamil 语言文本放入 JSONObject
.
问题出现在android活动的接收端(即),解析时 JSONObject
给出问号(?)符号
如果我静态给出 TextView
的文本值,它可以正常工作 .
有什么建议???
这是 AllAsyncTask.java 的代码,我从servlet接收文本值
AllAsyncTask.java
public class AllAsyncTask extends AsyncTask<String, Integer, Double>{
String httpPostStr, res;
Context context;
String textValue;
public AllAsyncTask(Context context)
{
this.context = context;
}
@Override
protected Double doInBackground(String... params) {
// TODO Auto-generated method stub
postData(params[0]);
return null;
}
protected void onPostExecute(Double result) {
Intent intent = new Intent(context, CategoriesActivity.class);
intent.putExtra(Constants.TEXT_VALUE, textValue);
context.startActivity(intent);
}
public void postData(String valueToSend)
{
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(Constants.GatewayUrl);
try
{
StringEntity stringEntity = new StringEntity(valueToSend);
httpPost.setEntity(stringEntity);
httpPost.setHeader("Accept", "application/json");
httpPost.setHeader("Content-type", "application/json");
httpPostStr = httpPost.toString();
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
res = EntityUtils.toString(httpEntity, "UTF-8");
JSONObject jsonObject = new JSONObject(res);
textValue = jsonObject.getString(Constants.TEXT_VALUE);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}