manolazo
23/07/13, 01:32:45
Buenas.
Estoy probando una aplicacion en la cual realizo un TransitionDrawable dentro de un Timer.
public void onClick(View v) {
.
.
.
timer = new Timer();
timer.schedule(new TimerTask(){
@Override
public void run() {
bm1 = BitmapFactory.decodeResource(contexto.getResources (), R.drawable.foto);
bm2 = BitmapFactory.decodeResource(contexto.getResources (), imagenes[parlinear.get(0).getId()]);
drawables = new BitmapDrawable[2];
drawables[0] = new BitmapDrawable(contexto.getResources(), bm1);
drawables[1] = new BitmapDrawable(contexto.getResources(), bm2);
trans = new TransitionDrawable(drawables);
trans2 = new TransitionDrawable(drawables2);
handler.post(new runa());
}
}, 4000);
fuera del hilo ponemos la transicion en un imageview (im1)
final Handler handler = new Handler();
class runa implements Runnable{
@Override
public void run() {
im1.setImageDrawable(trans);
trans.startTransition(2000);
}
}
Pues bien, las primeras pulsaciones sobre el imageView no pasa nada, pero sobre la sexta pulsacion se me arroja el siguiente error:
Se ve que esta relacionado con la linea BitmapFactory.decodeResource() pero por mas que modifico no consigo dar con ello.
Alguna idea de por donde van los tiros?
07-22 22:36:51.085: E/dalvikvm-heap(26085): Out of memory on a 2183696-byte allocation.
07-22 22:36:51.085: I/dalvikvm(26085): "Timer-5" prio=5 tid=16 RUNNABLE
07-22 22:36:51.085: I/dalvikvm(26085): | group="main" sCount=0 dsCount=0 obj=0x4254be18 self=0x5d112a70
07-22 22:36:51.085: I/dalvikvm(26085): | sysTid=28587 nice=0 sched=0/0 cgrp=apps handle=1515006088
07-22 22:36:51.085: I/dalvikvm(26085): | schedstat=( 51788168 1015247 20 ) utm=5 stm=0 core=3
07-22 22:36:51.085: I/dalvikvm(26085): at android.graphics.BitmapFactory.nativeDecodeAsset(N ative Method)
07-22 22:36:51.090: I/dalvikvm(26085): at android.graphics.BitmapFactory.decodeStream(Bitmap Factory.java:623)
07-22 22:36:51.090: I/dalvikvm(26085): at android.graphics.BitmapFactory.decodeResourceStrea m(BitmapFactory.java:476)
07-22 22:36:51.090: I/dalvikvm(26085): at android.graphics.BitmapFactory.decodeResource(Bitm apFactory.java:499)
07-22 22:36:51.090: I/dalvikvm(26085): at android.graphics.BitmapFactory.decodeResource(Bitm apFactory.java:529)
07-22 22:36:51.095: I/dalvikvm(26085): at com.example.ejercicios3.Prueba3GridLayout_JuegoMem orion$linearListener$3.run(Prueba3GridLayout_Juego Memorion.java:187)
07-22 22:36:51.100: I/dalvikvm(26085): at java.util.Timer$TimerImpl.run(Timer.java:284)
07-22 22:36:51.105: A/libc(26085): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 28587 (Timer-5)
Estoy probando una aplicacion en la cual realizo un TransitionDrawable dentro de un Timer.
public void onClick(View v) {
.
.
.
timer = new Timer();
timer.schedule(new TimerTask(){
@Override
public void run() {
bm1 = BitmapFactory.decodeResource(contexto.getResources (), R.drawable.foto);
bm2 = BitmapFactory.decodeResource(contexto.getResources (), imagenes[parlinear.get(0).getId()]);
drawables = new BitmapDrawable[2];
drawables[0] = new BitmapDrawable(contexto.getResources(), bm1);
drawables[1] = new BitmapDrawable(contexto.getResources(), bm2);
trans = new TransitionDrawable(drawables);
trans2 = new TransitionDrawable(drawables2);
handler.post(new runa());
}
}, 4000);
fuera del hilo ponemos la transicion en un imageview (im1)
final Handler handler = new Handler();
class runa implements Runnable{
@Override
public void run() {
im1.setImageDrawable(trans);
trans.startTransition(2000);
}
}
Pues bien, las primeras pulsaciones sobre el imageView no pasa nada, pero sobre la sexta pulsacion se me arroja el siguiente error:
Se ve que esta relacionado con la linea BitmapFactory.decodeResource() pero por mas que modifico no consigo dar con ello.
Alguna idea de por donde van los tiros?
07-22 22:36:51.085: E/dalvikvm-heap(26085): Out of memory on a 2183696-byte allocation.
07-22 22:36:51.085: I/dalvikvm(26085): "Timer-5" prio=5 tid=16 RUNNABLE
07-22 22:36:51.085: I/dalvikvm(26085): | group="main" sCount=0 dsCount=0 obj=0x4254be18 self=0x5d112a70
07-22 22:36:51.085: I/dalvikvm(26085): | sysTid=28587 nice=0 sched=0/0 cgrp=apps handle=1515006088
07-22 22:36:51.085: I/dalvikvm(26085): | schedstat=( 51788168 1015247 20 ) utm=5 stm=0 core=3
07-22 22:36:51.085: I/dalvikvm(26085): at android.graphics.BitmapFactory.nativeDecodeAsset(N ative Method)
07-22 22:36:51.090: I/dalvikvm(26085): at android.graphics.BitmapFactory.decodeStream(Bitmap Factory.java:623)
07-22 22:36:51.090: I/dalvikvm(26085): at android.graphics.BitmapFactory.decodeResourceStrea m(BitmapFactory.java:476)
07-22 22:36:51.090: I/dalvikvm(26085): at android.graphics.BitmapFactory.decodeResource(Bitm apFactory.java:499)
07-22 22:36:51.090: I/dalvikvm(26085): at android.graphics.BitmapFactory.decodeResource(Bitm apFactory.java:529)
07-22 22:36:51.095: I/dalvikvm(26085): at com.example.ejercicios3.Prueba3GridLayout_JuegoMem orion$linearListener$3.run(Prueba3GridLayout_Juego Memorion.java:187)
07-22 22:36:51.100: I/dalvikvm(26085): at java.util.Timer$TimerImpl.run(Timer.java:284)
07-22 22:36:51.105: A/libc(26085): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 28587 (Timer-5)