Saturday 15 January 2011

android - Background Service to take picture with Camera -


I know there are so many questions about it, but I think that whatever problem I am facing None of them is addressed in either. The problem I have written this service with all the different questions is that I am getting "success" in all attempt-grab blocks in the Austrade Common Command, but the logs are not being processed in the callback message (shuttercollback and picturecolback). What I think is that it means that the photograph has been taken but the callback has not been called, which is strange.

  camera camera; Parameter param; Chitraklak Rawcrollback = New ImageCollection () {Public Zero (Byte [] Data, Camera Camera on Chitrutoot) {Log D. ("Camera", "painting on-raw - raw"); }}; Shutterclub shuttercollback = new shuttercallback () {public zero} on shutter (log.i ("camera", "ontitterred");}}; @Ivoride public IBir on reboot (intent arg0) {// to-auto object method stub returns Null;} @Override public int onStartCommand (intended intent, int-flags, int startId) {try {cam = Camera.open ()} log. I ("camera", "success");} hold (runtime exception e } {Log. ("Camera", "camera is currently unavailable"); e.printStackTrace ();} try {param = cam.getParameters (); cam.setParameters (ultimate); log.I ("camera", " Support ) "}; {Hold (exception E1) {Log.e (" camera "," parameter problem "); e1.printStackTrace ();} {try SurfaceView view = new SurfaceView (this); cam.setPreviewDisplay ( See.getHolder (); cam.startPreview (); log.I ("camera", "success");} catch (exception e) {Log.e ("camera", "surface problem"); e.printStackTrace (); Try {cam.takePicture (shuttercollback, rawcollback, blank); log.i ("camera", "success");} hold (exception e) {Log.e ("camera", "click failure" ); E.printStackTrace ();} Cam.release (); Return Super. Onboard Commands (Intent, Flags, Beginners); }    

You should not release the camera immediately after moving. The graphic method executes callback to you To give the camera enough time to do it BTW, you also want to add JPG callback Apart from this, the stop preview can be said before the camera is released. Your code will look below:

  Camera camera; Parameter param; Chitraklak Rawcrollback = New ImageCollection () {Public Zero (Byte [] Data, Camera Camera on Chitrutoot) {Log D. ("Camera", "painting on-raw - raw"); Camera.stopPreview (); Camera.release (); }}; PictureColubbackJPGCallack = New ImageCollection () {Public Zero (Byte [] Data, Camera Camera on Chitrutut) {Log D. ("Camera", "Painting on - JPG"); Camera.stopPreview (); Camera.release (); }}; Shutterclub shuttercollback = new shuttercallback () {public zero} on shutter (log.i ("camera", "ontitterred");}}; @Ivoride public IBir on reboot (intent arg0) {// to-auto object method stub returns Null;} @Override Public int onStartCommand (intended intent, int-flags, int startId) {try {cam = Camera.open ()} log. I ("camera", "success");} hold (RuntimeException e) {Log.e ("Camera", "Camera is currently unavailable"); e.printStackTrace ();} Try {param = cam.getParameters (); cam.setParameters (ultimate); log.I ("camera", " Success ");} hold (upper E1) {Log.e ("camera", "parameter problem"); e1.printStackTrace ();} {try SurfaceView view = new SurfaceView (this); cam.setPreviewDisplay (view.getHolder ()); cam .startPreview (); log.i ("camera", "success");} hold (exception e) {Log.e ("camera", "surface problem"); e.printStackTrace ();} try {cam. TakePicture (shuttercollback, rawcolbback, blank); log ("camera", "success");} catch (exception e) {Log.e ("camera", "click failure"); e.printStackTrace (); } // commented on the following line and it was brought to your callback // camera .release (); Return Super.Onstart Commands (Intent, Flags, Beginners); }    

No comments:

Post a Comment