Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Contributor
Sajid_Halai
Posts: 6
Registered: ‎06-13-2012
My Carrier: NO

Getting Error In Taking Picture

 

Hi

          I am doing example of taking picture but i am getting error :smileysad:

 

  code is  here

 

 

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.amms.control.camera.*;
import javax.microedition.media.*;
import javax.microedition.media.control.*;

public class ImageCaptureDemo extends UiApplication
{
    public static void main(String[] args)
    {
        ImageCaptureDemo app = new ImageCaptureDemo();
        app.enterEventDispatcher();
    }
    
    public ImageCaptureDemo()
    {
        pushScreen(new ImageCaptureDemoScreen());
    }   

    class ImageCaptureDemoScreen extends MainScreen
    {	
        Player _p;
        VideoControl _videoControl;    
 
        public ImageCaptureDemoScreen()
        {
            try 
            {
                _p = javax.microedition.media.Manager.createPlayer("capture://video?encoding=jpeg&width=1024&height=768");
                _p.realize();
                _videoControl = (VideoControl) _p.getControl("VideoControl");

                if (videoControl != null)
                {
                    Field videoField = (Field) _videoControl.initDisplayMode (VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
                    _videoControl.setDisplayFullScreen(true);
                    _videoControl.setVisible(true);
                    _p.start();

                    EnhancedFocusControl efc = (EnhancedFocusControl)p.getControl("net.rim.device.api.amms.control.camera.EnhancedFocusControl");
                    efc.startAutoFocus();

                    if(videoField != null)
                    {
                        add(videoField);
                    }
                } 
            }
            catch(Exception e)
            {
                Dialog.alert(e.toString());
            }
        }

        protected boolean invokeAction(int action)
        {
            boolean handled = super.invokeAction(action); 
        
            if(!handled)
            {
                if(action == ACTION_INVOKE)
                {   
                    try
                    {                      
                        byte[] rawImage = _videoControl.getSnapshot(null);        
                    }
                    catch(Exception e);
                    {
                        Dialog.alert(e.toString());
                    }
                }
            }           
            return handled;                
        }  
    }   
}
i am getting 104 runtime exception.please help ..
Please use plain text.
Administrator
MSohm
Posts: 12,957
Registered: ‎07-09-2008
My Carrier: Bell

Re: Getting Error In Taking Picture

[ Edited ]

What exception is being thrown?  What line of code is triggering it?  Which BlackBerry Smartphone model and BlackBerry handheld software version are you testing on?  You can find this under Options, About on the BlackBerry Smartphone. 

 

Are you testing in the simulator or on a real device?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Found a bug? Report it using the Issue Tracker
Please use plain text.