Monday, December 6, 2010

Synchronize BlackBerry Emails with Exchange Server

Lately, I implemented the function that given the native emails on BlackBerry, fetch the email attachments in the email from the Exchange Server.

Input: Emails w/ attachments on BlackBerry (The email account is on the Exchange Server)

Output: Actual attachments of the email

Complexity:
1. The attachments in an email on BlackBerry are not download to the device, therefore there is no good method to get the actual attachments through RIM API.

2. RIM API provides limited access to the properties of emails, what you can get are basically listed in the link: http://www.blackberry.com/developers/docs/4.6.0api/net/rim/blackberry/api/mail/Message.html

3. According to different exchange server versions (mainly 2003 and 2007), there are different protocols and require different transformation format. For Exchange 2003, the protocol is WebDAV which stands for Web-based Distributed Authoring and Versioning. The transformation from Exchange Message to the DAV Message that the protocol recognizes (through SQL). For Exchange 2007, the protocol is EWS which stands for Exchange Web Services. The transformation from Exchange Message to the EWS Message that the protocol recognizes (through SOAP and XML).

Possible Solutions:
Pass in a set of attributes which can be reached from RIM API (not Message ID since that is only good for BlackBerry.) and are also the same with the email record on Exchange Server. Once targeted the correct email, fetch the attachments from the Exchange Server.

Final Solutions:
Attributes passed in: Subject, Sent Time and From.

Technical requirements:
1. RIM API
2. Exchange Server and Protocols (both WebDAV and EWS)

Reference:
1. http://msdn.microsoft.com/en-us/library/bb204119.aspx
2. http://en.wikipedia.org/wiki/WebDAV

Thursday, September 23, 2010

Book Review: How to Win Friends and Influence People

《How to Win Friends and Influence People》 by Dale Carnegie

1. The importance of human relationship: "Even in the field of Engineering, about 15 percent of one's financial success is due to one's technical knowledge and about 85 percent is due to skill in human engineering--- to personality and the ability to lead people."

2. "The person who has technical knowledge plus the ability to express ideas, to assume leadership, and to arouse enthusiasm among people--- that person is headed for higher earning power."

3. Professor William James of Harvard once said "Compared to what we ought to be, we are only half awake. We are making use of only a small part of our physical and mental resources. Starting the thing broadly, the human individual thus lives far within his limits. He posesses powers of various sorts which he habitually fails to use."

4. "The great aim of education is not knowledge but action."

5. Ask yourself on a weekly basis:
"What mistakes did I make that time?"
"What did I do that was right--- and in what way could I have imporved my performance?"
"What lessons can I learn from that experience?"

6. "Ninety-nine times out of a hundred, people don't criticize themselves for anything, no matter how wrong it may be."

7. "Let's realize that the person we are going to correct and condemn will probably justify himself or herself, and condemn us in return."

8. "When dealing with people, let us remember we are not dealing with creatures of logic. We are dealing with creatures of emotion, creatures bristling with predudices and motivated by pride and vanity."

9. "Instead of condemning people, let's try to understand them. Let's try to figure out why they do what they do."

10. Sigmund Freud said that "Everything you and I do springs from two motives: the sex urge and the desire to be great."

11. Lincoln once said "Everybody likes a compliment."

12. "Don't be afraid of enemies who attack you. Be afraid of the friends who flatter you."

13. "In our interpersonal relations we should never forget that all our associates are human beings and hunger for appreciation."

14. "Let's cease thinking of our accomplishments, our wants. Let's try to figure out the other person's good points. Then forget flattery. Give honest, sincere appreciation."

15. "The only way on earth to influence other people is to talk about what they want and show them how to get it."

16. "Action springs out of what we fundamentally desire and the best piece of advice which can be given to would-be persuaders, whether in business, in the home, in the school, in politics, is: First, arouse in the other person an eager want. He who can do this has the whole world with him. He who cannot walks a lonely way."

17. "Tomorrow you may want to persuade somebody to do something. Before you speak, pause and ask yourself: 'How can I make this person want to do it?'"

18. Henry Ford once said, "If there is any one secret of success, it lies in the ability to get the other person's point of view and see things from that person's angle as well as from your own."

19. "The world is full of people who are grabbing and self-seeking. So the rare individual who unselfishly tries to serve other has an enormous advantage."

20. "People who can put themselves in the place of other people, who can understand the workings of their minds, need never worry about what the future has in store for them."

