Hi Everyone !
I´m getting the exception OutOfMemoryError! Please help me, i´m 5 days with this problem !!
I load bitmap once on "FirstTime", put it on Map and then use it, so when i call "Activity.Finish" this activity closes, and when i open it again, i get the exception OutOfMemoryError. Why if i don´t Load Bitmap again, i use the bitmaps i have puted on MAP variable.
Part of My COde
SEE LOG
FATAL EXCEPTION: main
java.lang.OutOfMemoryError
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:543)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:518)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:370)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
at android.content.res.Resources.loadDrawable(Resources.java:1970)
at android.content.res.Resources.getDrawable(Resources.java:676)
at uk.co.martinpearman.b4a.androidresources.AndroidResources.GetApplicationDrawable(AndroidResources.java:129)
at com.mobileforfunapps.descobrindomeumundo.basemod._buscarimagem(basemod.java:164)
at com.mobileforfunapps.descobrindomeumundo.frmquizzanimais._montarlayout(frmquizzanimais.java:931)
at com.mobileforfunapps.descobrindomeumundo.frmquizzanimais._activity_create(frmquizzanimais.java:334)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:174)
at com.mobileforfunapps.descobrindomeumundo.frmquizzanimais.afterFirstLayout(frmquizzanimais.java:98)
at com.mobileforfunapps.descobrindomeumundo.frmquizzanimais.access$100(frmquizzanimais.java:16)
at com.mobileforfunapps.descobrindomeumundo.frmquizzanimais$WaitForLayout.run(frmquizzanimais.java:76)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4624)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
at dalvik.system.NativeStart.main(Native Method)
threadid=86: interp stack at 0x4d30b000
threadid=86: calling run()
Force finishing activity com.mobileforfunapps.descobrindomeumundo/.frmquizzanimais
Thanks So Much
Rafael
I´m getting the exception OutOfMemoryError! Please help me, i´m 5 days with this problem !!
I load bitmap once on "FirstTime", put it on Map and then use it, so when i call "Activity.Finish" this activity closes, and when i open it again, i get the exception OutOfMemoryError. Why if i don´t Load Bitmap again, i use the bitmaps i have puted on MAP variable.
Part of My COde
B4X:
Sub Process_Globals
Dim mapImagensMiniaturas As Map
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim First as Boolean
First = FirstTime
if FirstTime = True Then
mapImagensMiniaturas.Initialize 'Inicialize only on FirstTime
End If
End Sub
Sub carregarScroolListaPersonagens
ArrayPersonagens(0) = "galo_pq.png#galo_grd.png#Galo#Cock#galo.mp3"
ArrayPersonagens(1) = "bode_pq.png#bode_grd.png#Bode#Billy-Goat#cabra.mp3"
ArrayPersonagens(2) = "cavalo_pq.png#cavalo_grd.png#Cavalo#Horse#cavalo.mp3"
ArrayPersonagens(3) = "ganso_pq.png#ganso_grd.png#Ganso#Goose#ganso.mp3"
ArrayPersonagens(4) = "porco_pq.png#porco_grd.png#Porco#Pig#porco.mp3"
ArrayPersonagens(5) = "vaca_pq.png#vaca_grd.png#Vaca#Cow#vaca.mp3"
ArrayPersonagens(6) = "galinha_pq.png#galinha_grd.png#Galinha#Chicken#galinha.mp3"
ArrayPersonagens(7) = "peru_pq.png#peru_grd.png#Peru#Turkey#peru.mp3"
ArrayPersonagens(8) = "touro_pq.png#touro_grd.png#Touro#Taurus#touro.mp3"
ArrayPersonagens(9) = "pato_pq.png#pato_grd.png#Pato#Duck#pato.mp3"
ArrayPersonagens(10) = "ovelha_pq.png#ovelha_grd.png#Ovelha#Sheep#ovelha.mp3"
For i = 0 To 10
Dim imgPers As ImageView
Dim dadosPersonagens(2) As String
dadosPersonagens = Regex.Split("#", ArrayPersonagens(i))
imgPers.Initialize("imgPers")
imgPers.Tag = ArrayPersonagens(i)
imgPers.Gravity = Gravity.FILL
If First= True Then
mapImagensMiniaturas.Put(i,LoadBitmapSample(File.DirAssets,dadosPersonagens(0),baseMod.larguraMiniauras,baseMod.larguraMiniauras)) 'I Execute LoadBitmapSample only on FirstTime and put it on Map variable
End If
imgPers.Bitmap = mapImagensMiniaturas.GetValueAt(i) 'Use Bitmap from MAP
scrwBarraCima.Panel.AddView(imgPers,leftPersonagemScrool,5,baseMod.larguraMiniauras,baseMod.larguraMiniauras)
Next
END Sub
SEE LOG
FATAL EXCEPTION: main
java.lang.OutOfMemoryError
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:543)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:518)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:370)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
at android.content.res.Resources.loadDrawable(Resources.java:1970)
at android.content.res.Resources.getDrawable(Resources.java:676)
at uk.co.martinpearman.b4a.androidresources.AndroidResources.GetApplicationDrawable(AndroidResources.java:129)
at com.mobileforfunapps.descobrindomeumundo.basemod._buscarimagem(basemod.java:164)
at com.mobileforfunapps.descobrindomeumundo.frmquizzanimais._montarlayout(frmquizzanimais.java:931)
at com.mobileforfunapps.descobrindomeumundo.frmquizzanimais._activity_create(frmquizzanimais.java:334)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:174)
at com.mobileforfunapps.descobrindomeumundo.frmquizzanimais.afterFirstLayout(frmquizzanimais.java:98)
at com.mobileforfunapps.descobrindomeumundo.frmquizzanimais.access$100(frmquizzanimais.java:16)
at com.mobileforfunapps.descobrindomeumundo.frmquizzanimais$WaitForLayout.run(frmquizzanimais.java:76)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4624)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
at dalvik.system.NativeStart.main(Native Method)
threadid=86: interp stack at 0x4d30b000
threadid=86: calling run()
Force finishing activity com.mobileforfunapps.descobrindomeumundo/.frmquizzanimais
Thanks So Much
Rafael
Last edited: