Monday, March 30, 2009

How To : Add an ApplicationMenuItem to BlackBerry Maps

0 comments

How To The BlackBerry Maps application allows the BlackBerry device user to view maps and receive directions on a BlackBerry device. BlackBerry Maps can also provide a visual route and navigational instructions to a specified destination.

BlackBerry Maps works with BlackBerry Device Software 4.1 and later. BlackBerry Maps is included with BlackBerry Device Software 4.2 and later. For use with BlackBerry Device Software 4.1, BlackBerry Maps can be downloaded from www.blackberry.com/maps.

With third-party applications, an ApplicationMenuItem can be added to the menu of BlackBerry Maps and pass a MapView object into the application.

This article focuses on adding an ApplicationMenuItem to BlackBerry Maps. Please see Here for information on the way to add a custom menu item to other BlackBerry device applications.

An ApplicationDescriptor is required for adding an ApplicationMenuItem to BlackBerry Maps. The code for registering a menu item with the BlackBerry Maps application is as follows:

 

ApplicationMenuItemRepository amir =
    ApplicationMenuItemRepository.getInstance();
ApplicationDescriptor ad_startup =
    ApplicationDescriptor.currentApplicationDescriptor();
ApplicationDescriptor ad_gui =
    new ApplicationDescriptor(ad_startup, "gui", null);
amir.addMenuItem(ApplicationMenuItemRepository.MENUITEM_MAPS,
new MapMenuItem(),ad_gui);

The menu item MapMenuItem() is then registered with the BlackBerry Maps application (MENUITEM_MAPS) to invoke the current application with ad_gui as the ApplicationDescriptor. The MapMenuItem()method contains the actual code for specifying the menu item as shown below. MapMenuItem implements the abstract class ApplicationMenuItem and implements the run and toString methods. The toString method specifies the text to display on the menu item.

private static class MapMenuItem extends ApplicationMenuItem {
     MapMenuItem() {
        super(20);
     }
     public String toString() {
        return "My Menu Item";
     }
     public Object run(Object context) {
        mv = (MapView)context;
        if (mv != null) {
            System.out.println("Latitude = " + mv.getLatitude());
            System.out.println("Longitude = " + mv.getLongitude());
            System.out.println("Zoom = " + mv.getZoom());
        }
        else {
             throw new IllegalStateException("Context is null, expected a MapView instance");
        }
        return null;
     }
}

Friday, March 27, 2009

How to : Create a custom layout manager for a screen

3 comments

How To You can create your own custom layout manager by extending the net.rim.device.api.ui.Manager class and customizing it to fit your needs. Custom layout managers enable you to customize the placement of fields on the screen and customize navigation within these fields. To do this, you need to implement at least the following three methods:

  1. public int getPreferredWidth()

This method returns the manager's preferred width.

  1. public int getPreferredHeight()

This method returns the manager's preferred height.

  1. public void sublayout(int height, int width)

This method is invoked by the manager's layout() method and instructs each child field how and where to be laid out.

This can be accomplished by calling Manager.setPositionChild(Field field, int x, int y) and LayoutChild(Field field, int width, int height) for each field contained in the manager.

Here is an example of how a screen can associate itself with a custom layout manager:

class LayoutManager extends Manager {
   public LayoutManager() {
       //construct a manager with vertical scrolling
       super(Manager.VERTICAL_SCROLL);
   }
   //overwrite the nextFocus method for custom navigation
   protected int nextFocus(int direction, boolean alt) {
       //retrieve the index of the current field that is selected
       int index= this.getFieldWithFocusIndex();
       if(alt) {
           if(direction 0){...}
               else{...}
       }
      // if we did not handle it, let the manager's parent class
      if (index == this.getFieldWithFocusIndex())
          return super.nextFocus(direction, alt);
      else
          return index;
   }
   protected void sublayout(int width, int height) {
       Field field;
       //get total number of fields within this manager
       int numberOfFields = getFieldCount();
       int x = 0;
       int y = 0;
       for (int i = 0;i < numberOfFields;i++) {
           field = getField(i); //get the field
           setPositionChild(field,x,y); //set the position for the field
           layoutChild(field, width, height); //lay out the field
           y += ...;
           ...
       }
       setExtent(width, height);
   }
   public int getPreferredWidth() {
       return 160;
   }
   public int getPreferredHeight() {
       int height= 0;
       int numberOfFields= getFieldCount();
       for (int i= 0; i < numberOfFields; i++) {
           height+= getField(i).getPreferredHeight();
           return height;
       }
   }

the main class :

   ...
   RichTextField myField = new RichTextField("Hello");
   RichTextField myOtherField = new RichTextField("World");
   LayoutManager myManager = new LayoutManager();
   MainScreen myScreen = new MainScreen();
   myScreen.add(myManager);
   myManager.add(myField);
   myManager.add(myOtherField);
   ...

Tuesday, March 24, 2009

Code : ListField with check boxes

5 comments

Code The default implementation of a ListField on a BlackBerry device will display text in a number of selectable rows. It is possible to expand on this behaviour and allow an application to add a series of check boxes to the list. This can provide a visual indication to the user of rows that have some significance to the application. In the attached sample application, check boxes are added to the left side of a ListField. The boxes can be checked and unchecked by highlighting the appropriate row and by either pressing the SPACEBAR or selecting Change Option from the menu. Here is a screenshot of what the list looks like with the first row highlighted on a BlackBerry 7290 Wireless Handheld™ with BlackBerry Device Software 4.1.


To download the source code of this application, see the CheckboxListField.zip file.

Monday, March 23, 2009

Code : End incoming call programatically

2 comments

Code Event injector will work only when the keystrokeinjection permission is set to allow for that particular application. To do so you have to go to the Options -> Advanced Options -> Applications –> Press Menu key –>  Modules –> select your application –> Press Menu key –> Edit Permissions –> Expand Interaction option-> set to allow keystrokeinjection permission.

EventInjector.KeyCodeEvent pressEndKey = new
    EventInjector.KeyCodeEvent(
    KeyCodeEvent.KEY_DOWN,( char)
    Keypad.KEY_END,0,100);

EventInjector.KeyCodeEvent releaseEndKey =
    new EventInjector.KeyCodeEvent(
    KeyCodeEvent.KEY_UP,(char)
    Keypad.KEY_END,0,100);

Thread.sleep(1000);
EventInjector.invokeEvent(pressEndKey);
EventInjector.invokeEvent(releaseEndKey);

Saturday, March 21, 2009

Code : Change HomeScreen-Icon on an external event

0 comments

Code Code:

String[] newargs = {"homescreen"};
int modHandle = CodeModuleManager
    .getModuleHandle("HomeScreenIconTest");
ApplicationDescriptor[] apDes =
    CodeModuleManager.getApplicationDescriptors(modHandle);
ApplicationDescriptor apDes2 = new
    ApplicationDescriptor(apDes[0], newargs);
ApplicationManager.getApplicationManager()
    .runApplication(apDes2);

and the main from the Class HomeScreenIconTest:

Code:

public static void main(String[] args) {
    if (args.length > 0 && args[0].equals("homescreen")) {
        HomeScreen.updateIcon(CROSS,0);
        HomeScreen.setRolloverIcon(MAN,0);
    } else {
        HomeScreenTest theApp = new HomeScreenTest();
        theApp.enterEventDispatcher();
    }
}

If event listener (running as a system service) registers
an event then now update the icon of main application,
indicating that there is an event waiting.
Maybe draw a number with graphics on the Bitmap.

How To : Auto-launch midlets using pushregistry except incoming message

2 comments

How To Launch midlets using pushregistry other than incoming message through alarm....its very simple ...all you need to do is just register
alarm for a particular time for launching the midlet automatically...
below is the syntax for registering the alarm :

Date alarm = new Date();
String midletClassName = this.getClass().getName();
PushRegistry.registerAlarm(midletClassName, alarm.getTime());

pushregistry.registeralarm method used to register your midlet.

Code:



PushRegistry.registerConnection(defaultURL,midletClassName,
defaultFilter);



Enjoy!

Code : Invoke rich media explorer

0 comments

Code /* Application.java */

import net.rim.device.api.ui.UiApplication;
public class Application extends UiApplication{

    public static void main(String[] args) {
        (new Application()).enterEventDispatcher();
    }

    public Application() {
        this.pushScreen(new MyScreen());
    }
}

/* MyScreen.java */

import net.rim.device.api.system.ApplicationDescriptor;
import net.rim.device.api.system.ApplicationManager;
import net.rim.device.api.system.ApplicationManagerException;
import net.rim.device.api.system.CodeModuleManager;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.component.Menu;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.system.Bitmap;

public class MyScreen extends MainScreen {

    private static final MenuItem menuItemClose =
                                                 new MenuItem(
                                                             "Close", 13, 244) {
        public void run() {
            System.exit(0);
        }
    };

    private static final MenuItem menuItemRun =
                                                 new MenuItem(
                                                               "Run", 13, 244) {
        public void run() {
            int handle = CodeModuleManager
                                .getModuleHandle("net_rim_bb_file_explorer");
            if (handle <= 0) {
                System.out.println("HANDLE IS INVALID");
                return;
            }
            ApplicationDescriptor[] appDescriptors = CodeModuleManager
                                            .getApplicationDescriptors(handle);
            if ((appDescriptors==null) || (appDescriptors.length == 0)) {
                System.out.println("App descriptors are missing");
                return;
            }
            String[] args = {"", "" };
            ApplicationDescriptor descriptor = new ApplicationDescriptor(
                                      appDescriptors[0], "Media explorer", args,
                                      Bitmap.getBitmapResource("icon.png"), -1, null, -1,
                                      ApplicationDescriptor.FLAG_SYSTEM);           
            try {
                ApplicationManager.getApplicationManager().runApplication(descriptor);
            } catch (ApplicationManagerException e) {
                System.out.println("App cannot be launched");
                System.out.println(e.getMessage());
                return;               
            }       
        }
    };

    public MyScreen() {
        super();
    }

    public boolean onClose() {
        System.exit(0);
        return false;
    }

    public void makeMenu(Menu menu, int context) {
        menu.add(menuItemRun);
        menu.add(menuItemClose);
    }
}

Enjoy!

Thursday, March 19, 2009

How To : Format text in a RichTextField

6 comments

How To A RichTextField can be used to present selectable, formatted text to a user. Multiple fonts, font sizes, and font formatting (for example, Bold, Italic, Underlined) can be used in a single RichTextField.

 

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
public final class RichTextFieldSample extends UiApplication
{
    public static void main(String[] args)
    {
            RichTextFieldSample theApp = new RichTextFieldSample();
            theApp.enterEventDispatcher();
    }
    public RichTextFieldSample()
    {
        //Define the screen.
        MainScreen mainScreen;
        //Defint the RichTextField.
        RichTextField rtField;
        //An array of fonts to be passed to the RichTextField.
        Font fonts[] = new Font[3];
        //A list of offsets of character positions of the string contained
        //in the RichTextField where font appearance will change.
        //The first value in the offset array should be 0,
        //the starting character of the string and the last value should
        //be the last character position in the string.
        int[] offset = new int[4];
        //An array of indexes that align with the offset values and indicate
        //the index of the font array of the font to use starting at an offset.
        byte[] attribute = new byte[3];
        //Get three instances of the default font.
        //On plain, one bold and one bold and italic.
        fonts[0] = Font.getDefault();
        fonts[1] = Font.getDefault().derive(Font.BOLD);
        fonts[2] = Font.getDefault().derive(Font.BOLD | Font.ITALIC);
        //The string of text we will display in the RichTextField.
        String richText = "This is how you create text with formatting!!!";
        //Offset will start a character 0 of the string.
        offset[0] = 0;
        //At character position 0 we want to use the font at
        // position 2 of the font array (bold and italic).
        attribute[0] = 2;
        //Change to the default (non-bold, non-italic) font at
        //the 4th character position.
        offset[1] = 4;
        attribute[1] = 0;
        //Change to bold font at the 33rd character position.
        offset[2] = 33;
        attribute[2] = 1;
        //Add the last character position to the offset.
        offset[3] = richText.length();
        //Instantiate mainScreen.
        mainScreen = new MainScreen();
        //Set the title of mainscreen.
        mainScreen.setTitle(new LabelField
          ("RichTextFieldSample Sample",
            LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH));
        //Instantiate rtField.
        rtField = new RichTextField
          (richText, offset, attribute, fonts,
           RichTextField.USE_TEXT_WIDTH);
        //Add the RichTextField to the MainScreen.
        mainScreen.add(rtField);
        //Push the MainScreen onto the stack.
        pushScreen(mainScreen);
    }
}

Wednesday, March 18, 2009

How to : display Horizontal and Vertical scrollbar with arrows

0 comments

How To If you have few rows and few columns in your application. Number of columns and rows are more. In order to display next column or next row, we need to nevigate in respective direction (left , right, up ,down).

And if you want to show the scroll bars with ARROWS following code can help you :

for Horizontal Scrollbar arrows:

HorizontalFieldManager hfmScrollbar;
hfmScrollbar=new HorizontalFieldManager()
{
protected void sublayout(int maxwidth,int MaxHeight)
{
setExtent(FIELD_WIDTH,20);
}
public void paint(Graphics g)
{
g.setColor(Color.BLACK);
g.drawRect(0,0,FIELD_WIDTH,20);
int lxPts[] = {5, 15, 15};
int lyPts[] = {10,5,15};
int rxPts[] = {FIELD_WIDTH-5,FIELD_WIDTH-15,FIELD_WIDTH-15};
int ryPts[] = {10,5,15}; g.drawFilledPath(lxPts, lyPts, null, null); g.drawFilledPath(rxPts, ryPts, null, null);
super.paint(g);
}
};

for Vertical Scrollbar arrows :

VerticalFieldManager vfmScrollbar=new VerticalFieldManager(){
protected void sublayout(int maxWidth,int maxHeight){
setExtent(20,160);
}
public void paint(Graphics g){
g.setColor(Color.BLACK);
g.drawRect(0,0,20,160);
int uxPts[]={5,10,15};
int uyPts[]={15,5,15};
int dxPts[]={5,10,15};
int dyPts[]={145,155,145};
if(currentRow>7)
g.drawFilledPath(uxPts, uyPts, null, null);
if(totalRows>8 && currentRow<totalRows)
g.drawFilledPath(dxPts, dyPts, null, null);
super.paint(g);
}
};

Tuesday, March 17, 2009

How To : Create a Scrollable Image Field

2 comments

How To The BitmapField class that is part of the BlackBerry smartphone API set allows an application to display an image within an application. These fields do not support internal scrolling, therefore if the image you wish to display is larger than the available screen area the image will be truncated. The following example demonstrates how to create a custom field that supports internal scrolling (scrolling within the field) if the image is larger than the available screen area available to the field.

You can download source for the ScrollableImageField.java

Download here.

How to : Make list items appear on a screen

0 comments

How To To create a list of selectable items, the ListField class is needed and the ListFieldCallback interface must be implemented. ListField is the displayable field object and the ListFieldCallback interface is responsible for drawing the list elements to the screen. The ListFieldCallback drawListRow() method is called automatically by the system for each element in the list.

The following is a sample implementation of ListFieldCallback:

private class ListCallback implements ListFieldCallback {
private Vector listElements = new Vector();
public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
String text = (String)listElements.elementAt(index);
g.drawText(text, 0, y, 0, w);
}
public Object get(ListField list, int index) {
return listElements.elementAt(index);
}
public int indexOfList(ListField list, String p, int s) {
//return listElements.getSelectedIndex();
return listElements.indexOf(p, s);
}
public int getPreferredWidth(ListField list) {
return Graphics.getScreenWidth();
}
public void insert(String toInsert, int index) {
listElements.insertElementAt(toInsert, index);
}
public void erase() {
listElements.removeAllElements();
}
}

