Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8829473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:50:26+00:00 2026-06-14T07:50:26+00:00

I have run into a few problems when trying to get the camera to

  • 0

I have run into a few problems when trying to get the camera to work accordingly… The camera Demo Works on the 8520 device (Has a memory Card) but does not work on the 9780 device (Has No Memory Card) the error given

ERROR Class java.lang.ArrayOutOfBoundsException :index 0>=0

My code Sample:

public class MyScreen extends MainScreen{

    Player _p;
    VideoControl _videoControl;
    FileConnection fileconn;
    String PATH;
    String GetfileName;
    LabelField GetPhotofileName = new LabelField("",LabelField.FOCUSABLE){
        protected boolean navigationClick(int status, int time){
            Dialog.alert("Clicked");
            return true;
        }
    };

    public static boolean SdcardAvailabulity() {
        String root = null;
        Enumeration e = FileSystemRegistry.listRoots();
        while (e.hasMoreElements()) {
            root = (String) e.nextElement();
            if( root.equalsIgnoreCase("sdcard/") ) {
            }else if( root.equalsIgnoreCase("store/") ) {
            }
        }

        class MySDListener implements FileSystemListener {
            public void rootChanged(int state, String rootName) {
                if( state == ROOT_ADDED ) {
                    if( rootName.equalsIgnoreCase("sdcard/") ) {
                    }
                } else if( state == ROOT_REMOVED ) {
                }
            }
        }

        return true;
    }

    protected boolean invokeAction(int action){
        boolean handled = super.invokeAction(action);
        if(SdcardAvailabulity()){
            PATH = System.getProperty("fileconn.dir.memorycard.photos")+"Image_"+System.currentTimeMillis()+".jpg";//here "str" having the current Date and Time;
        } else {
            // PATH = System.getProperty("file:///store/home/user/pictures/")+"Image_"+System.currentTimeMillis()+".jpg";
            PATH = System.getProperty("fileconn.dir.photos")+"Image_"+System.currentTimeMillis()+".jpg";
        }

        if(!handled){
            if(action == ACTION_INVOKE){
                try{
                    byte[] rawImage = _videoControl.getSnapshot(null);
                    System.out.println("----------1");
                    fileconn=(FileConnection)Connector.open(PATH);
                    System.out.println("----------2");
                    if(fileconn.exists()){
                        fileconn.delete();
                        System.out.println("----------3");
                    }
                    fileconn.create();
                    System.out.println("----------4");
                    OutputStream os=fileconn.openOutputStream();
                    System.out.println("----------5");
                    os.write(rawImage);
                    GetfileName =fileconn.getName();
                    System.out.println("----------6");
                    System.out.println("GetfileName----------"+GetfileName);
                    fileconn.close();
                    System.out.println("----------7");
                    os.close();
                    Status.show("Image is Captured",200);
                    GetPhotofileName.setText(GetfileName);
                    System.out.println("----------8");
                    if(_p!=null)
                        _p.close();
                    System.out.println("----------9");
                }catch(Exception e){
                    if(_p!=null){
                        _p.close();
                    }
                    if(fileconn!=null){
                        try{
                            fileconn.close();
                        }catch (IOException e1){
                            //if the action is other than click the trackwheel(means go to the menu options) then we do nothing;
                        }
                    }
                }
            }
        }
        return handled;
    }

    public MyScreen(){
        setTitle("Camera App");
        try{
            System.out.println("Debug------------10");
            _p = javax.microedition.media.Manager.createPlayer("capture://video?encoding=jpeg&width=1024&height=768");
            _p.realize();
            _videoControl = (VideoControl) _p.getControl("VideoControl");
            System.out.println("Debug------------11");
            if (_videoControl != null){
                Field videoField = (Field) _videoControl.initDisplayMode (VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
                _videoControl.setDisplayFullScreen(true);
                System.out.println("Debug------------12");
                _videoControl.setVisible(true);
                _p.start();
                System.out.println("Debug------------13");
                if(videoField != null){
                    add(videoField);
                    System.out.println("Debug------------14");
                }
            }
        }catch(Exception e){
            if(_p!=null) {
                _p.close();
            }
            Dialog.alert(e.toString());
        }
        add(GetPhotofileName);
    }
}  

on the 8520 (Has a Memory Card) the code works fine on the 9780 (Has no Memory Card) the the code stops at “System.out.println(“debug—1″)”, can anyone please tell me if you can see any problem with my code???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:50:27+00:00Added an answer on June 14, 2026 at 7:50 am
      public static boolean SdcardAvailabulity() {
         String root = null;
         Enumeration e = FileSystemRegistry.listRoots();
         while (e.hasMoreElements()) {
             root = (String) e.nextElement();
             if( root.equalsIgnoreCase("sdcard/") ) {
                 return true;
             }else if( root.equalsIgnoreCase("store/") ) {
                 return false;
             }
         }
         class MySDListener implements FileSystemListener {
             public void rootChanged(int state, String rootName) {
                 if( state == ROOT_ADDED ) {
                     if( rootName.equalsIgnoreCase("sdcard/") ) {
                     }
                 } else if( state == ROOT_REMOVED ) {
                 }
             }
         }
         return true;
    }
    

    This is the sollution, My “SD card availability” code only returned true which caused the picture not to save when the blackberry had no memory card inserted. @ Eugen Martynov Please read through the code and you will see it is there 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build my first program and I've run into a few problems
I have run into this problem a few times and I'm not happy with
I have run into a problem trying to modify a form I myself have
I have run into a problem... I'm trying to use QTKit in an application
I have run into this problem a few times before so this time around
I've run into a few problems using a C# regex to implement a whitelist
I have run into a problem with Eclipse Indigo, attempting to start up my
I have run into a little problem. I am connecting to a webservice that
I have run into a couple of similar quirks regarding uint usage in both
I have run into a situation where I want to ensure that a compound

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.