Wednesday, September 1, 2010

What I learned about BB Email Structure lately

Lately, I've been fixing a really sneaky bug and today I finally fixed it! It has something to do with the email structure and also the new os version of blackberry 6.

1. Typical Email Structure of a HTML email


2. Timing of the corresponding "text/plain" content being loaded
When the email first comes to the device, if you want to access the content of the email, you need to use Transport.more() to request more information from the server. I notice that for the peer-part of "text/html", there is a "text/plain" part comes with html mimebodypart. However, when you use Transport.more(BodyPart, true) to get the information in the "text/plain" mimebodypart, it will take approximately 5 seconds to load the content to the bodypart. Therefore, in your program, you need to wait longer for the content fetching.

3. Always deep check the content
Moreover, you need to double check the content when there is some content in the bodypart to make sure the content is not just spaces.

Reference:
1. How to- Access HTML email messages
http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800698/How_To_-_Access_HTML_email_messages.html?nodeid=1443037&vernum=0

2. One useful thread in a BB Forum
http://supportforums.blackberry.com/t5/Java-Development/Extract-Plain-Text-from-HTML-Email/td-p/184499

Thursday, August 26, 2010

Book Review: Love is the killer app

Recently, I read the book named Love is the killer app by Tim Sanders. I want to share some notes here:

The three key components to be a lovecat in bizworld:
1. Expand your knowledge
Aggregation, encoding, processing and application

2. Expand your network
Collecting, connecting (prepare thyself, swap bizcards, organize, input and follow up) and disappearing

3. Show your compassion to co-workers

Friday, August 13, 2010

Install Updates (OS6.0) on BlackBerry Torch 9800

This should apply to any OS version and Phone module generally. However it may have some slight differences for BlackBerry 6.0.

Complexity of the installation: Since I have a beta version of Os 6.0, it behaves unstably. I get an error which is 'App Error 602 reset' and the phone enters to the vicious cycle, which is after resetting, the phone goes back to 'App Error 602 reset' error. More annoyingly, the phone cannot connect to PC reliably since it is with the error. Therefore, it makes the reinstallation more complex. Here is what I did to rescue BlackBerry 6.0:

Step 1: Wipe the phone via Apploader/loader.exe
The timing of doing this is really vital. Do it when the phone is rebooting but not at its 'Error' phase. Open your command prompt in Windows, type in:
C:\Program Files\Common Files\Research In Motion\Apploader\loader.exe /resettofactory
[Note] Download and install OS6.0 from BlackBerry Website first!

Step 2: Download BlackBerry Desktop Software (new name of Desktop Manager for OS6.0)

Step 3: Connect your device to PC (Windows) and run Desktop Software (Connect the PIN)

Step 4: Desktop Software will detect the updates of OS automatically and install them on your device. The whole installation takes approximately 20 minutes.
[Note] Watch out for the disconnection of your device and the PC. Make the whole process connected.

Hope this helps for the people exploring BlackBerry torch 9800, which is by the way an awesome handheld to have!


What is new with BlackBerry 6.0


Aug 2010, RIM launched their new baby- BlackBerry 6.0 Torch 9800 in the US market. I am really lucky to have a chance to play with it and I have to say: Bravo!

It inherit BlackBerry's robust keypad/Track wheel and in the meantime introduced the new touchpad, which makes BlackBerry 6.0 more competitive with iPhones.

I have to say that a key success of this new phone is the screen. With resolution 360x480, torch displays smoothly and clearly.

Another nice feature is that in the Contacts, BB 6.0 provides the 'Recent Activities' you have with the contact, which informs you about your business with the person.

In addition, BB 9800 separates the SIM card holder and the battery holder, which eases the processes of configurations and installations.

Technically, I believe there is not too much change in RIM API except for the Email interfaces, which is a good piece of news for BlackBerry 3rd party developers since the old apps can be transferred to the new device fairly easily. In all, I will rate torch 9800 as 8.5/10.

Thursday, July 22, 2010

A Useful Thesis Revision Tool: TexDiff

TexDiff compares two .tex files by showing the differences in different colors. It is really helpful for tracking the changes during the process of thesis revision. Here is the instruction of installation and usage.

Step 1: Download and Unzip
(1). Download latest wdiff from the link below:
http://robmar.net/TexDiff/wdiff-0.5g.tar.gz
(2). Unzip: tar -zxvf wdiff-0.5g.tar.gz

Step 2: Compilation
(1). cd wdiff-0.5g
(2). ./configure
(3). make
(4). sudo make install

Step 3:
Copy the script texdiff to /usr/local/bin/ (Download texdiff from the link: http://robmar.net/TexDiff/texdiff)

Step 4: Usage
texdiff sample.tex sample-old.tex sample-diff.tex

Step 5: Make pdf file out of sample-diff.tex

REF: http://robmar.net/TexDiff

Tuesday, July 6, 2010

BlackBerry: Email Bug from RIM

I found this interesting bug BB has for versions before 4.6 and here it is:

There are two possible options in the menu list to delete the address in email address fields. One is "delete field" and the other one is "clear field". "clear field" does not always show up in the menu list depending on how's the address like. If the address is only selectable as ONE whole content instead of as text (which is able to be deleted character by character), the option of "clear field" won't show up.

The bug happens when users 'delete' the address using 'clear field', what RIM does is, the address won't show in the field, however when the email is sent, the address got clear-fielded is still an address to which the email sent. This bug only happens with "Reply" functions. (RIM's bug!)

Why it is not noticeable is because that when users type in the addresses, most of the cases, the addresses shown are selectable only as ONE content. I believe RIM has some secret internal method does that, which is not revealed to 3rd party developers.

Saturday, July 3, 2010

Email Structure in BlackBerry

This post will show you the structure of BlackBerry emails.

1. API: Mulipart->BodyPart
First, let's take a look at the Email API under net.rim.blackberry.api.mail.Multipart and et.rim.blackberry.api.mail.BodyPart

These two classes provide the components which consist the emails. An email is a multipart containing multiple bodyparts. It is a tree structure. Each bodypart can contain multipart as well. Therefore if you want to retrieve the information of an email, you need to do it recursively. See reference [1].

The key subclasses of BodyPart are TextBodyPart, MimeBodyPart and SupportedAttachmentBodyPart. The not so convenient part is that the method of "setContentType(String value)" in Class BodyPart is currently not supported, which means although the 3rd party apps can add bodypart to an email, it cannot sign the specific type to a bodypart (for example, 'text/html' content-type), which constraints the 3rd party apps abilities to control the emails.

[TextBodyPart]
BodyPart with 'text/plain' content-type. This class is used when creating a multipart message that includes a text/plain part.

[MimeBodyPart]
This Class represents a MIME body part.
MIME Definition:
The basic Internet e-mail transmission protocol, SMTP, supports only 7-bit ASCII characters. This effectively limits Internet email to messages which, when transmitted, include only the characters used for the English language. MIME defines mechanisms for sending other kinds of information in e-mail, including text in languages other than English using character encodings other than ASCII as well as 8-bit binary content such as files containing images, sounds, movies, and computer programs.

[SupportedAttachmentBodyPart]
Represents an attachment part that has a corresponding viewer on the handheld, including registered third-party viewers.

2. Relation with Class net.rim.blackberry.api.mail.Message
In Class Message, there is a method setContent(Object o). Object o can only be String or Multipart. Therefore, the connection between Message and Multipart is: Message.setContent(Multipart).

3. Notes:
(1). MimeBodyPart does not support signing any content (Method: setContent(Object o)). Therefore, to construct emails, TextBodyPart and SupportedAttachmentBodyPart should be used.
(2). UnsupportedAttachmentBodyPart is not publicly instantiatable.

3. References:
(1). Retrieve Email Information:
http://rim.lithium.com/t5/Java-Development/Access-HTML-email-messages/ta-p/444941
(2). Attach HTML File to Emails:
http://supportforums.blackberry.com/t5/Java-Development/Create-an-attachment/ta-p/445025

Sunday, June 27, 2010

The Seven Habits of Highly Effective People

[by Prof. Stephen Covey]

Our character is a composite of our habits. Changing habits is hard,but can be done by tremendous commitment. A (good) habit can be definedas the intersection of knowledge, skill and desire. Change is a cycleof being and seeing (visualization)

Our objective is to move progressively on a maturity continuum fromdependence to independence to interdependence. Although independence isthe current paradigm of our society, we can accomplish much more bycooperation and specialization. However, we must achieve independencebefore we can choose interdependence.

Habit 1: Be Proactive

