Skip to content


Five Things that BlackBerry does better than iPhone

Another op-ed piece (don’t worry, I’ll get to more concrete stuff again soon).

I’ll start with a confession - I’ve been using an iPhone instead of a BlackBerry for the past little while, because my company has been focused on developing some iPhone products. The iPhone is a phenomenal device, and certainly has to have RIM worried, but having used both devices now, there are definitely a lot of things that the BlackBerry does way better. I’ve picked 5 things that I really really miss about using a BlackBerry (and probably they’ll be the reasons that I go back to BlackBerry for day-to-day use soon). I think most of these are known to most people, but I’ve omitted a few things that are commonly thought of as BlackBerry’s advantages - I’ll explain why at the end of the article.

Continued…

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google

Posted in opinion. Tagged with , , .

BlackBerry JDE Plug-In for Eclipse 1.1 Beta - Part 1

The BlackBerry Developer Conference (Nov 9-12 in San Francisco) contained a lot of new announcements - among the bigger ones (Payment Services, Advertising Services, etc) one of the most exciting - from my point of view - may have been overlooked a bit. A new version of the BlackBery JDE Plug-In for Eclipse - v1.1 - as of this writing in Beta.

Being a huge fan of Eclipse for BlackBerry development - despite numerous problems - I was eager to try out this version. I discovered a few interesting quirks, but overall a much more solid development experience.

Continued…

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google

Posted in 1.1, Uncategorized, basics, eclipse. Tagged with , , , , , .

GPS Class

I just started coding in J2ME just under a year ago, when I wanted to build a GPS Golf application.  After learning the wrong way to do it, I found a GPS class that I have changed a bit to suit my needs.  The following is a simple GPS class that will run on its own thread in the background, and you can use the get methods to get any of the GPS data that is avaliable.  The way I use the Class is with a Timer Task, but I’m sure it could be changed to use a lister if that is what you are looking.  Remember It’s code, you can do anything! :)

Here is my GPS class that I use:

import javax.microedition.location.Location;
import javax.microedition.location.LocationException;
import javax.microedition.location.LocationListener;
import javax.microedition.location.LocationProvider;
import javax.microedition.location.QualifiedCoordinates;
/**
 *
 * @author Justin
 *
 */
public class GPS extends Thread {

	private double latitude;
	private double longitude;
	private String satCountStr;
	private float accuracy;
	private double heading;
	private double altitude;
	private double speed;

	private int interval = 1; // time in seconds to get new gps data

	/**
	 * This will start the GPS
	 */
	public GPS() {
		// Start getting GPS data
		if (currentLocation()) {
			// This is going to start to try and get me some data!
		}
	}

	private boolean currentLocation() {
		boolean retval = true;
		try {
			LocationProvider lp = LocationProvider.getInstance(null);
			if (lp != null) {
				lp.setLocationListener(new LocationListenerImpl(), interval, 1, 1);
			} else {
				// GPS is not supported, that sucks!
				// Here you may want to use UiApplication.getUiApplication() and post a Dialog box saying that it does not work
				retval = false;
			}
		} catch (LocationException e) {
			System.out.println("Error: " + e.toString());
		}

		return retval;
	}

	private class LocationListenerImpl implements LocationListener {
		public void locationUpdated(LocationProvider provider, Location location) {
			if (location.isValid()) {
				heading = location.getCourse();
				longitude = location.getQualifiedCoordinates().getLongitude();
				latitude = location.getQualifiedCoordinates().getLatitude();
				altitude = location.getQualifiedCoordinates().getAltitude();
				speed = location.getSpeed();

				// This is to get the Number of Satellites
				String NMEA_MIME = "application/X-jsr179-location-nmea";
				satCountStr = location.getExtraInfo("satellites");
				if (satCountStr == null) {
					satCountStr = location.getExtraInfo(NMEA_MIME);
				}

				// this is to get the accuracy of the GPS Cords
				QualifiedCoordinates qc = location.getQualifiedCoordinates();
				accuracy = qc.getHorizontalAccuracy();
			}
		}

