I have subclassed the SurfaceView and instantiating it in onCreate of the Activity. The preview is generated but the control never enters onDraw() which is overriden in the subclass of SurfaceView. Why is that?
class ActivityClass extends Activity{
onCreate(){
mPreview = new Preview(this);
setContentView(mPreview);
}
public void startPreview(){
rec = new MediaRecorder();
rec.setVideoSource();.......
rec.setPreviewDisplay(mPreview.getSurfaceHolder.getSurface());
}
}
class Preview extends SurfaceView implements SurfaceHolder.Callback{
SurfaceHolder mHolder;
public Preview(Context context){
super(context);
mHolder = getHolder();
mHolder.addCallback(this);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
bringToFront();//this is not
invalidate();//making a difference
}
SurfaceHolder getSurfaceHolder(){
return mHolder; }
//Surface callback methods implemented here
}
Before drawing the preview on the Surface, shouldn't the control be given to the onDraw callback if it is implemented?
Because onDraw callback says to the Android framework 'you don't draw the view. I will draw it since I have been implemented'. Am I right?
Why then, is the control failing to enter onDraw()? Please help.