The first and most basic habit of a highly effective person in any environment is the habit of proactivity. Being proactive means that as human beings, we are responsible for our own lives. Our behavior is a function of our decisions, not our conditions. We can subordinate feelings to values. We have the initiative and the responsibility to make things happen.

Look [at] the word responsibility-response-ability-the ability to choose your responses. Highly proactive people recognize that responsibility. They do not blame circumstances, conditions, or conditioning for their behavior. Their behavior is a product of their own conscious choice, based on values, rather than a product of their conditions, based on feeling. The opposite of proactive is reactive.The spirit of reactive people is the transfer of responsibility. Their language absolves them of responsibility. Proactive people focus their time and energy on their Circle of Influence (things they can control)in lieu of reacting to or worrying about conditions over which they have little or no control (Circle of Concern). In so doing, proactive people use positive energy to influence conditions and increase their Circle of Influence.

Habit 2: Begin with the End in Mind

To begin with the end in mind means to begin each day with a clear understanding of your desired direction and destination. By keeping that end in mind you can make certain that whatever you do on any particular day does not violate the criteria you have defined assupremely important, and that each day of your life contributes in a meaningful way to the vision you have of your life as a whole.

Begin with the end in mind is based on the principle that all things are created twice. There's a mental or first creation and a physical or second creation. The second, or physical creation, follows from the first, just as a building follows from a blueprint. In our personallives, if we do not develop our own self-awareness and become responsible for first creations, we empower other people and circumstances to shape our lives by default.

Leadershipis the first creation. Management is the second creation. Management is a bottom line focus: How can I best accomplish certain things? Leadership deals with the top line: What are the things I want to accomplish? In the words of both Peter Drucker and Warren Bennis, "Management is doing things right; leadership is doing the right things." Management is efficiency in climbing the ladder of success; leadership determines whether the ladder is leaning against the rightwall.

Habit 3: Put First Things First

What are first things? First things are those things that you, personally, find most worth doing. They move you in the right direction and help you achieve the purpose expressed in your mission statement.

Put First Things First involves organizing and managing time and events according to the personal priorities established in Habit 2(Begin with the End in Mind). Habit 2 is the first or mental creation. Habit 3, then, is the second,or physical creation. It's the day-in, day-out, moment by moment doing it.

Habit 4: Think Win-Win

In relationships and businesses, effectiveness is largely achieved through the cooperative efforts of two or more people. Marriages and other partnerships are interdependent realities, and yet people often approach these relationships with an independent mentality, which is like trying to play golf with a tennis racket-the tool isn't suited to the sport.

Most of us learn to base our self-worth on comparisons and competition. We think about succeeding in terms of someone else failing. That is, if I win, you lose. Or if you win, I lose. There is only so much pie and if you get a big piece there is less for me. People with this type of Scarcity Mentality find it difficult to share recognition and power, and to be happy for the successes of others, especially those closest to them.

Win-Win, on the other hand, is based on the paradigm that there is plenty for everybody, that one person's success is not achieved at the expense or exclusion of the success of others. Win-Win sees life as a cooperative, not a competitive arena. Win-Win is a frame of mind and heart that constantly seeks mutual benefit in all human interactions. Win-Win means that agreements or solutions are mutually beneficial and satisfying.

Habit 5: Seek First to Understand, Then to Be Understood

Communication is the most important skill in life. We spend most of our waking hours communicating. But consider this: You've spent years learning how to read and write. Years learning how to speak. But what about listening? What training or education have you had that enables you to listen so that you really, deeply understand another human being from that individuals' own frame of reference?

Seeking first to understand, or diagnosing before you prescribe, is a correct principle manifest in many areas of life. A wise doctor will diagnose before writing a prescription. A good engineer will understand the forces, the stresses at work, before designing the bridge. An effective salesperson first seeks to understand the needs of the customer before offering a product. Similarly, an effective communicator will first seek to understand another's views before seeking to be understood. Until people feel properly diagnosed they will not be open to prescriptions.

We typically seek first to be understood. Most people do not listen with the intent to understand; they listen with the intent to reply. They're either speaking or preparing to speak. They're filtering everything through their own paradigms, reading their autobiography into otherpeople's lives.

Habit 6: Synergize

Synergyis everywhere in nature. The intermingled roots of two plants growing closely together improve the quality of the soil. Two pieces of wood bonded together hold much more than the total of the weight held by each separately. The whole is greater than the sum of its parts. One plus one equals three or more.

The principle of synergy also holds true in social interactions. Two people, creatively cooperating, will be able to produce far better results than either one could alone. Synergy lets us discover jointly things that we are much less likely to discover by ourselves. It occurs when minds stimulate each other and ideas call forth ideas. I say something that stimulates your mind; you respond with an idea that stimulates mine. I share that new idea with you, and the process repeats itself and even builds.

Synergy works. It is the crowning achievement of all the previous habits. It is effectiveness in an interdependent reality-it is teamwork, team building, the development of unity and creativity with other human beings.

Valuing the differences is the essence of synergy-the mental, the emotional,the physiological differences between people. And the key to valuing those differences is to realize that all people see the world, not as it is, but as they are. When we value differences and bring different perspectives together in the spirit of mutual respect, people then feel free to seek the best possible alternative, often the Third Alternative, one that is substantially better than either of the original proposals. Finding a third alternative is not compromise, but represents a Win-win solution for both parties.

Habit 7: Sharpen the Saw

Habit 7 is the habit that makes all the others possible. Sharpen the Saw means preserving and enhancing the greatest asset you have-you. It means having a balanced, systematic program for self-renewal in the four areas of our lives: physical, mental, emotional-social, and spiritual. Without this discipline, the body becomes weak, the mind mechanical,the emotions raw, the spirit insensitive, and the person selfish.

This is the single most powerful investment we can ever make in life-investment in ourselves, in the only instrument we have with which to deal with life and to contribute. Yet when people get busy producing, or sawing, they seldom take time to Sharpen the Saw because maintenance seldom pays dramatic, immediate dividends.

This daily Private Victory is the key to the development of the Seven Habits, and it's completely within our control. Renewal is the principle and the process that empowers us to move on an upward spiral of growth and change, of continuous improvement.

Wednesday, June 16, 2010

Blackberry: Compose Email Programmatically

In a 3rd party app for BlackBerry, in some cases, you may want to launch the internal applications like Emails, SMS, AddressBook, etc. in the running process of your 3rd party app. There are two procedures I tried, in which the first one works (High Five to BlackBerry API) and the second one need to be hacked more (an interesting area to explore when you want some fun). In this article, we will make an example of getting access to Message Apps.

1. The Bright Road
BlackBerry API provides the class Invoke (in package net.rim.blackberry.api.invoke) which allows third-party applications to remotely invoke internal applications. The way how to use it is as follows:

Under Class Invoke, there is a method:
public static void invokeApplication
(int appType,applicationarguments args)
in this method, the parameter int appType has the following options:
APP_TYPE_ADDRESSBOOK
APP_TYPE_BLUETOOTH_CONFIG
APP_TYPE_CALCULATOR
APP_TYPE_CALENDAR
APP_TYPE_CAMERA
APP_TYPE_MAPS
APP_TYPE_MEMOPAD
APP_TYPE_MESSAGES
APP_TYPE_PHONE
APP_TYPE_SEARCH
APP_TYPE_TASKS

Here we use APP_TYPE_MESSAGES and an instance of MessageArguments class as parameters in this method.

What you need to do is, in your app procedure, you need to write this code in invokeLater(). Here is an example:

UiApplication.getUiApplication.invokeLater(new Runnable()
{
public void execute(){
Invoke.invokeApplication
(Invoke.APP_TYPE_MESSAGES, new MessageArguments(...));
}
});

[References]
http://www.blackberry.com/developers/docs/5.0.0api/net/rim/
blackberry/api/invoke/package-summary.html

2. The Dark but Adventurous Road
While in the Message App, write this code:
String URL = ApplicationDescriptor.currentApplicationDescriptor.
getModuleName+"?"+"saved";

ApplicationManager.getApplicationManager.launch(URL)

So far, what I know about the parameters in Message apps are 'saved' (which lead you to the saved messages folder), 'search' and 'searchinit'. I believe there are some non-revealed args like 'compose', 'reply', etc. to be found!

[Reference]
(1). ApplicationDescriptor:
http://www.blackberry.com/developers/docs/4.6.0api/net/rim/
device/api/system/ApplicationDescriptor.html
(2). ApplicationManager:
http://www.blackberry.com/developers/docs/4.6.0api/net/rim/
device/api/system/ApplicationManager.html

Hack it! Enjoy it!

Saturday, June 12, 2010

BlackBerry Emails: Detect Email Contents in Apps

