0

Sorry about the confusing question title, wasn't sure how better to phrase it...

The problem is that I have a bunch of downloaded image thumbnails on the screen. If any one of them is clicked, a new activity should be launched that features (amongst other things) a larger version of the image.

It works fine for some of the images, but I realised by happenstance that for more than half of the images it just does nothing. The code is executed (I get log messages) but nothing happens.

ImageView imageView = new ImageView(this);
imageView.setImageBitmap(locationBitmap.bitmap);
imageView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View image) {
        Log.i(this.getClass().getName(), "You selected location: " + locationBitmap.location);
        Intent i = new Intent(context, AnswerActivity.class);
        i.putExtra("question_text", question_text);
        i.putExtra("question_title", question_title);
        i.putExtra("location", locationBitmap.location);
        i.putExtra("bitmap", locationBitmap.bitmap);
        Log.d(this.getClass().getName(), "About to start the activity...");
        context.startActivity(i);
        Log.d(this.getClass().getName(), "Started the activity...");
    }
});

All of the log messages are produced correctly, but sometimes the activity doesn't change and sometimes it does. Any ideas?

Szymon
  • 42,577
  • 16
  • 96
  • 114
Alex
  • 18,332
  • 10
  • 49
  • 53

2 Answers2

2

The answer seems to be that the bundle has a size limitation - some of the file's are exceeding it and some aren't.

Passing through the name of a file, rather than the bitmap itself, works.

Related question: Maximum length of Intent putExtra method? (Force close)

Community
  • 1
  • 1
Alex
  • 18,332
  • 10
  • 49
  • 53
0

I think problem with getting image null.

check locationBitmap.bitmap is null or not put one condition if null then set default image else set imageView.setImageBitmap(locationBitmap.bitmap);

This type issue generate many user.

Harshid
  • 5,701
  • 4
  • 37
  • 50