×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    63

    How to use Display.vibrate() - static content?

    Hello,
    I was just trying to use vibration in my J2ME app. But it doesn't want to work. This is the code I wrote, I think it's correct, but it doesn't want to:
    Code:
    public void checkPress (int px, int py) {
            if (((xneu < px) && (px < (xneu+wneu))) && ((yneu < py) && (py < (yneu+hneu)))) {
                pressed = true;
                Display.vibrate(10);
            }
        }
    The void is called when pointerPressed is called. The SDK shows me "not-static method vibrate(int) cannot be referenced from a static content".
    I also searched with google and here in the forum but didn't found any solution.
    Please help

  2. #2
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: How to use Display.vibrate() - static content?

    From MIDP spec
    "There is exactly one instance of Display per MIDlet and the application can get a reference to that instance by calling the getDisplay() method. The application may call the getDisplay() method at any time during course of its execution. The Display object returned by all calls to getDisplay() will remain the same during this time."

    You you first have to get the Display reference with getDisplay and call the vibrate using that object.

    Hartti

  3. #3
    Nokia Developer Expert
    Join Date
    Aug 2007
    Posts
    1,595

    Re: How to use Display.vibrate() - static content?

    Hello schumi1331,

    hartti is referring to the correct usage as described on this example: http://www.developer.nokia.com/Commu...ngs_in_Java_ME

    Display.getDisplay(this).vibrate(1000);

    Also, could you provide more information on which device(s) or SDK emulator(s) you are using for testing?

    Regards,
    r2j7
    [URL="http://library.forum.nokia.com/java"][B] >>> Java Developer's Library <<<[/B][/URL]
    [URL="https://www.developer.nokia.com/Resources/Support/Technical_support.xhtml"] [B]>>> Technical Support for Java ME development <<<[/B][/URL]
    [URL="https://publish.ovi.com/info/"][B]>>> Nokia Publish: reach millions of Nokia users worldwide through Nokia Store <<<[/B][/URL]

  4. #4
    Registered User
    Join Date
    Nov 2009
    Posts
    63

    Re: How to use Display.vibrate() - static content?

    thanks for reply, I will try it

    I'm using J2ME SDK 3.0 for Mac and my 701 for testing... but it should work also on older Nokias...

Similar Threads

  1. Replies: 1
    Last Post: 2009-06-19, 09:15
  2. why doesn't Display.getDisplay(this).vibrate(milis) work on E65?
    By ronikoren in forum Mobile Java General
    Replies: 3
    Last Post: 2008-08-19, 10:36
  3. Alternative to display.vibrate() in J2ME?
    By vics69 in forum Mobile Java General
    Replies: 2
    Last Post: 2006-03-05, 09:07
  4. How to display HTML content?
    By molim in forum Symbian User Interface
    Replies: 4
    Last Post: 2005-09-27, 08:48

Posting Permissions

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