How to write a BlackBerry application – Lesson 2: Mail API, Invoke API, Menu
How to write your second BlackBerry application – Lesson 2: Mail API, Invoke API, Menu
In this lesson, you’ll learn how one can program, create and compose email messages as well as how to add a MenuItem to your application.
1. You open up the JDE (Java Development Environment) and load your Workspace file. Go to File -> Recent Workspaces to load up the Lections.jdw file.
2. Now right-click on Lections.jdw and select Create new Project
3. Name it Lection_2
4. Now right-click on Lection_2 and select Add file to Project
5. Select both files HelloWorld.java and Lesson2Screen.java to import them into the project
6. You now have the project set up and are ready to jump into the code
What the application allows you to do is the following:
It gives you 3 EditFields where you can enter data. It also provides you with 2 ButtonFields.
The one button is called Create email and when you click that button it pops up a new email message with the data you entered in the fields. From there, you can send the email.
The other button is called Send email and after you click the button, it sends off the email straight from your app without showing the form where you can still edit the message. Then, when you go into your Messages Application you find the sent mail there.
What else do I learn in this lesson?
You learn how to insert colored fields into the screen and you learn how to add a MenuItem to your app.
What else is there to know about this lesson?
We imported two new APIs into our project:
The invoke-API is needed to invoke the Messages application to pop up that email form and the mail-API is needed to send of the email from the Send email button. For a complete list of all APIs you can go to Help -> API Reference.
Is there anything specific you want me to cover in the next lesson?
Drop your thoughts in the comments or reply to me on Twitter: www.twitter.com/FabianMH.