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.

inside custom component

Java Development

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

Getting Error In Taking Picture

 

Hi

          I am doing example of taking picture but i am getting error Smiley Sad

 

  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 ..
Highlighted
BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
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.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker