How to display Bitmap Image in Android

You should use runOnUiThread() to update views from other threads.


When you are doing some view related job always do it from GUI thread ie. the thread that created the view hierarchy .

So use Handlers to achieve this.


ImageView tv1;
tv1= (ImageView) findViewById(R.id.image);
InputStream si1 = asset.open("image/" + cat_arr1[i] + ".png");
Bitmap bitmap1 = BitmapFactory.decodeStream(si1);
tv1.setImageBitmap(bitmap1);

The exception CallFromWrongThreadException means that you tried to update the UI from a thread that is not the UI thread and which is not allowed.

So your issue is not that your code to create the image is wrong, but that you are doing it at the wrong place. If you e.g. are fetching the image in background in an AsyncTask, you need to setImageBitMap() in postExecute() and not in doInBackground().

Without seeing more code, we can't help you more.