iPhone 3G camera doesn't work
Based on a research I did on the Internet it seems that the reason for this malfunction could be the sensor (whatever that means). With new phones this usually means warranty replacement. My phone is a bit too old for that unfortunately, but... I accidentally found a workaround!

Covering completely the camera lens with a finger when opening the Camera app seems to solve the problem! Covering the lens when the Camera app is already opened doesn't cause shutter to open though so the lens has to be covered prior to Camera app launch.