		public void providerStateChanged(LocationProvider provider, int newState) {
			// no-op
		}
	}

	/**
	 * Returns the terminal's course made good in degrees relative to true north.
	 * The value is always in the range (0.0,360.0) degrees.
	 *
	 * @return double
	 */
	public double getHeading() {
		return heading;
	}

	/**
	 * Returns the altitude component of this coordinate.
	 * Altitude is defined to mean height above the WGS84 reference ellipsoid.
	 * 0.0 means a location at the ellipsoid surface, negative values mean the
	 * location is below the ellipsoid surface, Float.NaN that no altitude is
	 * available.
	 *
	 * @return double
	 */
	public double getAltitude() {
		return altitude;
	}

	/**
	 * Get the number of satellites that you are currently connected to
	 *
	 * @return String
	 */
	public String getSatCount() {
		return satCountStr;
	}

	/**
	 * Get the Accuracy of your current GPS location
	 *
	 * @return float
	 */
	public float getAccuracy() {
		return accuracy;
	}

	/**
	 * Returns the latitude component of this coordinate.
	 *
	 * Positive values indicate northern latitude and negative values southern latitude.
	 *
	 * @return double
	 */
	public double getLatitude() {
		return latitude;
	}

	/**
	 * Returns the longitude component of this coordinate.
	 *
	 * Positive values indicate eastern longitude and negative values western longitude.
	 *
	 * @return double
	 */
	public double getLongitude() {
		return longitude;
	}

	/**
	 * Get your current ground speed in meters per second (m/s) at the time of measurement
	 *
	 * @return double
	 */
	public double getSpeed() {
		return speed;
	}
}

Once you have added the GPS class to your project you can then use it the following way:

GPS gps = new GPS();
gps.start();

I like to start my GPS class as soon as my application starts up because it can take anywhere between 2 to 10 minutes for the BlackBerry to get a GPS lock. It will depend where they are. If you are outside with a clear view of the sky it works best (line of sight). Once you have the GPS option you can just pass the object between your screens or, if you want or you can just start a new GPS object, and if the first GPS object already has a lock then the new GPS class will get a lock right away.

Like I said before I like to use a Timer Task to update my screen UI. The reason for this is that it give me more options. This way I can tell the applciation how often I want to update the screen with the new data. I do it the following way:

import java.util.Timer;
import java.util.TimerTask;
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.container.MainScreen;

public class GPSScreen extends MainScreen {
	GPS gps;
	Timer timer;
	RichTextField txtGPS;

	public GPSScreen(){
		gps = new GPS();
		timer = new Timer();
		timer.schedule(new CheckGPS(), 100, 1000);  //check for GPS every 1 second;

		String textGPS = "";
		txtGPS = new RichTextField(textGPS, RichTextField.NON_FOCUSABLE);

		add(txtGPS);

	}
	public boolean onClose()
	{
		timer.cancel();  //cleanup
		this.close();
		return true;
	}

	public class CheckGPS extends TimerTask{
		public CheckGPS() {
		}

		public void run() {
			double lat;
			double lng;
			lat = 0;
			lng = 0;

			lat = gps.getLatitude();
			lng = gps.getLongitude();

			if (lat != 0.0 & lng != 0.0) {
				synchronized (MyApplicationName.getEventLock()) {
					double acc = gps.getAccuracy();
					txtGPS.setText(lat + ", " + lng + " (" + gps.getSatCount() + ") (" + (int) acc + ")");
				}			

			}
			else
			{
				String thetxt = txtGPS.getText();
				synchronized (MyApplicationName.getEventLock()) {
					if(thetxt.length() > 10)
						if(thetxt.length() > 25)
							txtGPS.setText("Waiting for GPS.");
						else
							txtGPS.setText(thetxt + ".");
					else
						txtGPS.setText("Waiting for GPS.");
				}
			}
		}
	}
}

Here is a screen shot from my simulator:

GPSScreen in use with the GPS class

GPSScreen in use with the GPS class

So within my Timer Task that runs once every second I use my get methods to get the Lat and the Long from GPS and I check to see if they are set. You could also add some more logic into the GPS class with a boolean flag to see if we have a GPS lock before you even get the values.

This GPS class will work with (almost) any BlackBerry Smartphone device that is GPS enabled. It will not work for Verizon 8130, 8330, and 8830, but it does work with the Verizon Storm and Tour. This Class will work with any 4.2 device that has a Bluetooth GPS receiver, including the Verizon devices listed above (8130, 8330, and 8830) as a workaround to the Verizon GPS lock-down.

Here is some related GPS information:

Enjoy!

Justin

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google

Posted in basics, components, gps. Tagged with , , , , , .

Welcome Justin!

I’ve convinced someone else to write a post about GPS for Thinking BlackBerry!

Justin is a BlackBerry developer (among other platforms) and has created a couple of great BlackBerry applications, including BBGPSGolf, a great free golf application for BlackBerry that uses the device’s GPS to show a map and give you information about golf courses (distances to the green, etc) on your device while you’re on the course.

Anyway, he graciously offered to share some of his GPS expertise with us so read his post and if he gets enough good feedback maybe he’ll share some more of his BlackBerry development expertise!

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google

Posted in Uncategorized.

Non Coding Related (Mostly)

I’ve been meaning to write this post for a while, but it sounds too much like making excuses. Well, in a way it is.

Faithful readers may have noticed how the frequency of my posts has dropped off rather sharply in the last few months. There are two reasons for this.

First, I’ve started a company called Zeebu Mobile doing - what else? - BlackBerry application development, specifically in educational and early childhood applications. We just released our first product, Baby GO!, which is free and runs on all BlackBerry devices with OS 4.2.0 and higher.

Second, I’ve been writing a book called Beginning BlackBerry Development which will be published (hopefully!) in late October.

No worries about the book - it doesn’t restrict me in any way from posting, except that it’s taking up a lot of my time. I’m still free to write about the topics I cover in the book on this blog.

The really good news for anyone reading this, is there are a couple of new things coming along soon that should result in more posts to the blog in the very near future. So bear with me and stay tuned! Thanks.

-Anthony

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google

Posted in Uncategorized.

BlackBerry Arithmetic Performance

Playing with some animation for a new BlackBerry product (see next post) and wondering about performance of double/float/Fixed32 arithmetic I came across this post on Blurry Words, which is exactly what I was looking for.

Basically performance depends on the type of arithmetical operation you’re doing (though double is always slowest, usually by a wide margin). For addition and subtraction, Fixed32 is faster, for multiplication and division float wins out. Some sample results:

BlackBerry Bold

Variable Type Add/Sub (ms) Mult (ms) Div (ms)
Fixed32 153 597 776
float 317 242 550
double 514 366 1931
long 114 117 225
int 96 90 114
short 102 102 125
byte 104 107 127

The net.rim.device.api.math.Fixed32 class is interesting - I’ve mostly used it in scaling EncodedImages. It packs a fixed decimal representation of a number into a 32 bit int datatype, using the leftmost 16 bits for the whole part, and the rightmost 16 bits for the fractional part. This has the result that the normal + and - operators work as expected, but multiply and divide are handled through special functions.

Though I’ve gotta disagree with the poster’s conclusions - Fixed32 is not strictly legacy, it’s only been available since OS 4.0, at which time float and double were available on BlackBerry.

There’s a lot more interesting discussion and more results for different devices just in this post, so I encourage to read the original!

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google

Posted in Uncategorized.

Sibling CODs - or How to Make Your App Install Over The Air

It’s been way too long since I wrote a post - interesting aside for bloggers: don’t get out of the rhythm, it’s incredibly hard to start back up again once it’s no longer part of your daily routine. Anyway, I’ve been busy (more on that later) but due to demand am now committed to start posting again, and it was a recent comment on an earlier post that gave me the idea for this one: short but sweet and valuable to all aspiring BlackBerry app developers.
Continued…

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google

Posted in Uncategorized.

What would you like to know about BlackBerry development?

I’ve gotten several good ideas for posts from the readers of this blog, so I’ve decided (based on a user comment) to put a sticky post up solely for the purpose of soliciting new post ideas.

So here it is: What would you like to see me write about? Any area of BlackBerry development is fair game. Leave comments below and I’ll pick the ones that are most in demand or that I think would make the best posts.

I’ll start off with some ideas:

  • BlackBerry networking - TCP/BIS/BES - what are they and how do you use them?
  • Resource bundles and localization
  • Debugging with the Eclipse debugger
  • Debugging your application on a real BlackBerry using the Eclipse debugger (or the JDE debugger)

Thanks!

Anthony

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google

Posted in Uncategorized.

A suggestion on how to fix the BlackBerry JDE Eclipse Plugin

A while ago, I wrote a post about setting up the JDE Eclipse Plugin, which extolled the virtues of the JDE Plugin for Eclipse. As I said then, I’d been using Eclipse for BlackBerry development for years (using custom Ant scripts, etc) but the official RIM Plugin for Eclipse was relatively new. I’ve now used the plugin for a few more months, and, while I still believe it’s the best way to develop BlackBerry applications, I’m also less in love with it than I was. Basically, the JDE’s built-in editor is still pretty hopeless, lacking what should be considered rudimentary features at this point, and so even with its quirks, it’s better to work in Eclipse.

But - there are some pretty significant quirks.

Big ones that I haven’t found good workarounds for include:
- src is the only ‘officially’ recognized source folder. I don’t know why or how RIM overrode this, but the bug is: You can set any folder to a source folder (as with any Eclipse project) and things will work, until you shut down and restart Eclipse, at which point only src will still be a source folder. The workaround is to manually re-add your source folders to the build path each time you restart Eclipse (which may not be that often) which works, but is obviously not great (read: very, very annoying)
- you can’t add 3rd party .jar files to a BlackBerry project in Eclipse (mentioned here). The only way around this is to use source files (for KXML/KXML-RPC, the most common one I’ve seen, source is thankfully available, though you have to dig)
- importing from a .jdw (BlackBerry JDE Workspace) file is broken - you get a bunch of symbolic links to your files in your Eclipse project. Just means you have to rebuild your project, making the Import feature pretty useless.

There are others, but you get the idea

Don’t let these scare you away (unless one really is a showstopper) - Eclipse is still the best way to go.

Now, here’s my suggestion for fixing things:

Open source the BlackBerry JDE Plugin for Eclipse!

That’s right, open source it. Please. Listen, RIM, if your’e reading: There’s a big and growing community of BlackBerry developers yearning for a better way to build BlackBerry apps. And you have very strong competition in the form of iPhone and Android, both of which have stunning development environments. They both came to the game late, and they’ve leapfrogged you, and you’re falling further behind.

You don’t have to make it GPL or even LGPL. Something less idealistic would be fine. You don’t even have to open-source parts of the Plugin that we know work (like RAPC). Just as much as you can, as soon as you can, so some enterprising BlackBerry developer out there with good knowledge of the Eclipse platform (and believe me, there are enough) can figure out what’s wrong and FIX IT.

Thank you!

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google

Posted in eclipse. Tagged with , , .

Making a Custom Screen, Vertically Scrolling and more

It’s been a couple of weeks since my last post - I’ve been busy with a couple of projects (hopefully more on one or two of those eventually), and there are a few posts I have in the works, but they’re all long enough that I don’t have the energy to finish them. Luckily I got inspiration for a new post from this reader comment! It’s fairly simple, but led to me finding a small bug in my GridLayoutManager, and does illustrate some interesting things about BlackBerry layout managers and screens, so read on (and keep those comments coming!):

Continued…

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google

Posted in components, ui. Tagged with , , .