From anddev
Import android. app. activity; import android. content. context; import android. graphics. canvas; import android. graphics. color; import android. graphics. paint; import android. hardware. camera; import android. OS. bundle; import android. view. surfaceholder; import android. view. surfaceview; import android. view. view; import android. view. window; import android. view. viewgroup. layoutparams; public class testcameraoverlay extends activity {/** called when the activity is first created. * // @ override public void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); requestwindowfeature (window. feature_no_title); preview mpreview = new Preview (this); drawontop mdraw = new drawontop (this); setcontentview (mpreview); addcontentview (mdraw, new layoutparams (layoutparams. wrap_content, layoutparams. wrap_content) ;}} class drawontop extends view {public drawontop (context) {super (context ); // todo auto-generated constructor stub} @ override protected void ondraw (canvas) {// todo auto-generated method stub paint = new paint (); paint. setstyle (paint. style. fill); paint. setcolor (color. black); canvas. drawtext ("test text", 10, 10, paint); super. ondraw (canvas) ;}} class preview extends surfaceview implements surfaceholder. callback {surfaceholder mholder; camera mcamera; Preview (context) {super (context); // install a surfaceholder. callback so we get notified when the // underlying surface is created and destroyed. mholder = getholder (); mholder. addcallback (this); mholder. settype (surfaceholder. surface_type_push_buffers);} public void surfacecreated (surfaceholder holder) {// The surface has been created, acquire the camera and tell it where // to draw. mcamera = camera. open (); mcamera. setpreviewdisplay (holder);} public void surfacedestroyed (surfaceholder holder) {// surface will be destroyed when we return, so stop the preview. // because the cameradevice object is not a shared resource, it's very // important to release it when the activity is paused. mcamera. stoppreview (); mcamera = NULL;} public void surfacechanged (surfaceholder holder, int format, int W, int h) {// now that the size is known, set up the camera parameters and begin // the preview. camera. parameters = mcamera. getparameters (); parameters. setpreviewsize (W, H); mcamera. setparameters (parameters); mcamera. startpreview () ;}} parsed in 0.113 seconds, using geshi 1.0.8.4