Make CameraPreview.java more robust

The code wasn’t smart enough about starting and stopping the preview at
all the right times; this is OK on some devices but makes others very
unhappy.