In your BlackBerry applications, sometimes you may want to 'intrude' on users' emails. For example, you may want to check the users' typings of keywords in the emails to trigger some feature you designed. Here is the way to get the email content in your application.

[Procedure]
Step 1: Create ViewListenerExtended and add it to Session

You need a ViewListenerExtended to listen the actions of 'Open', 'Close', 'Compose', 'Reply' and 'Forward' Emails. Here, ViewListenerExtended is an interface, you need to override the methods. For example, if you want to detect the moment when the user is composing the email, you need to override the method 'void newMessage (MessageEvent e)'. See Step 2.

Additionally, use Session.addViewListener([the listener you created]) to add the ViewListener in to the application.

Step 2: Override the methods in ViewListenerExtended

In the methods, if you want to get to the email contents, you need to find the manager which contains the email TextField. Here are the sub-steps you need to follow:
(1). Get the Current Email Screen
//Screen Type: net.rim.device.apps.internal.blackberryemail.email.EmailEditorScreen
Screen currentScreen = UiApplication.getUiApplication().getActiveScreen()
(2). Get the VerticalFieldManager from the Email Screen
//Manager Type:
net.rim.device.apps.internal.blackberryemail.email.EmailEditorScreen
$BodyVerticalFieldManager
VerticalFieldManager bodyManager = (VerticalFieldManager) currentScreen.getField(i);
(3). Get the Email TextField from the Manager
//TextField Type: net.rim.device.api.ui.component.ActiveAutoTextEditField
emailTextField = (ActiveAutoTextEditField) bodyManager.getField(j);

Step 3: Add FieldChangeListener on Email Text Field to detect the changes in Emails
(1). Create class to implement FieldChangeListener
(2). Override method 'fieldChanged' in your class
(3). Add your class to Email Text Field you got from Step 2.

You should be able to detect the email contents and trigger your desired features now. Enjoy!



Monday, June 7, 2010

BlackBerry API: ApplicationMessageFolder

BlackBerry ApplicationMessageFolder

From BlackBerry JDE API 4.6.0, BlackBerry applications can create custom messages and folders that are visible in the message list. An application can create an ApplicationMessageFolder that contains messages that the application creates. When an application adds an ApplicationMessage to a folder, the folder appears in the message list. A BlackBerry device user can open and view the custom message in a screen of the application that contains contextual information for the message.

Key Steps of Using Application Folder:
1. Register Folder
Class: ApplicationMessageFolderRegistry
In this class, call the method:
registerFolder(long folderId, String folderName, ReadableList collection)
to register a folder. The tricky part is the ReadableList collection. Since ReadableList is an interface which is implemented by UnsortedReadableList class, so here, it is safe to use UnsortedReadableList to store the ApplicationMessages.

Also a note here is, if you store the ApplicationMessages in a Vector, here you need to call:
UnsortedReadableList.loadFrom(Vector)

2. Implement Interface ApplicationMessage
long timestamp
String contact
String subject
int type (optional)
int status (optional)

2. Add/Remove ApplicationMessage to/from ApplicationFolder
In the class of ApplicationMessageFolder, there are two useful methods:
fireElementAdded(ApplicationMessage msg)
fireElementRemoved(ApplicationMessage msg)

3. Customize MenuItems for ApplicationMessage
The class of ApplicationMenuItem ensures us to create our own menu items. What we need to do is to inherit the constructor from super(int), in which the 'int' indicates the position of the item in the menu.

Interestingly, the place to register the menu items is not the ApplicationMessageFolder or the ApplicationMessage, but ApplicationMessageFolderRegistry. The method is:
registerMessageMenuItems(int type, int status, ApplicationMenuItem [] menuItems)
Here the type and status are referred to the specific type ApplicationMessage, For example, incoming message type can have View and Reply actions while outgoing message can have View action only.

4. Run(Object o) method in ApplicationMenuItem
If you register the ApplicationMenuItem from Step 3, then the Object o in method Run(Object o) is the instance of the selected (focused) ApplicationMessage, which you can get the information from.

Good Reference:
http://rim.lithium.com/t5/Product-Management-The/
Discussion-Application-Messages-API/m-p/75783
ApplicationMenuItem:
http://www.blackberry.com/developers/docs/4.6.0api/net/rim/
blackberry/api/menuitem/ApplicationMenuItem.html
ApplicationMessageFolder:
http://www.blackberry.com/developers/docs/4.6.0api/net/rim/
blackberry/api/messagelist/ApplicationMessageFolder.html
ApplicationMessageFolderRegistry:
http://www.blackberry.com/developers/docs/4.6.0api/net/rim/
blackberry/api/messagelist/ApplicationMessageFolderRegistry.html

Saturday, June 5, 2010

Run Two BlackBerry Simulators to Send and Receive SMS

If you are using ANT tools for compiling your Blackberry apps like me, then this question may pop up to your head before: How to configure .XML file to run multiple simulators to test SMS?

This is actually really simple. In your compile file (.xml), in the section of 'run simulator' (path of one simulator), set the following parameter as:
/sms-source-port=5000 /sms-destination-port=5001 /phone-number=18881234567 /pin=0x2100000B

in the section of 'run simulator2' (path of the other simulator), set the following parameter as:
/sms-source-port=5001 /sms-destination-port=5000 /phone-number=18881234568 /pin=0x2100000B

Notice here that the two simulators (fledge.exe) should be in different directories. After these settings, you should be able to run two simulators and send SMS to each other.

However, I found that BlackBerry simulators are not very reliable on tracking the outbound SMS, so I suggest that always be ready to use real device for testing although that may take longer.

Cheers!

Friday, May 21, 2010

Fullscreen for Linux guest OS on VirtualBox

There is a common problem that happens while running Linux guest OS on VirtualBox3.1.6 using Mac OS. The problem is: the Linux guest OS is not full screened on PC. To solve this problem, you need to download guest-additions on VirtualBox website. Download the guest-additions given your version of VirtualBox from this link:
download.virtualbox.org/virtualbox

Install the iso file on the Linux guest OS and restart your guest OS after the installation. Once restarted, go to System->Preferences->Monitors. Change the monitor to 9:16. The guest screen now is full sized.


Monday, May 17, 2010

How to disable CheckboxField

Lately, I came across the question: How to disable CheckboxField in BlackBerry JDE. Here is the solution:

Package net.rim.device.api.ui.component


CheckboxField.setEditable(false)!!

There we go~

Saturday, May 15, 2010

Weird Problem of Hyperref and Includegraphics

Lately, I came across a weird problem when writing my master thesis, which is the use of hyperref and \includegraphics.

The problem is described as followings:
When I use the package of hyperref and include .eps figures in my sub-files under the master.tex file, Latex gives me the error: File "filename" not found. Apparently, the .eps files I included are under the same directory as master.tex. So that won't be the reason why Latex could not find .eps.

The reason is that pdftex won't recognize .eps. The solution is the usage of package "epstopdf". Download the package (.zip file) from http://www.ctan.org/tex-archive/support/epstopdf/

Unzip it and run in terminal "epstopdf filename.eps" under the directory of .eps files and the corresponding .pdf files will be generated. In your sub-file, instead of include .eps files, include .pdf files. The latex will then run perfectly.

Hope this helps!

Saturday, May 8, 2010

A Useful Spell-Check Tool: Ispell

Ispell is a spell-checking program available for many Unix implementations. I use this program for spell-checking my Master thesis. Now I will show you how to install ispell in Unix/Linux and how to use it, more importantly, how useful it is.

Installation:
Step 1: Download Ispell from http://www.lasr.cs.ucla.edu/geoff/ispell.html
Step 2: gunzip ispell-3.3.xx.tar.gz
Step 3: tar -xvf ispell-3.3.xx.tar
Step 4: cd ispell-3.3.xx
Step 5: Copy one of the sample local.h files to local.h:
cp local.h.bsd local.h
cp local.h.cygwin local.h
cp local.h.linux local.h
cp local.h.macos local.h
cp local.h.solaris local.h
or
cp local.h.generic local.h
Step 6:
If you used the generic local.h file and are using a
USG-style system (Linux, IRIX, HP-UX, Solaris, etc):
Edit local.h and change:
#undef USG
to:
#define USG
Step 7: make all
If you get compile errors in term.c, do step 6 (or undo it
if you already did it).
Step 8: make install

Note:
1. Before installation, you may need to install the compiling tools. If you get the error at Step 7 as: 'make: yacc: Command not found', you will need to install bison, which is a parser generator for GNU Project. Write command like: apt-get install bison
2. Since local.h is a system Read-Only file. You may need to change the permission of local.h in order to edit the file at Step 6. The command for changing permission is:
chmod a=rwx file

(turns on read, write, and execute permissions, and turns off the hidden, archive, and system attributes.)

How to use ispell after Installation?

To use it, at your Unix/Linux shell prompt, enter: ispell filename

Replace filename with the name of the file you wish to check.

For my case, I use .tex file for spell-checking and it works perfectly! It saves a lot of time on the writing! Enjoy!

Friday, April 23, 2010

Re-install Ubuntu and Kile

Last week, I did some changes to my Ubuntu 9.04 OS (Installed some packages which affect the system's performances.) and Ubuntu began to act wierdly. So I decide to re-install Ubuntu and share my installation procedure here.

Step 1: In Windows system, insert the Ubuntu 9.04 installation CD (You can download from http://www.ubuntu.com/getubuntu/download).

Step 2: Restart the PC and choose Ubuntu system to get in.

Step 3: WAIT for installing (Fairly easy, just find sth to do while waiting! lol)

Step 4: Install any application on Ubuntu and you are good to go.

However, I am right now using Latex for thesis writing. So I need to install Kile. I found the installation of Kile is a little tricky, especially its configuration part. So here is the procedure I install and configure Kile:

Step 1: Applications->Add/Remove->Search for "Kile" application

Step 2: Install Kile and wait for its running, also after the installation, the system will run "Update Manager" automatically. This step will take a while, for like 30 minutes.

Step 3: Restart Ubuntu, your Kile is installed

Step 4: Get the nessasary packages for Latex
Open terminal and type in:
sudo apt-get install latex-beamer texlive texlive-fonts-extra
texlive-latex-recommended texlive-pstricks texlive-science
texlive-latex-extra texlive-publishers texlive-font-utils xfig ipe
kile texlive-math-extra texlive-generic-extra texlive-bibtex-extra

Step 5: Open Kile and Configure it
1. Settings->Configure Kile->Build->Select tools->ViewPS
add new configuration "evince"
change the command to "evince"
2. Settings->Configure Kile->Build->Select tools->ViewPDF
add new configuration "evince"
change the command to "evince"
3.Settings->Configure Kile->Build->Select tools->QuickBuild
Select "Latex+DVItoPS+PStoPDF+ViewPDF"

You are good to go!!!

Friday, April 16, 2010

How to install Adobe Flash Player 10 on Ubuntu Linux

Here is a simply way operated on terminal to install Flash 10:

Step 1: Download getlibs from http://ubuntuforums.org/showthread.php?t=474790 and install_flsh_player_10_linux.tar.gz from Adobe website
Note: save them on Desktop

Step 2: Remove old plugins

sudo apt-get -y purge nspluginwrapper
sudo apt-get -y purge mozilla-plugin-gnash
sudo apt-get -y purge swfdec-mozilla
sudo rm -rfd /usr/lib/nspluginwrapper
sudo rm -f /usr/lib/firefox-addons/plugins/libflashplayer.so
sudo rm -f /usr/lib/mozilla/plugins/flashplugin-alternative.so
sudo apt-get purge flashplugin-nonfree
sudo rm -f /usr/lib/firefox-addons/plugins/libflashplayer.so
sudo rm -f
/usr/lib/nspluginwrapper/plugins/npwrapper.libflashplayer.so

Step 3: Install getlibs
cd ~/Desktop
sudo apt-get -y install nspluginwrapper
sudo dpkg -i getlibs-all.deb
sudo getlibs -p libcurl3
sudo getlibs -p libnss3-1d
sudo getlibs -p libnspr4-0d

Step 4: Install Flash plugin
tar -xzvf install_flash_player_10_linux.tar.gz
sudo mv -f ~/Desktop/libflashplayer.so
/usr/lib/firefox-addons/plugins/

Step 5: Wrap and Link
sudo nspluginwrapper -i /usr/lib/firefox-addons/plugins/libflashplayer.so
sudo ln -s /usr/lib/nspluginwrapper/plugins/npwrapper.libflashplayer.so
/usr/lib/firefox-addons/plugins/

Step 6: Restart browser and you are good to go!

Reference: http://ubuntuforums.org/showthread.php?t=772490

Thursday, April 15, 2010

First blog

This is my first technical blog. Things get a little crazy but fun lately. I got my new job at Fixmo Inc. in Toronto and I cannot wait to join the team and explore the awesome area of software developing!

Good luck Catherine!