android - How to handle out of memory error? -


I am using the following code to display a bitmap in my ImageView. When I enlarge the size image by 1.5 MB, then gives me an error Anyone gives me a suggestion?

  Try {URL aURL = New URL (myRemoteImages [val]); URLConnection conn = aURL.openConnection (); Conn.connect (); InputStream = Faucet; Try {is = conn.getInputStream (); } Hold (IOException e) {return 0; } Int a = conn.getConnectTimeout (); BufferedInputStream bis = new BufferedInputStream (is); Bitmap bm; Try {BM = BitMap Feature Encodestream (bis); } Hold (exception before) {bis.close (); is close(); Return 0; } Bis.close (); is close(); Img.setImageBitmap (BM); } Hold (IOException e) {return 0; } Return 1; Log Cat:  
  06-14 12: 03: 11.701: Error / Android Random (443) Heading out is 06-14 12: 03: 11.861: Error / Android Randomime (443): java.lang.OutOfMemoryError: The size of the bitmap is more than the VM budget 06-14 12: 03: 11.861: error / Android Random (443 ): On Android. Graphics. Bitmapfactory native diskstream (native method)  

InSampleSize option to reduce memory consumption Should be decoded with.

Another option in the zestedcodebows can help you find the right sample value


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -