mia app scopo principale è quello di visualizzare immagini in seguito la moda come mostrato nella immagineAndroid Bitmap.createScaledBitmap getta java.lang.OutOfMemoryError per lo più su Jelly Bean 4.1
private void setSelectedImage(int selectedImagePosition)
{
BitmapDrawable bd = (BitmapDrawable) drawables.get(selectedImagePosition);
Bitmap b = Bitmap.createScaledBitmap(bd.getBitmap(), (int) (bd.getIntrinsicHeight() * 0.9), (int) (bd.getIntrinsicWidth() * 0.7), false);
selectedImageView.setImageBitmap(b);
selectedImageView.setScaleType(ScaleType.FIT_XY);
}
codice dettagliate possono essere trovare here
viene generata un'eccezione alla riga seguente
Bitmap b = Bitmap.createScaledBitmap(bd.getBitmap(), (int) (bd.getIntrinsicHeight() * 0.9), (int) (bd.getIntrinsicWidth() * 0.7), false);
La funzione precedente è denominata da onItemSelected
. ** L'app funziona ancora correttamente su 2.2 e 2.3, ma genera un'eccezione immediata su 4.1 Il codice sopra funziona bene, ma genera un'eccezione successiva. Non ho mai visto crash in 2.2 e 2.3, ma si blocca immediatamente in 4.1 C'è qualche differenza importante nella gestione della memoria in Jelly Bean? **:
java.lang.OutOfMemoryError
AndroidRuntime(2616): at android.graphics.Bitmap.nativeCreate(Native Method)
AndroidRuntime(2616): at android.graphics.Bitmap.createBitmap(Bitmap.java:640)
AndroidRuntime(2616): at android.graphics.Bitmap.createBitmap(Bitmap.java:586)
AndroidRuntime(2616): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:466)
AndroidRuntime(2616): at com.rdx.gallery.GalleryDemoActivity.setSelectedImage(GalleryDemoActivity.java:183)
Quali sono le dimensioni e la larghezza della bitmap? –
bitmap width e height è 363X387 – RDX
Penso che il problema sia selezionatoImageView.setScaleType (ScaleType.FIT_XY); –