hi guys, sorry got involved in something else and just didn't look back here,....
this is what was happening: i hav an action_pick where the user picks an image and the resulting URI is used to display the image as is full-size on the imageview. This action wud cause an outofmemory error.... and also when I change orientation. after reading through a couple of other posts, I used BitmapFactory and scaled the original image before displayin it on imageview. The code is shown below. It is self-explanatory. While the scaling is done, I wanted to still use the original image file for later part of my app, which is what I did. try { InputStream is = getContentResolver().openInputStream( selectedImageURI); BitmapFactory.Options opts = new BitmapFactory.Options(); Bitmap bitmap; opts.inJustDecodeBounds = true; bitmap = BitmapFactory.decodeStream(is, null, opts); System.out.println("ht" + opts.outHeight); System.out.println("wt" + opts.outWidth); System.out.println("mime" + opts.outMimeType); BitmapFactory.Options ops2 = new BitmapFactory.Options (); WindowManager win = getWindowManager(); Display disp = win.getDefaultDisplay(); int width = disp.getWidth(); float w = opts.outWidth; int scale = Math.round(w / width); ops2.inSampleSize = scale; is = getContentResolver().openInputStream (selectedImageURI); bitmap = BitmapFactory.decodeStream(is, null, ops2); ImageView imageview1 = (ImageView) findViewById (R.id.imageview); imageview1.setImageBitmap(bitmap); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } Hope this helps. Thanks, Abhishek On Dec 18, 12:35 pm, Sergiu Dogaru <creative.art....@gmail.com> wrote: > how ? > > On Dec 18, 6:11 pm,Abhi<abhishek.r.sha...@gmail.com> wrote: > > > > > Resolved!!! > > > On Dec 18, 9:25 am,Abhi<abhishek.r.sha...@gmail.com> wrote: > > > > Anyone? > > > > On Dec 18, 12:11 am,Abhi<abhishek.r.sha...@gmail.com> wrote: > > > > > Hi, > > > > > I am doing the following in my app, which at times results in the > > > > above error. > > > > > Action 1: Button on Main activity calls all pictures using ACTION_PICK > > > > (results in a thumbnail view of all pictures on my phone). User picked > > > > image (URI) is then passed over to next activity where the image is > > > > displayed (ImageView) full screen. When I hit back, I go back to the > > > > main activity. If I try to open all pictures and pick a picture again, > > > > I get a FORCE CLOSE and the logCat data says "OutofMemoryError: bitmap > > > > size exceeds VM budget. > > > > > Action 2: I get the same error and FORCE CLOSE when I try to rotate > > > > the full-sized picture by changing phone orientation back and forth. > > > > > What am I supposed to do to save memory? I can't change the use case > > > > of my app... the user has to follow the above steps. How can I free up > > > > memory without having to change anything in my app. > > > > > Thanks, > > > > >Abhi- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en