Yeah! Thanks a lot :)
On May 8, 10:11 pm, Streets Of Boston <[email protected]> wrote: > Your image is probably too big. > By setting a 2048x1536 pixels image, you will eat up about 6MByte of > memory right there. > The memory of the large bitmap may not be cleaned up quick enough when > chaning orientation. > > To get around this issue, scale the bitmap yourself: > Read in the full-size bitmap by getting the inputstream from the > imageUri (getContentResolver()), use the inputstream and BitmapFactory > to get a Bitmap (be sure to set inSampleSize to something larger than > 1 and the type to RGB_565 to conserve memory). Then from this Bitmap, > create a new bitmap that is scaled to the size of your imgUpload view. > > On May 8, 11:43 am, "[email protected]" > > <[email protected]> wrote: > > Hi, > > > I get an OutOfMemoryError every time i change the screen orientation > > and I am having a hard time finding the mistake... > > > The Activitie's view consists of an ImageView, two Buttons and a > > Spinner. I don't have static variables and can't imagine where i could > > leak a context. > > > Most of the times, the exception is thrown at setContentView > > (R.layout.upload); > > sometimes it goes fine until imgUpload.setImageURI(imageURI); > > > The images i am displaying are form the G1's camera, so about 500kb > > and 2048x1536pixels > > > Here is some code: > > ------------------------------------------------------------------------------------- > > private ImageView imgUpload; > > private Spinner spnCollections; > > private Button btnEditMetadata; > > private Button btnUpload; > > private Uri imageURI; > > > @Override > > public void onCreate(Bundle savedInstanceState) { > > super.onCreate(savedInstanceState); > > setContentView(R.layout.upload); > > > // Get View References > > imgUpload = (ImageView) findViewById(R.id.imgUpload); > > spnCollections = (Spinner)findViewById(R.id.spnCollections); > > btnEditMetadata = (Button) > > findViewById(R.id.btnEditMetadata); > > btnUpload = (Button)findViewById(R.id.btnUpload); > > > // Get Image from ACTION_SEND Intent > > Intent intent = getIntent(); > > if (intent.getAction() != null && intent.getAction().equals > > (Intent.ACTION_SEND)) { > > Bundle extras = intent.getExtras(); > > imageURI = > > (Uri)extras.getParcelable(Intent.EXTRA_STREAM); > > imgUpload.setImageURI(imageURI); > > } > > ... > > ------------------------------------------------------------------------------------- --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

