Write a Drawing App “myArtwork” for Blackberry with Social Network Sharing Capability

Introduction:

With Mobile Processingg one can write J2ME apps that work in Blackberry phones. Sometime ago, I compiled a simple code that I found on the web that without any changes works perfectly in my Blackberry Bold 9900. The compiled app utilises the touchscreen on my phone as a method for drawing images. My grandchild loves to draw using this app, but his artworks were not being saved or shared until recently, when I added an app to my Blackberry that allows me to save the drawings, and to share them.

Objectives:

Write code for a drawing app named myArtwork for Blackberry smartphones with touchscreen, such as Blackberry Bold 9900, and add Social Networking sharing capability. The resulting app must have basic look and feel of a professional Blackberry app.

Requirements:

Blackberry Bold 9900, or other Blackberry smartphone with touchscreen
Mobile Processing IDE installed in PC with Java SDK and Wireless Tool Kit (WTK)
Blackberry Desktop Software

Installing Mobile Processing IDE and “Hello World” app

You need to Mobile Processing, Windows Version with Java and WTK download Mobile Processing  for building Java mobile phone applications. Note the location of the installation. In our case we unzipped into root of our C:\ drive

There is no installation just run Mobile Processing by double clicking the icon in your PCs folder:

There will be an error warning when checking for updates. The Mobile Processing project has been stale for a while, so there are no updates:

Click Ok.

Choose Preferences from the main dropdown menu:

In the Preferences dialog box, go to the Mobile tab, and enter the location of the WTK:

Choose CLDC version 1.1 and MIDP version 2.0. Click Ok.

We are now ready to write our first app “Hello World”. Cut and paste or write the following code in the sketch workspace of Mobile Processing:

PFont font;

  void setup()
  {
    font = loadFont("SansSerif.bold-24.mvlw"); 
    textFont(font);
  }

  void draw()
  {
    text("Hello World",10,25);
  }

Save the project with name Hello with dropdown main menu File -> Save as.

NOTE: All projects are saved in your PC’s My documents -> MobileProcessing.

Now, before simulating, we need to load the font into the project directory. Do Tools -> Create Font. The following configuration window will open:

We will choose SansSerif.bold-24.mvlw and include A-Z and a-z characters. If we do not do this procedure our emulator will throw Java exception error. The emulator does not how to display fonts.

We will now simulate this first application. In the dropdown main menu run the simulation with Sketch -> Build and Run. The default color emulator will open:

We will click the right button Launch in the emulator. The result will be as follows:

Check the folder in your PC in My documents -> Mobile Processing -> Hello and you will see the directories that have been created:

Open the data folder, and you will see our font file:

Now open the MIDlet folder, and you will see Hello.jad, Hello.jar and Hello.java files:

The files that Blackberry needs are Hello.jad and Hello.jar. Hello.java contains Java source code. We will not install these files in our Blackberry, and proceed with installing our drawing app “myArtwork“.

In the main dropdown menu choose File -> New and cut and paste the following code, or write it in  Mobile Processing sketch workspace:

int x;
int y;
int lastX;
int lastY;
boolean screenTouch;

void setup() {
softkey("Wipe");

x = width / 2;
y = height / 2;

framerate(15);
background(0);
stroke(255);
fill(0);
stroke(0);
strokeWeight(3);
colorMode(HSB);
}

void draw() {
if(screenTouch){

lastX = x;
lastY = y;
fill(random(0,255), 255, 255);
triangle(x + random(-20, +20), y + random(-20, +20),
x + random(-20, +20), y + random(-20, +20),
x + random(-20, +20), y + random(-20, +20));

}
}

void pointerDragged(){

x=pointerX;
y=pointerY;
redraw();
}

void pointerPressed(){
x = pointerX;
y = pointerY;
lastX = x;
lastY = y;
screenTouch = true;
}

void pointerReleased(){
screenTouch = false;
}

void softkeyPressed(String label) {
if (label.equals("Wipe")) {
background(0);
}
}

You will now save the project with the name myArtwork with  File->Save As in the main dropdown menu.

Before proceeding we will create an Icon for our App. It needs to be 62×62 pixels.  You can download here an icon we have designed, together with pde file of above code. The file is hosted by BitbucketBitbucket that offers unlimited public and private repositories and it is free for small teams. In your PC’s My Documents -> MobileProcessing ->myArtwork folder create a data folder and paste this icon image file icon.png into it.

Export as MIDlet with File-> Export MIDlet:

The MIDlet will be created and your PC´s MIDlet folder will open automatically to show myArtwork.jad, myArtwork.jar and myArtwork.java files:

Note: If you care to check myArtwork folder you will also see a new folder proguard. ProGuard is included in Mobile Processing to make the apps smaller and more efficient jar files. We will not use the jar file in this folder.

We are now ready to copy myArtwrok.jad and myArtwork.jar into the Blackberry.

After connecting your Blackberry to the PC with USB cable run Blackberry Desktop software and choose Files:

Click the Start button. You will see the next screen:

In your PCs folder MIDlet folder select myArtwork.jad and myArtwork.jar files:

And with right click of your mouse button Copy these files, and paste them into the Blackberry Desktop folder you have just opened:

