List of all Iphone and Blackberry Development codes in a one click Iphone,objective C,xcode,blackberry Development,iOS Development

Tuesday, August 21, 2012

Phone Call in Blackberry

The following code will help to call a mobile number programatically.

PhoneArguments callArgs = new PhoneArguments(PhoneArguments.ARG_CALL,"mobile number to make call");
Invoke.invokeApplication(Invoke.APP_TYPE_PHONE, callArgs);


        

Automatically Taking Picture in Blackberry

The following code will automatically take pictures without any user interactions. It also displays the taken picture in the screen.

    private Field _videoField;
    private Player _player;
    private VideoControl _videoControl;
    byte[] image;

 try{
        _player = Manager.createPlayer( "capture://video??encoding=jpeg&width=240&height=240" );
        _player.realize();
        _player.prefetch();
        _videoControl = (VideoControl)_player.getControl("VideoControl");
        _player.start();               
        if (_videoControl != null){

            _videoField = (Field) _videoControl.initDisplayMode (GUIControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
            _videoControl.setDisplayFullScreen(true);
            add(_videoField);
        }
    }
    catch(Exception e)
    {
       //show error
    }
         

         try {
                image = _videoControl.getSnapshot(null);
                 _player.close();
               
                EncodedImage bitmap = EncodedImage.createEncodedImage(image, 0, image.length); 
                BitmapField field1 = new BitmapField();
                field1.setImage(bitmap);
                add(field1);
            } catch (MediaException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }



        

Play Audio From URL in Blackberry

The following code will help you to playing an audio from url.

                       try {
                         String httpURL="http://www.yourwebsite.com/audio.mp3";
                         if ((WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED)
                                    && RadioInfo.areWAFsSupported(RadioInfo.WAF_WLAN)) {
                                httpURL += ";interface=wifi";
                            }
                       
                            Player player;
                            player =Manager.createPlayer(httpURL);
                            player.realize();
                            player.prefetch();
                            player.start();
                           
                        } catch (Exception me) {
                            Dialog.alert(me.toString());
                           
                        }