As MrChaz wrote, you'll definitively need the Camera permission and
for checking if you are still getting exceptions, try this:
Camera cam = null;
try{
cam = Camera.open();
}catch(Exception ex){
Log.e("Camera.open()",""+ex);
}
if(cam==null){
return;
}
//it is very important that the camera be released by the app that
opens it.
try{//try-finally block to ensure that the camera is released
try{
cam.startPreview();
}catch(Exception ex){
Log.e("Camera.startPreview()",""+ex);
return;
}
//other work here
}finally{
try{
cam.release();
}catch(Exception ex){
Log.e("Camera. release()",""+ex);
}
}
serge
On Jun 13, 9:51 am, MrChaz <[email protected]> wrote:
> Have you added the Camera permission to the manifest?
>
> On Jun 12, 11:32 am, Urizev <[email protected]> wrote:
>
>
>
> > I am developing an application which uses the camera of my G2. The
> > code using the camera is showed below:
>
> > Camera cam = Camera.open();
> > if (cam == null) {
> > return;
> > }
>
> > cam.startPreview();
>
> > It throws and XXXX Exception and I do not know why. Someone has any
> > idea?
>
> > com.sun.jdi.InvocationException occurred invoking
>
> > Regards
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---