从 Android 发布文件时出现内存问题
当我尝试从 Android 应用程序上传图像或更大的文件时,它会因 OutOfMemoryException 崩溃。我想知道是否有其他方法可以做到这一点。
我在两个不同的地方发生了应用程序崩溃:
Base64.encodeToString(bytes, Base64.DEFAULT);
这里的 base64 字符串是 nameValuPairs 集合中的值之一。
HttpClient client = new DefaultHttpClient();
HttpPost httppost = new HttpPost(uo.WebServiceURL);
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(nameValuePairs); // On this line
httppost.setEntity(entity);
HttpResponse response = client.execute(httppost);
有什么想法吗?
When I try to upload images or larger files from my android app it crashes with an OutOfMemoryException. Im wondering if there are any alternate ways of doing this.
Ive had the application crash in two different spots:
Base64.encodeToString(bytes, Base64.DEFAULT);
And here where the base64 string is one of the values in the nameValuPairs collection.
HttpClient client = new DefaultHttpClient();
HttpPost httppost = new HttpPost(uo.WebServiceURL);
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(nameValuePairs); // On this line
httppost.setEntity(entity);
HttpResponse response = client.execute(httppost);
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 Android 中发布大文件
也检查一下....... ..
正如 Schnapple 所说,你的问题似乎非常广泛,并且难以阅读和理解。
下面是一些发送 HTTP POST 并从服务器获取响应的通用代码,但这可能会有所帮助。
Posting a large file in Android
Check This also .........
As Schnapple says your question seems very broad and is confusing to read and understand.
Here is some general code to send a HTTP POST and get a response from a server though that may be helpful.
这是因为图像尺寸太大,有一些关于如何解决此问题的解释,我将向您指出一个已经提出的问题。
将图像加载到位图对象时出现奇怪的内存不足问题
希望这有帮助。
It is because the image size is too high, there is some explanation in to how to resolve this issue, i will point you to a question that has already been asked.
Strange out of memory issue while loading an image to a Bitmap object
hope this helps.