Discussion Board

Results 1 to 3 of 3
  1. #1
    Hello everyone,

    First post on here I do believe! I'm not new to java but I am new to the S40 API. I noted the method 'startVibra(frequency, duration)' which can be called from the 'DeviceControl' class. I have written a very simple MIDlet to test the method, which allows me to enter a number into a text field and click a "Vibrate" button. The number represents the 'frequency' parameter of the 'startVibra()' method, while the duration is hard coded to a value of 2000 (2 seconds). There seems to be no difference in vibration frequency no matter what the value is; a value of 1 or 100 vibrates the phone in the same way.

    Is this a restriction on the device itself or is there something i can add to the MIDlet to enable this type of behaviour? If it is a device restriction, could anyone tell me which devices support the frequency parameter?

    Many thanks,
    P.M

  2. #2
    Nokia Developer Champion im2amit's Avatar
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    2,903
    For 6500 Slider - This API is deprecated. For all MIDP 2.0 or higher devices it is replaced by javax.microedition.lcdui.Display.vibrate(int). Where is int = duration, so you might not have the support for different frequencies.

    'DeviceControl.startVibra
    public static void startVibra(int freq,long duration)

    Deprecated. As of Nokia UI API 1.1 in devices with MIDP 2.0 or higher, replaced by javax.microedition.lcdui.Display.vibrate(int).
    Activates vibration for a given length of time and frequency. If no exception is thrown this method will return immediately and thus will not block the calling thread during the vibration. Vibration feedback can be used, for example, as a tactile feedback effect in games. The frequency of the vibration can be controlled with the freq parameter. The frequency is a logical number between 0 and 100, 100 being the maximum frequency. No vibra is always 0, 1 should always have some effect. If a device does not support different frequencies, the fixed frequency that is allowed the by device is used.
    The parameter duration is used to indicate the length of time of the vibration in milliseconds. The method will not block for vibration. There is a maximum limit in the implementation for the length of time. Duration values that exceed this limit result in a maximum vibration effect.

    If the method is called during a previously called vibration that has been activated from this method, the previous vibration is stopped and the new one is activated using the new set of parameters.

    IllegalStateException will be thrown if freq is not 0 and if the device does not allow vibration; for example, it is common that vibration is not allowed when the device is being recharged in a desk stand or there is an incoming call. IllegalStateException will be thrown if there is no vibration capability in the device.

    Note that if the frequency is 0, and the device does not have vibration, IllegalStateException is thrown. This means that the method call DeviceControl.startVibra(0,0) can be used to detect whether vibration is supported (IllegalStateException not thrown) or not (IllegalStateException thrown) without any vibration occuring even if it is supported.


    Parameters:
    freq - the frequency of the vibra device. Value 0 can be used for detecting whether or not there is a vibration device. 100 means the maximum frequency value of a specific system. 1 must always result in a minimum non-zero vibration.
    duration - the length of time in milliseconds the vibration is active.
    Throws:
    java.lang.IllegalStateException - For freq values 1-100: the use of vibration is not allowed or the system does not have vibration support. For frequency value 0: the device does not have vibration.
    java.lang.IllegalArgumentException - if duration or freq is < 0, or freq is > 100.
    Since:
    1.0
    thanks,
    ~Amitabh
    (Poster of the Month -Dec'12)
    Follow me on my blog for Innovative Mobile Apps

  3. #3
    im2amit: Thank you for the good quality reply. It seems I have to find another device that supports the frequency setting of the method. Do you know where I can find out which devices support it?

    Many thanks,
    P.M

Similar Threads

  1. Suggestion for and Bugs of S40/6500 slide
    By kennithng in forum General Development Questions
    Replies: 2
    Last Post: 2008-10-20, 17:36
  2. Installing .sis file on 6500 slide (S40 5th)
    By absarc in forum Mobile Java General
    Replies: 3
    Last Post: 2008-09-28, 22:23
  3. Nokia 6500 slide???
    By katielward26 in forum General Development Questions
    Replies: 2
    Last Post: 2008-09-22, 11:57
  4. Nokia 6500 Slide
    By speedy911 in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2008-03-25, 15:30
  5. 6310i and DeviceControl.startVibra(fr equency, duration);
    By Nokia_Archive in forum Mobile Java General
    Replies: 0
    Last Post: 2002-05-27, 16:14

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved