Archive

Archive for the ‘BlackBerry’ Category

How to send an email from your BlackBerry application

March 26, 2009 Leave a comment

One of the main reasons for the BlackBerry to become so popular was their excellent email service and RIM was the pioneer of introducing Push email system where the user will be notified immediately once the email is received by the email server.  In your BlackBerry application also you can explore the power of BlackBerry email service quite easily.

The following code fragment outlines how to programmatically send a message while setting some additional parameters prior to sending:

//Get the Store from the default mail Session.
Store store = Session.getDefaultInstance().getStore();

//retrieve the sent folder
Folder[] folders = store.list(Folder.SENT);
Folder sentfolder = folders[0];

//create a new message and store it in the sent folder
Message msg = new Message(sentfolder);
Address recipients[] = new Address[1];

try {
recipients[0]= new Address(“user@company.com”, “user”);

//add the recipient list to the message
msg.addRecipients(Message.RecipientType.TO, recipients);

//set a subject for the message
msg.setSubject(“Test email”);

//sets the body of the message

msg.setContent(“This is a test email from my BlackBerry Wireless Handheld”);

//sets priority
msg.setPriority(Message.Priority.HIGH);

//send the message
Transport.send(msg);
}
catch (Exception me) {
System.err.printIn(me);
}

How to test the email functionality using ESS (Email Server Simulator)

ESS should be used if the email functinality is being tested in the BlackBerry simulator. If you want test a simple email with a message and simple text attachment ESS would be sufficient. But if you need to test a email with image attchment I would recommend you to use a real BlackBerry device since ESS does not support image attachments to be sent.

See this for the setting up of ESS environment.

Kick start to BlackBerry JDE

January 28, 2009 Leave a comment

Once you get familiar with BlackBerry JDE environment it is time to develop a small HelloWorld application for BlackBerry….

Here it goes….

If you are using Eclipse just create a new BlackBerry project..

For that go to File -> New -> Project and expand the BlackBerry folder and select BlackBerry project and click Next. Then enter any name click Finish. A new project will be created. Then create a new java file called HelloWorld and place the below code..

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.*;

/*
* BlackBerry applications that provide a user interface
* must extend UiApplication.
*/

public class HelloWorld extends UiApplication
{
public static void main(String[] args)
{
//create a new instance of the application
//and start the application on the event thread
//…

HelloWorld app = new HelloWorld();
app.enterEventDispatcher();
}

//define a constructor for your application
//…

public HelloWorld()
{
pushScreen(new HelloWorldScreen());
}
}

//create a new screen that extends MainScreen, which provides
//default standard behavior for BlackBerry applications

final class HelloWorldScreen extends MainScreen
{
public HelloWorldScreen()
{

//invoke the MainScreen constructor
super();

//add a title to the screen
LabelField title = new LabelField(“HelloWorld Sample”,LabelField.ELLIPSIS|LabelField.USE_ALL_WIDTH);

//add the text “Hello World!” to the screen
setTitle(title);
}

//override the onClose() method to display a dialog box to the user
//with “Goodbye!” when the application is closed

public boolean onClose()
{
//display a dialog box with “Goodbye!”
//…

Dialog.alert(“Good bye!!”);
System.exit(0);
return true;
}
}

When you run the application select it to run in BlackBerry simulator and the simulator will run.

Then select the HelloWorld application from the application list in BB simulator and click on it.

If the application is running perfectly you will see the word “HelloWorld”  displayed as the title. If you press Esc key the  Dialog box will appear saying “Good bye” and you will exit the application.

Congratulations!!! You have successfully run your first BlackBerry application. Hope this tiny application will help you to get a quick start into the BlackBerry development.

Introduction to BlackBerry development

January 16, 2009 Leave a comment

If you are new to BlackBerry development you will be quite confused with the number of development methods available. There are three main approaches,

  • BlackBerry Browser Development
  • Rapid Application development
  • Java Application development

Both Browser development and RAD are powerful development methods which provides  greater functionality and ease. When it comes to creating user interfaced the RAD approach provides the user the ability build the UI s by just dragging and dropping UI components, thus have the ability to build fully functinal enterprise applications in minutes.

If we consider the Java development environment it gives the developer the power and control to build any application although it is not as easy as the other two approaches. Unlike the rest the Java ME based developement gives the application the access the advanced feartures of the BlackBerry deveice such as camera, phone, bluetooth etc and to integrate with core BlackBerry functionalities such as BlackBerry Maps, GPS functinality, address book and message application as well.

If you are familiar with Java environment I highly recommend that you use Java ME approach which enables you to build very powerful applications on your own. Since I have also been using Java ME, I will be discussing more about Java development environment from now on.

Categories: BlackBerry

Entering to BlackBerry world

December 25, 2008 Leave a comment

I’m currently into BlackBerry smartphone application development which seems to be a cool area. I’m stBlackBerry Curveill very much new into it. I would like to share my BlackBerry experiences very soon…

Want to find more information BlackBerry? Visit the official web site which has plenty of development resources >> http://na.blackberry.com/eng/developers/

Follow

Get every new post delivered to your Inbox.