well, image is selected from the sdcard. can i check image size in onActivityResult to make sure that image can be set on imageView just to avoid this exception?
On Apr 2, 4:12 pm, Jean-Baptiste Queru <[email protected]> wrote: > Use smaller images. You're trying to allocate a bitmap that's 20 times > larger than the screen. That's just unrealistic on a constrained > device like a cell phone. > > JBQ > > > > On Thu, Apr 2, 2009 at 8:08 AM, zeeshan <[email protected]> wrote: > > > any solution? > > > On Apr 2, 2:05 pm, zeeshan <[email protected]> wrote: > >> thanks for the reply Mark, yes u r right issue is something related to > >> image pixels > >> i checked another image which is ok but i really need to display that > >> image. > >> i am getting the path of the image from DB in activity A and passing > >> it in extra to activity B to set as imageUri to ImageView. > >> here is my code: > > >> Activity B: > > >> public void onCreate(Bundle icicle) { > >> super.onCreate(icicle); > >> setContentView(R.layout.my_View); > >> loadSelectedImage(); > > >> } > > >> public void loadSelectedUtter(){ > > >> Bundle extras = getIntent().getExtras(); > >> if(extras !=null) > >> { > >> imageFile= extras.getString("image"); > > >> if(imageFile != null){ > >> image= Uri.parse(imageFile); > > >> imageicon.setImageURI(image); > >> } > > >> } > > >> } > >> } > > >> <ImageView > >> android:id="@+id/imageicon" > > >> android:src="@drawable/image" > >> android:adjustViewBounds="true" > >> android:maxWidth="291dip" > >> android:maxHeight="55dip" > >> android:layout_width="wrap_content" > >> android:layout_height="wrap_content" > >> android:layout_gravity="center" > >> /> > > >> it loads the image for first time but gives exception on rotation or > >> 2nd load. > > >> plz advise if u have any alternative solution or how can i call recycle > >> () on it. > > >> On Apr 2, 12:43 pm, Mark Murphy <[email protected]> wrote: > > >> > zeeshan wrote: > >> > > Hi Experts, > > >> > > I am beating my head against a wall since 3 days trying to resolve out > >> > > of memory exception but still no success. > >> > > here is the line giving me this error > > >> > > image_view.setImageURI(image_uri); > > >> > > everytime when i change the orientation or start this activity again, > >> > > it gives me out of memory exception > > >> > > VM won't let us allocate 6291456 bytes. > > >> > > it seems i am not leting GC to release my memory. > >> > > any solution would be appreciated > > >> > Use a different image. > > >> > The G1 has a 320x480 pixel display. Your image is consuming ~41 bytes > >> > per pixel...which seems a little high. More likely, it is a much higher > >> > resolution picture than the G1 display can handle. > > >> > So, use a different image. Or scale down the one you have before > >> > displaying it (and cache the smaller one to reuse on the rotation): > > >> >http://www.anddev.org/resize_and_rotate_image_-_example-t621.html > > >> > Also, call recycle() when you are done with the Bitmap, which may help > >> > GC it faster. > > >> > -- > >> > Mark Murphy (a Commons > >> > Guy)http://commonsware.com|http://twitter.com/commonsguy > > >> > Android App Developer Training:http://commonsware.com/training.html > > -- > Jean-Baptiste M. "JBQ" Queru > Android Engineer, Google. > > Questions sent directly to me that have no reason for being private > will likely get ignored or forwarded to a public forum with no further > warning. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

