How to get that working:
if(findViewById(ResIdWithUnkownType) instanceof Bitmap)
{
Bitmap bitmap = (Bitmap) findViewById(ResIdWithUnkownType);
} else if(findViewById(ResIdWithUnkownType) instanceof ImageView)
{
ImageView = (ImageView) findViewById(ResIdWithUnkownType);
}
The second block would work just fine. The problem is the first one:
findViewByIdreturns aViewobject always, andBitmapis not aView, so the firstifstatement will never be executed.