I want to display a couple of images and add a delay between each image. I did this and have no errors in the code but for some reason the app crashes.
Bitmap bitmap = BitmapFactory.decodeFile(imageIn);
ImageView myImageView = (ImageView)findViewById(R.id.imageview);
myImageView.setImageBitmap(bitmap);
// Those are the only 2 lines I used to make my handler
Handler handlerTimer = new Handler();
handlerTimer.postDelayed((Runnable) this, 20000);
You don't say what class hosts the snippet you posted, but I think handlerTimer.postDelayed((Runnable) this, 20000);
is unlikely to be right.
Try adding an anonymous Runnable
object such as
handlerTimer.postDelayed(new Runnable(){
public void run() {
// do something
}}, 20000);
Another thing, logcat
output is invaluable for getting clues about what is causing a crash. http://developer.android.com/guide/developing/tools/logcat.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With