开发者

Android how to restrict user to upload a image less than 2MB

In my android application i am uploading a image but if the size is greater than 2MB it crashes. Anybody having the solution to stop the user to upload the image greater than 2MB

Thanx开发者_JS百科 in advance....


I'm not sure what you expect from a general question like that without any specifics, but a general question gets a general answer:

  1. Check image size. Depending on the format you can use the correct API for that.
  2. Compare image size to 2MB.
  3. Restrict if size is too large.


I also got these "out of memory" issue when I worked on images. But I problem is that the image dimemsion is to big. I post my solution for it, hope it can help u out.

BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inSampleSize=0.5;
BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