我不明白:在android中,我沒有得到完整的字符串返回我輸入到stringbody。我檢查過這個字符串是完全保存的,但是當它傳遞給stringbody的時候它就會中斷。在同一個應用程序的桌面版本中,結果是成功的。但在Android中,字符串末尾的隨機部分會丟失。如果我嘗試在丟失後保存結果字符串,則該字符串會保存在同一個位置。我不使用任何口音或特殊字符。 的例子,從測試:StringBody沒有得到完整的字符串
第一次寫:
這是一個測試生物與我是書面方式在旅途中隨機消息。 如果這被削減,就像我期待的事情將被留在 了。讓我們看看會發生什麼。
一個保存保存此:
這是一個測試生物與我是書面方式在旅途中隨機消息。 如果這個被削減像我期待的東西將被排除在外
的第二次節省:
這是一個測試生物與我是書面方式在旅途中隨機消息。 如果這個被削減像我
的代碼是
protected void gravarPerfil() throws UnsupportedEncodingException {
MultipartEntity entity = new MultipartEntity();
StringBody sAcerca = null, sLoc = null;
DefaultHttpClient client = new DefaultHttpClient();
if (cookie != null) {
client.getCookieStore().addCookie(cookie);
}
HttpPost post = new HttpPost(address + "/dinamicas/editarPerfil");
FileBody imagebin = null;
if (imgfile != null) {
imagebin = new FileBody(imgfile);
}
Log.v("msg", acerca.getText().toString());
這裏是我的filebody犯規加載整個字符串
sAcerca = new StringBody(acerca.getText().toString());
sLoc = new StringBody(local.getText().toString());
try {
entity.addPart("acerca", sAcerca);
entity.addPart("localizacao", sLoc);
if (imgfile != null) {
entity.addPart("foto", imagebin);
}
post.setEntity(entity);
HttpResponse response = client.execute(post);
} catch (Exception e) {
e.printStackTrace();
}
我以前有過類似的問題。我完全從模擬器/設備上卸載了應用程序,然後再次嘗試 - 然後就沒事了。一旦進入藍月亮,事情就會被破壞,應用程序擦除會修復它。 – CelticParser
卸載,重新安裝,創建新的模擬器,從Apache中刪除罐子,並安裝相同版本的新的...沒有什麼作品。 :\ – Lucky
它仍然可能是你的服務器(在Android和服務器之間)所以[我認爲這可能是你需要的](http://stackoverflow.com/questions/8505811/image-gets-distorted-sometime-while-上傳) - 與您的問題類似,但在發送多部分數據時使用圖像。 – CelticParser