I ran into a similar problem. If you do not need the full-size images
then you should use the BitmapFactory.Options class to specify a
different sample size to safe memory. This is some piece of code which
I'm using for loading pictures from the media store:

InputStream bitmapInputStream = mContext.getContentResolver
().openInputStream(bitmapUri);
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inSampleSize = 4; // specify whatever matches your needs
Bitmap bitmap = BitmapFactory.decodeStream(bitmapInputStream, null,
opts);

--
Have fun,
André



On 18 Mai, 19:03, Tjerk Wolterink <tje...@gmail.com> wrote:
> But it's still strange that sometimes it works and sometimes it doesnt
> work.. hmmm.And another concern: future devices may have more / less
> memory.
> How do i deal with that? Can i check the maximum amount of memory?
> Or just stick to the 16mb limit?
>
> 2009/5/18 Romain Guy <romain...@google.com>
>
>
>
>
>
> > That's correct.
>
> > On Mon, May 18, 2009 at 9:53 AM, Tjerk Wolterink <tje...@gmail.com> wrote:
> > > Aha ok, so if this memmory is thrown it mean i really have to cut down
> > > on memory usage. Is that right? I have a lot of sprites and a lot fo
> > > gamesounds,
> > > which takes a lot of memory.
>
> > > 2009/5/18 Romain Guy <romain...@google.com>
>
> > >> > Another problem: a user can run a lot of applications in
> > >> > the background. When a user tries to run my game but my game
> > >> > runs out of memmory .. what should i do?
> > >> > How should i deal with this kind of situation?
>
> > >> If your apps needs memory, Android will kill a background process. And
> > >> your app is limited to a maximum of 16 MB anyway.
>
> > >> --
> > >> Romain Guy
> > >> Android framework engineer
> > >> romain...@android.com
>
> > >> Note: please don't send private questions to me, as I don't have time
> > >> to provide private support.  All such questions should be posted on
> > >> public forums, where I and others can see and answer them
>
> > > --
> > > --
> > > Tjerk Wolterink @ GMail
>
> > --
> > Romain Guy
> > Android framework engineer
> > romain...@android.com
>
> > Note: please don't send private questions to me, as I don't have time
> > to provide private support.  All such questions should be posted on
> > public forums, where I and others can see and answer them
>
> --
> --
> Tjerk Wolterink @ GMail
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to