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
Contributor
coolfish
Posts: 26
Registered: ‎07-25-2012
My Device: 9800

generate sound or vibrate or alert when application get update notification.

 

Hey guys,

                i  have done  the state flag to indicate that there is something new for the application. but what if i want generate the sound or vibrate the device or show alert message. is there any api for that ?? please suggest me regarding this.


        

Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: generate sound or vibrate or alert when application get update notification.

You should set up a profile for your application and fire it using NotificationsManager.

 

New Developer
saurabh0208
Posts: 10
Registered: ‎08-24-2012
My Device: 9820

Re: generate sound or vibrate or alert when application get update notification.

You can use Alert.startVibrate(duration) to vibrate your device. 

Developer
madiha
Posts: 107
Registered: ‎05-26-2011
My Device: Torch

Re: generate sound or vibrate or alert when application get update notification.

   use this code snippet ..

private Player m_player;
private VolumeControl m_volumeControl;  

//Blink LED

  if (LED.isPolychromatic(LED.LED_TYPE_STATUS)) {
           LED.setColorConfiguration(500, 500, 0x0000FF00);
   } else
           LED.setConfiguration(500, 500, LED.BRIGHTNESS_50);
 LED.setState(LED.STATE_BLINKING);

//Vibrate specifying vibrate duration in millisecods

    Alert.startVibrate(1000);

 

// play a sound placed in your project's resource folder

    public void playMP3() {
            if (m_player != null) {
                stopMP3();
            }
            try {
                InputStream stream;
                    stream = (InputStream) this.getClass().getResourceAsStream("/play.mp3");

                m_player = Manager.createPlayer(stream, "audio/mpeg");
                m_player.realize();
                m_volumeControl = (VolumeControl) m_player.getControl("VolumeControl");
                m_volumeControl.setMute(false);

                if (m_volumeControl != null)
                    m_volumeControl.setLevel(salatSettingsObj.prayerCallVolume);

                m_player.prefetch();
                m_player.start();
            } catch (Exception e) {
                e.printStackTrace();
            }

        }

        private void stopMP3() {
            if (m_player == null)
                return;
         
            try {
         
                m_player.stop();

                // m_player.close();
            } catch (MediaException ex) {
                ex.printStackTrace();
              
            }
            m_player.deallocate();
            m_player = null;

        }