Both files will be now in your Blackberry phone’s documents folder.

NOTE: If you are too lazy to write code you can  install the jad file found here into your Blackberry as shown. Note the jad and jar files are hosted at Bitbucket, a free and unlimited public and private repositories hosting site. The jad file will download from Bitbucket the required jar file (provided your Blackberry is connected to Internet) and install it following same procedures as shown below.

Now disconnect the USB cable between your Blackberry and your PC. In your Blackberry’s go to All group of folders and choose the Applications folder:

Open the folder, and select Files folder:

Open the Files folder and navigate to the documents folder. In my Blackberry I found it in File Folders -> Device -> home -> user. In documents folder within user folder, you will find myArtwork.jad and myArtwork.jar  (in case you have not downloaded the jad file as mentioned above in which case jar file will be downloaded from Web). Select myArtwork.jad:

Click myArtwork.jad and you will seee the following screen:

Click Download button and our app will start to be installed. You will get next the following warning window:

Normally you would press button No, or at least you ought to do so. We will click Yes button, and proceed with the installation. Eventually without any errors, you will get the following reassuring pop up window in your Blackberry:

You can Run immediately the app. But we will wait, and check first our All group of folders to see what appears there. You will see reassuringly see myArtwork icon:

We are now ready to test our app myArtwork for Blackberry.

Testing  our App

Click myArtwork icon and a black background empty screen will be shown in your Blackberry phone:

Touch the screen with your finger, and draw something similar to the following:

You can Wipe this drawing pressing the Menu button in your Blackberry:

You will see the option to Wipe or Exit:

If you use Wipe option the screen will be cleared. This is all that this code does. But, we will not stop here, and we will add to our app saving and sharing capabilities.

Blackberry App World offers a free software that does exactly what we want and integrates into other apps. It is called Screen Grabber. It is free, no watermark , no ads, courtesy of JaredCo.  This is a totally flexible screen capture app that lets you share your Blackberry screenshots with anyone. It is simple and useful. It has BBM, SMS, Email, Twitter and Facebook integration. It also creates in your Blackberry’s Media/Pictures folder, a new  folder called Screen_Grabs where the screenshots you have chosen  to share will be saved.

Install Jaredco‘s Screen Grabber in your Blackberry. After installing Screen Grabber and restarting your Blackberry, you will see in your Balckberry’s All group folder the Screen Grabber icon:

Now if you Run our app myArtwork, you will see the option to capture the screen if you click the Menu button in your Blackberry:

Click Screen Grabber and the following option will be opened:

For testing purpose, we will click BBM button  and the following options will be shown:

We select a contact, and the following will be shown:

You can add a comment and Send. That is it! Your first artwork has gone to your contact.The Screen Grabber app will return to the first screen. To exit, if you do not want to use other sharing features, you can press the Back menu in your Blackberry:

And you will return to the drawing you have just made. With Menu button in your Blackberry you can use Exit option to leave myArtwork app.

You can check in your BBM whether the image has been sent. It will be there for the contact you have chosen to send to.

Final words

I am a Blackberry fan. My phone is a workhorse I am using for all my business and other activities. I love the interconnection among apps, easy switching among apps, and many more features. The added most recent Social Network capabilities in apps is a plus for those that understand the value of such features. If you ask me whether I am ready to switch to iPhone or any other hype driven smartphones, I will readily answer with “no, thank you!”.

My first app for Blackberry was written to control a 8051 microcontroller-based robot (I adapted from my original Nokia N95 app). I published my work here in this blog.

I have enjoyed doing myArtwork app, and specially as it is made for my Blackberry Bold 9900. My grandchild loves myArtwork. He is an artist in making, but I am suspect!

I hope Research in Motion (RIM) will continue to exist, and come out of its actual financial woes, and more developpers will write apps for Blackberry devices.

Acknowledgments

A special thank you is due to Addy B for sharing drawing code for Motorola, written in Mobile Processing IDE.

Conclusions

We have written a drawing app for Blackberry and shown that it works as expected, and that one can easily add to it sharing for Social Network capabilities . Instead of Mobile Processing we could have written our app in Eclipse.

It is not Rocket Science to write apps for Blackberry, surely!

Advertisements

About Tayeb

Electronics engineer, part-time webmaster and owner of "Aliatron", a tech-oriented company registered in Portugal and Mozambique.
This entry was posted in Mobile Apps, Programming and tagged , , , , , , . Bookmark the permalink.

5 Responses to Write a Drawing App “myArtwork” for Blackberry with Social Network Sharing Capability

  1. Pingback: Write a Drawing App “myArtwork” for Blackberry with Social Network ... - Monitor Urbano | Monitor Urbano

  2. Pingback: Write a Drawing App “myArtwork” for Blackberry with Social Network … | 99Covers Blog

  3. Pingback: Write drawing app for Blackberry and add sharing in Social Networks - BlackBerry Forums at CrackBerry.com

  4. Pingback: Write a Drawing App “myArtwork” for Blackberry with Social Network …

  5. Pingback: Remote Viewing of Temperature with FRDM-KL25Z and TCN75A on Basic I/O Shield | RedAcacia

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s