To create an instance of ListField

ListField _list = new ListField();

To create an instance of ListCallback, which is an implementation of the ListFieldCallback interface, use the following:

ListCallback _callback = new ListCallback();

After creating instances of ListField and ListCallback, an association between the two can be created by calling the ListField setCallback() method as follows:

_list.setCallback(_callback);

Now that the list has been initialized, items can be added to it as follows:

_list.insert(index);
_callback.insert(name, index);

Where name is the String that represents the name of the selectable item in the list and index is a number (int) that represents the position of the item in the list.

Friday, March 13, 2009

How To : Detect if the BlackBerry smartphone is holstered or flipped

0 comments

How To The Sensor API allows third-party applications to query the existence and states of BlackBerry smartphone sensors (for example, holster or flip). This API also supports registration to a SensorListener that can receive updates for specified sensor(s).

Note: The relevant classes added to BlackBerry® Java® Development Environment (BlackBerry JDE) 4.6 are as follows:

  • net.rim.device.api.system.Sensor
  • net.rim.device.api.system.SensorListener

The following code snippet shows how to receive sensor updates for both flip and holster events using the SensorListener:

public class SensorDemo extends Application implements SensorListener {

public SensorDemo() {
Sensor.addListener(this,this,Sensor.HOLSTER | Sensor.FLIP);
System.exit(0);
}
public void onSensorUpdate(int sensorId, int update)
{
switch(sensorId)
{
case Sensor.HOLSTER:
System.out.println("Received an Holster update!");
switch(update){
case Sensor.STATE_IN_HOLSTER:
System.out.println("Device Holstered!");
break;
case Sensor.STATE_OUT_OF_HOLSTER:
System.out.println("Device out of Holster!");
break;
default:
System.out.println("Unknown Holster update");
}
break;
case Sensor.FLIP:
System.out.println("Received a Flip update!");
switch(update){
case Sensor.STATE_FLIP_OPEN:
System.out.println("Device Flip opened!");
break;
case Sensor.STATE_FLIP_CLOSED:
System.out.println("Device Flip closed!");
break;
default:
System.out.println("Unknown Flip update");
}
break;
default;
}
}
public static void main(String[] args)
{
new SensorDemo().enterEventDispatcher();
}

Monday, March 9, 2009

Support : setMediaTime does not work for AMR files

1 comments

When using the Player method to seek the media time in an Adaptive Multi-Rate (AMR) encoded file, seeking past the first 58 KB of the file does not work. Seeking is possible within the first 58 KB of the AMR file, provided the file size is known, and setMediaTime is called after the PlayerListener.STARTED event is received.

To work around this limitation, implement and call a custom DataSource method to handle the seeking separately.

See DB-00612 for instructions on creating a custom DataSource and SourceStream.

The SourceStream implementation should contain a special operation to handle the AMR seeking. The following is an example for 12.2kbps AMR files, which is the encoding standard used for files recorded on the BlackBerry device. AMR files are broken into 20 millisecond frames, and 12.2kbps files have 32bytes per frame. Each AMR file also has a 6 byte header.

public void amrSeek(long millis) {
int frame = (int) millis/20;
readLocation = (framenumber * 32) + 6;
}

The SourceStream read method should use the readLocation variable to define where reads to the media stream will start because it is the beginning of the frame that has been seeked.

How To : Play video within a BlackBerry smartphone application

0 comments

How To In BlackBerry Device Software 4.3.0 and later and BlackBerry JDE 4.3.0 and later, video playback within a BlackBerry smartphone application is supported that allows the application to control video playback (play, pause, etc.).

The following code sample plays back a video called Trailer.avi from the Trailers directory on the microSD card on the BlackBerry smartphone. You can open video content from any valid URL. The sample code can also be downloaded here.

Alternatively, you can play video on any BlackBerry smartphone that supports video playback (BlackBerry Device Software prior to 4.3.0) by launching the Media application on the BlackBerry smartphone. To do so, invoke the BlackBerry® Browser with a URL that points to your video content. The URL could point to a web server or to a file located on the microSD card on the BlackBerry smartphone (for instance, "file:///SDCard/yourDirectory/yourFile.avi" or http://yourServer.com/yourFile.avi).

See Here for information on how to invoke the BlackBerry Browser.

import javax.microedition.media.Player;
import javax.microedition.media.Manager;
import javax.microedition.media.control.VideoControl;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.system.Characters;


public final class PlayVideo extends UiApplication
{
private Player player;
private VideoControl videoControl;
public static void main(String[] args)
{
PlayVideo theApp = new PlayVideo();
theApp.enterEventDispatcher();
}
public PlayVideo()
{
MainScreen ms = new MainScreen(){
public boolean onClose()
{
//Clean up the player resources.
player.close();
videoControl.setVisible(false);
close();
return true;
}
//Override keyChar to capture key commands used to control video playback.
protected boolean keyChar(char c, int status, int time)
{
boolean retVal = false;
if (c == Characters.SPACE)
{
if (player.getState() == Player.STARTED)
{
//Stop playback.
try
{
player.stop();
}
catch (Exception ex)
{
System.out.println("Exception: " + ex.toString());
}
}
else
{
//Start playback.
try
{
player.start();
}
catch (Exception ex)
{
System.out.println("Exception: " + ex.toString());
}
}
retVal = true;
}
return retVal;
}
};
ms.setTitle(new LabelField("Let's play some video..."));
LabelField lf = new LabelField("Press space to start/stop/resume playback.");
ms.add(lf);
pushScreen(ms);
try
{
//Create a new Player pointing to the video file.
//This can use any valid URL.
player = Manager.createPlayer("file:///SDCard/Trailers/Trailer.avi");
player.realize();
//Create a new VideoControl.
videoControl = (VideoControl)player.getControl("VideoControl");
//Initialize the video mode using a Field.
videoControl.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
//Set the video control to be visible.
videoControl.setVisible(true);
}
catch (Exception ex)
{
System.out.println(ex.toString());
}
}
}

Saturday, March 7, 2009

What Is : Compatibility mode on touch screen BlackBerry smartphones

0 comments

What Is Compatibility mode is used when the application has been designed for a physical input (non-touch screen) BlackBerry smartphone, where the application expects to receive input events from the keyboard and the trackball.

There are three ways that your application can indicate whether it should be running in compatibility mode:

  1. If the application is compiled with BlackBerry® Java® Development Environment (BlackBerry JDE) 4.7 or later, it will automatically not run in compatibility mode. If the application is compiled with any earlier version of the BlackBerry JDE, it will run in compatibility mode.
  2. You can add fields to your Java Application Descriptor (JAD) file for wireless downloading to indicate whether you want the application to run in compatibility mode regardless of what BlackBerry JDE version was used to compile the application. You can also use a field to indicate whether the BlackBerry smartphone user can modify this capability. In the following example, the value can be set to either true or false.

RIM-TouchCompatibilityMode: value
RIM-TouchCompatibilityMode-UserChangeable: value Blackberry Strom

  1. The BlackBerry smartphone user can modify settings on the BlackBerry smartphone so that the application runs in compatibility mode. This is done by completing the following steps on the BlackBerry smartphone:
    1. Go to Options > Advanced Options > Applications.
    2. From the list of applications, select the appropriate application.
    3. Display the menu, and then turn on enable or disable for the compatibility mode.

If your application is running in compatibility mode, it will always have a virtual keyboard, it will always be locked to portrait mode, and it will always translate touch events into trackball or keyboard events.

News : Telefonica and RIM Launch the Sleek, New BlackBerry Curve 8900 Smartphone in Spain

0 comments

Press release Date : March 3, 2009

Madrid, Spain and Waterloo, Canada - Telefónica and Research In Motion (RIM) (Nasdaq: RIMM; TSX: RIM) today launched the BlackBerry® Curve™ 8900 smartphone in Spain. The BlackBerry Curve 8900, which forms part of Telefónica’s Movistar catalogue, offers users an expansive set of features that makes it incredibly easy to keep in touch with the office, friends and family.

The new BlackBerry Curve 8900 smartphone features built-in Wi-Fi®, GPS, Bluetooth® 2.0, a next generation processor and a dazzling hi-resolution display. It includes premium phone features, the industry's leading mobile email and messaging capabilities and rich multimedia features, enabling customers to remain connected, productive and entertained while on the move.

At approximately 110 grams and 109 x 60 x 13.5 millimeters, the BlackBerry Curve 8900 smartphone from Telefónica is the thinnest full-QWERTY BlackBerry smartphone to date. Its sleek and refined design feels comfortable for either one-handed or two-handed use. The large, striking 2.4 inch HVGA+ display (480x360 resolution) projects vivid color and makes information easier to read. The BlackBerry Curve 8900 smartphone also provides flexible connectivity and helps people find their way, combining built-in Wi-Fi (802.11 b/g) support and GPS capabilities.

[Read More…>>]

News : IDEA Launches Portfolio of BlackBerry Offerings in India

0 comments

Press release Date : March 4, 2009

Mumbai, India - IDEA Cellular, one of the leading GSM operators in India, and Research In Motion (RIM) (Nasdaq: RIMM; TSX RIM) today announced the launch of the BlackBerry® solution for IDEA customers. IDEA will offer a broad range of BlackBerry® smartphones and services for enterprise and individual customers on its network, nationally.
The BlackBerry solution provides customers with easy wireless access to email, phone, calendar, web and multimedia applications, as well as access to thousands of other mobile business and lifestyle applications.
BlackBerry smartphones will now be available from IDEA stores, leading modern trade, and multi-brand outlets across 15 circles of IDEA Cellular's network, throughout the country. IDEA customers can now choose from a broad range of BlackBerry smartphones and enjoy the freedom and productivity benefits of using the BlackBerry solution to stay connected to people and information, while on the move.

[ Read More…>> ]

News : RIM unveils the BlackBerry Curve 8900 Smartphone

0 comments

News Research In Motion (RIM) on Friday unveiled the thinnest and lightest full-QWERTY BlackBerry smartphone – the BlackBerry Curve 8900 – in the Philippines.


The new BlackBerry Curve 8900 smartphone features a compact and sleek design weighing just 110 grams and measuring only 109mm x 60mm x 13.5mm, which fits comfortably in the hand for one or two-handed use. Housed within its chrome-frame and stylish black finish, the BlackBerry Curve 8900 packs an expansive feature-set with rich multimedia capabilities, as well as advanced phone, email, messaging, organizer and web browser applications. The powerful new smartphone makes it easy to stay connected with family, friends and co-workers, surf the net, take and view pictures, record and watch video and listen to music while on the go.Click to Zoom-In (BB Curve 8900)

Powered by a 512MHz next generation mobile processor that delivers snappy performance, the BlackBerry Curve 8900 smartphone supports quad-band EDGE and includes built-in Wi-Fi (802.11 b/g) and Bluetooth for flexible connectivity. Its built-in GPS supports location-based applications and services to provide added travel convenience for users.


Its large and brilliant display features the highest resolution available on a BlackBerry smartphone (480x360 resolution), adding to its rich multimedia experience. It also comes with a 3.2 megapixel camera that includes auto focus, image stabilization, digital zoom and flash, as well as a microSD/SDHC expandable memory card slot that supports up to 16GB per card, giving users plenty of storage to carry and capture more of their music, pictures and video wherever they go.
“The new BlackBerry Curve 8900 gives users an exceptional mobile experience,” said Gregory Wade, Regional Vice President, Asia Pacific at Research In Motion. “Its compact and refined design, combined with its impressive functionality and performance, will make it a popular choice with both business customers and consumers.”
The BlackBerry Curve 8900 smartphone will be available in the Philippines from Globe Telecom and Smart Communications in March 2009.

Thursday, March 5, 2009

Support - RMS data store does not persist between invocations of the simulator

0 comments

If an application is recompiled, it will not be able to access its existing RMS data stores on the simulator. Because of the recompilation, the application is not considered to be the same as the previous version and will not be allowed access to the RMS data stores on the simulator. This feature is part of the persistent data access security architecture.

Support - Unable to connect BlackBerry devices and simulators running BlackBerry Device Software 4.2.2 to BlackBerry JDE 4.2.1

0 comments

Problem :

BlackBerry JDE 4.2 and later automatically recognizes installed BlackBerry Device Simulators and includes them in the list of simulators. Although BlackBerry Device Simulator 4.2.2 is recognized and listed, it cannot connect to BlackBerry JDE 4.2.1. The following error message is displayed in BlackBerry JDE 4.2.1:

The running VM is not compatible with this version of the IDE. Debugging is not possible.

Cause :The BlackBerry® Java® Virtual Machine (BlackBerry JVM) in BlackBerry Device Software 4.2.2 and BlackBerry Device Simulator 4.2.2 is incompatible with BlackBerry JDE 4.2.1.

Resolution : This issue was corrected in BlackBerry JDE 4.3.0. BlackBerry JDE

4.3.0 can be used to debug the application, but the application still needs to be built using BlackBerry JDE 4.2.1.

How To - Use a computer file system as a microSD card

1 comments

BlackBerry JDE 4.3.0 and later

To use a computer file system as a microSD card, complete the following steps:

  1. Open the BlackBerry JDE.
  2. From the Edit menu, click Preferences.
  3. On the Simulator tab, select a simulator running BlackBerry® Device Software 4.3.x.
  4. On the Simulator tab, click Memory.
  5. Select the Use PC filesystem for SD Card files check box.
  6. Type the location of the folder to use as a microSD card.

Note: Using the Browse button to select the location of the folder to use as a microSD card in BlackBerry JDE only allows selection of a file and not a folder; the location must be corrected manually to represent a folder.

  1. Click OK.

Eclipse

Note: The BlackBerry JDE Plug-in for Eclipse is required.

To use a computer file system as a microSD card, complete the following steps:

  1. Open Eclipse.
  2. Click the arrow beside the Debug as button.
  3. Click Open Debug Dialog.
  4. Click an entry under BlackBerry Simulator.
  5. On the Simulator tab, click Memory.
  6. Select the Use PC filesystem for SD Card files check box.
  7. Type the location of the folder to use as a microSD card.
  8. Click OK.

Wednesday, March 4, 2009

Code : Capture Signature on the BlackBerry Storm

2 comments

The BlackBerry Storm incorporates a touchscreen which can be used to capture and collect signatures. The following sample application demonstrates how to accomplish this by using the TouchEvent API to capture touch points and then using a BitmapField to draw the signature. A complete working sample can be downloaded here.

Code : Access and Obtain Service Books

0 comments

The BlackBerry JDE 4.0 has a package, net.rim.device.api.servicebook, that allows the retrieval of service book information on a BlackBerry device.

The example below uses both the ServiceBook and ServiceRecord classes to obtain the APN of the WAP Browser service book:

import net.rim.device.api.system.*;
import net.rim.device.api.servicebook.*;
public class ServiceBookExample extends Application {
ServiceRecord[] _sRecordsArray; //Creates a ServiceRecord array.
ServiceBook _servicebook; //Creates a ServiceBook variable.
String cidValue, sbName, sbAPN;
public static void main(String[] args)
{
// Create a new instance of the application and
// start the event thread.
ServiceBookExample app = new ServiceBookExample();
app.enterEventDispatcher();
}
public ServiceBookExample() {
// Returns a reference to the service book from the factory.
_servicebook = ServiceBook.getSB();
// Returns an array of all registered service records.
_sRecordsArray = _servicebook.getRecords();
// Loops through the service record array
// and obtains specific information relating
// to each item and prints it to the debugging output.
for(int i = 0; i < _sRecordsArray.length; i++) {
// Obtains the Service Book CID
cidValue = _sRecordsArray[i].getCid();
// Obtains the Name of the Service Book
sbName = _sRecordsArray[i].getName();
if(cidValue.equals("BrowserConfig")
&& sbName.startsWith("WAP Browser")) {
// Obtains the Service Book's APN
// (Associated Access Point Name)
String sbAPN = _sRecordsArray[i].getAPN();
}
}
}
}

For a complete listing of available methods, please see the API reference included within the BlackBerry JDE 4.0. Additional information can be found in Chapter 10 of the BlackBerry Application Developer Guide Volume 2.

Code : Determine if a microSD card has been inserted

0 comments

The BlackBerry® Pearl™ 8100 smartphone was the first BlackBerry device to support microSD cards. Along with microSD card support, the BlackBerry Pearl 8100 smartphone was the first BlackBerry device to support JSR 75, the FileConnection API. In addition to providing the ability to store data to the internal memory and microSD card, this API also allows an application developer to determine if a microSD card has been inserted into the BlackBerry Pearl 8100 smartphone.

String root = null;
Enumeration e = FileSystemRegistry.listRoots();
while (e.hasMoreElements()) {
root = (String) e.nextElement();
if( root.equalsIgnoreCase(“sdcard/”) ) {
//device has a microSD inserted
} else if( root.equalsIgnoreCase(“store/”) ) {
//internal memory identifier
}
}

The above code will allow a developer to determine if a microSD card is currently inserted, while the code below will notify the developer if this state ever changes (card removed/card inserted). Note that the listener must be added to FileSystemRegistry via the addFileSystemListener() method.

public class MySDListener implements FileSystemListener {
public void rootChanged(int state, String rootName) {
if( state == ROOT_ADDED ) {
if( rootName.equalsIgnoreCase(“sdcard/”) ) {
//microSD card inserted
}
} else if( state == ROOT_REMOVED ) {
//perform the same check as above
}
}
}

As of the last updated date of this article, an API did not exist to determine if the BlackBerry device could support microSD regardless of whether or not a card was inserted. However, the BlackBerry device model number can be used to determine microSD card support since the list of BlackBerry devices that support this feature is finite.

String modelNum = DeviceInfo.getDeviceName();
if(modelNum.startsWith("8") && !modelNum.startsWith("87")) {
//microSD card supported
}

Tuesday, March 3, 2009

Code : BlockDecryptor class

0 comments

I need to encrypt the string using AES encryption and CBC mode.

The way given in one of the post 'How to - Use Basic Encryption'. This code works fine.

But when I am encrypting the string using blockdescryptor and CBCBlockDescryptor the string is not encrypted fully.

Now the question was “How can I encrypt the string properly?”.

Following is the code:

private static byte[] encrypt(byte[] keyData, byte[] data) throws CryptoException, IOException

{

// Create the AES key to use for encrypting the data.

// This will create an AES key using as much of the keyData
// as possible.
AESKey key = new AESKey(keyData, 0, 128);

// Now, we want to encrypt the data.
// First, create the encryptor engine that we use for the actual
// encrypting of the data.
AESEncryptorEngine engine = new AESEncryptorEngine(key);

String strInitVector = "1234567890123456";
byte[] initVector = strInitVector.getBytes();
// Create a new initialization vector using the 8 bytes in initVector
InitializationVector iv = new InitializationVector(initVector);
// Create a BlockEncryptor to hide the engine details away.
ByteArrayOutputStream output = new ByteArrayOutputStream();
BlockEncryptor encryptor = new BlockEncryptor(new CBCEncryptorEngine(engine, iv) , output);
//BlockEncryptor encryptor = new BlockEncryptor(fengine , output);
encryptor.write(data, 0, data.length);
int nSize = output.size();
encryptor.flush();
output.close();
//encryptor.close(); // At this line application is throwing uncaught exception

// Now, the encrypted data is sitting in the ByteArrayOutputStream.
// We simply want to retrieve it.
return output.toByteArray();
}

The string given for encryption is "The quick brown fox jumped over the lazy dog".

Actual encrypted string from PHP for this string is of 42 characters. Where as my application is giving me the encrypted string of 32 characters. After decryption I am getting the plain text as "The quick brown fox jumped over ".

I have tried the same thing,appended '0' byte at the end of the string if the string length is less than block length.

And, It is working perfect.