×

Discussion Board

Results 1 to 13 of 13
  1. #1
    Nokia Developer Champion
    Join Date
    Sep 2007
    Posts
    915

    Illigal State Exception whiile Capturing image

    Hello,

    My application capture image from N 97. But when it goes second time to capture it is saying Illigal State Exception.

  2. #2
    Super Contributor
    Join Date
    May 2008
    Location
    Helsinki, Finland
    Posts
    1,100

    Re: Illigal State Exception whiile Capturing image

    Hello there, honest_success

    Could you maybe consider posting the part of code that you are capturing the image,
    or better, send it to me so that I could test it? My e-mail is in the signature. N97 you have
    with the latest firmware? Memory issues?...set reference to null?

    A couple of references to do some quick checks for your code maybe, your implementation uses..?

    http://wiki.forum.nokia.com/index.ph...idge_Interface
    http://www.forum.nokia.com/info/sw.n..._0_en.pdf.html

    Best Regards,
    [FONT="Comic Sans MS"][COLOR="Blue"][/COLOR][I]Marko Lumivuori
    Technical Support
    +358 40 8019330
    [email]marko.lumivuori@nokia.com[/email][/I][/FONT]

  3. #3
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Illigal State Exception whiile Capturing image

    Quote Originally Posted by honest_success View Post
    it is saying Illigal State Exception.
    You probably need to call initDisplayMode() again.

    Graham.

  4. #4
    Nokia Developer Champion
    Join Date
    Sep 2007
    Posts
    915

    Re: Illigal State Exception whiile Capturing image

    Quote Originally Posted by grahamhughes View Post
    You probably need to call initDisplayMode() again.

    Graham.
    Hello Graham

    Thanks for your reply. Actually it is throwing exception when application try to capture snap shot. Some hwo first time it is working fine.

  5. #5
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Illigal State Exception whiile Capturing image

    Quote Originally Posted by honest_success View Post
    Hello Graham

    Thanks for your reply. Actually it is throwing exception when application try to capture snap shot. Some hwo first time it is working fine.
    After taking the snap first time are you closing/stooping/deallocating the player anywhere in the code?
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  6. #6
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Illigal State Exception whiile Capturing image

    Yes, I understand. You're calling getSnapshot() twice. Are you calling initDisplayMode() twice?

  7. #7
    Nokia Developer Champion
    Join Date
    Sep 2007
    Posts
    915

    Re: Illigal State Exception whiile Capturing image

    Quote Originally Posted by raj_J2ME View Post
    After taking the snap first time are you closing/stooping/deallocating the player anywhere in the code?
    Hello Raj.

    I am calling mPlayer.close() once capturing successful first time.

  8. #8
    Nokia Developer Champion
    Join Date
    Sep 2007
    Posts
    915

    Re: Illigal State Exception whiile Capturing image

    Quote Originally Posted by grahamhughes View Post
    Yes, I understand. You're calling getSnapshot() twice. Are you calling initDisplayMode() twice?
    Hello Grahamhughes thanks for your quick reply actually i am not caling getSnapshot twice in sequence. I start capturing frist time and once getSnapshot called automaticallly then it come to home scrren then again after few seconds it starts capturing but when it tries to take snapshot it is giving exception. I am not calling initDisplayMode() no where. Where i need to put it. I tried to put in my canvas class but it gave me error. The following is code of canvas.

    public CameraCanvas(ImageUploader midlet, VideoControl videoControl) {
    int width = getWidth();
    int height = getHeight();
    mSnapperMIDlet = midlet;

    videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this);
    try {
    videoControl.setDisplayLocation(2, 2);
    videoControl.setDisplaySize(width - 4, height - 4);
    }
    catch (MediaException me) {
    try { videoControl.setDisplayFullScreen(true); }
    catch (MediaException me2) {}
    }
    videoControl.setVisible(true);
    }


    hope to hear soon from you.

  9. #9
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Illigal State Exception whiile Capturing image

    I guess you can easily trace that where exactly and which method call is leading you as the exception,try to debug the code and find the exact location/line of concern
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  10. #10
    Nokia Developer Champion
    Join Date
    Sep 2007
    Posts
    915

    Re: Illigal State Exception whiile Capturing image

    Quote Originally Posted by raj_J2ME View Post
    I guess you can easily trace that where exactly and which method call is leading you as the exception,try to debug the code and find the exact location/line of concern
    I found the problem. when i am creating object of VideoControl. First time it is creating object but when i come to it it has null value. can any one say why it is not creating object and return null ?

    mPlayer = Manager.createPlayer("capture://video");
    mPlayer.realize();

    mVideoControl = (VideoControl) mPlayer.getControl("VideoControl");

  11. #11
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Illigal State Exception whiile Capturing image

    Hey champion,
    Did you check that the mPlayer is not null?
    I think that you have not deallocate/null the player, and you are creating the same again, and hence the video control is finding the player in the other start than the UNREALIZED.You can check that by printing that in which state the player is.Manage the player state and I am sure this issue can be fixed.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  12. #12
    Nokia Developer Champion
    Join Date
    Sep 2007
    Posts
    915

    Re: Illigal State Exception whiile Capturing image

    Quote Originally Posted by raj_J2ME View Post
    Hey champion,
    Did you check that the mPlayer is not null?
    I think that you have not deallocate/null the player, and you are creating the same again, and hence the video control is finding the player in the other start than the UNREALIZED.You can check that by printing that in which state the player is.Manage the player state and I am sure this issue can be fixed.
    Hello raj

    Thanks for your reply as you can see in code before creating object of VideoControl object i am calling mPlayer.realize(); and it is not giving any Exception so it proves that mPlayer(Player Object is not null). So at the time of creating object of VideoControl the player should be REALIZED as i called that method just before it. are you sure that the palyer should be UNREEALIZED at the time of creating obejct of VideoControl. If i do not put mPlayer.reqlize() then it is giving exception that player is not realised first time only.

    Let me know if you want to know any other thing. HOpe i can solve my issue soon.

  13. #13
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Illigal State Exception whiile Capturing image

    Quote Originally Posted by honest_success View Post
    Hello raj

    Thanks for your reply as you can see in code before creating object of VideoControl object i am calling mPlayer.realize(); and it is not giving any Exception so it proves that mPlayer(Player Object is not null). So at the time of creating object of VideoControl the player should be REALIZED as i called that method just before it.
    Thats correct indeed.


    Quote Originally Posted by honest_success View Post
    If i do not put mPlayer.reqlize() then it is giving exception that player is not realised first time only.
    Let me know if you want to know any other thing. Hope i can solve my issue soon.
    That's also correct..this will throw the exception.Since this code is throwing.
    On which are you testing the same?
    Or are you testing the same on the emulator?
    Please make sure that you should test the same on the device..
    Why dont you follow This example,

    As you know that the IlligalArgumentException is thrown by the call from method
    videoControl = (VideoControl)player.getControl("VideoControl");
    Throws:
    java.lang.IllegalArgumentException - Thrown if controlType is null.
    java.lang.IllegalStateException - Thrown if getControl is called in a wrong state.
    Last edited by raj_J2ME; 2010-05-31 at 14:10.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

Similar Threads

  1. Opening a JPEG Image
    By ummarbhutta in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2007-02-15, 06:34
  2. Capturing the image from Nokia S40 3rd handsets.
    By salopge in forum Mobile Java Media (Graphics & Sounds)
    Replies: 22
    Last Post: 2006-04-12, 22:56
  3. Replies: 2
    Last Post: 2006-03-08, 11:36
  4. illegal state exception
    By lmtang in forum Mobile Java General
    Replies: 5
    Last Post: 2005-05-26, 02:35

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •