<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Thinking BlackBerry</title>
	
	<link>http://www.thinkingblackberry.com</link>
	<description>A gentle introduction to BlackBerry development</description>
	<pubDate>Wed, 20 Jan 2010 14:03:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/ThinkingBlackberry" /><feedburner:info uri="thinkingblackberry" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Five Things that BlackBerry does better than iPhone</title>
		<link>http://feedproxy.google.com/~r/ThinkingBlackberry/~3/X4YdxBEd_Tg/274</link>
		<comments>http://www.thinkingblackberry.com/archives/274#comments</comments>
		<pubDate>Wed, 20 Jan 2010 05:29:08 +0000</pubDate>
		<dc:creator>anthony</dc:creator>
		
		<category><![CDATA[opinion]]></category>

		<category><![CDATA[blackberry]]></category>

		<category><![CDATA[iphone]]></category>

		<guid isPermaLink="false">http://www.thinkingblackberry.com/?p=274</guid>
		<description><![CDATA[Another op-ed piece (don&#8217;t worry, I&#8217;ll get to more concrete stuff again soon).
I&#8217;ll start with a confession - I&#8217;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 [...]]]></description>
			<content:encoded><![CDATA[<p>Another op-ed piece (don&#8217;t worry, I&#8217;ll get to more concrete stuff again soon).</p>
<p>I&#8217;ll start with a confession - I&#8217;ve been using an iPhone instead of a BlackBerry for the past little while, because <a href="http://www.zeebu.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.zeebu.com');">my company</a> 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&#8217;ve picked 5 things that I really <em>really</em> miss about using a BlackBerry (and probably they&#8217;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&#8217;ve omitted a few things that are commonly thought of as BlackBerry&#8217;s advantages - I&#8217;ll explain why at the end of the article.</p>
<p><span id="more-274"></span></p>
<h3>1.  Push Email</h3>
<p>Yes, iPhone does push email too, but BlackBerry does it better.  You can sync an Exchange account with your iPhone and get push email, but only one.  I&#8217;ve always got a minimum of 2 accounts I want to keep up to date with - currently 5 - but even with 2, I&#8217;d have to choose a preferred one (or consolidate everything through one account, which isn&#8217;t an option).</p>
<p><img src="http://www.thinkingblackberry.com/wp-content/uploads/clouds.png" alt="clouds" title="clouds" width="571" height="303" class="alignnone size-full wp-image-276" /><br />
And sure you can get 3rd party solutions for iPhone that use the push notification functionality to tell you about new email - I&#8217;m using one called Mail Notifier - but it&#8217;s not the same thing.  I get notified of a new email, which includes a snippet of the text, but I then have to go into the Mail app, select the account, wait for it to connect and download, and then click the email.  With BlackBerry the email is already there, and I can even set the device to pop the email client up on new emails.  No going through the list of accounts, remembering which one the email came from, speaking of which&#8230;</p>
<h3>2.  Multiple Email Accounts</h3>
<p>Handled beautifully by BlackBerry.  I can view the inbox for each account separately, but never do.  BlackBerry lets me view all emails from all accounts in one place, and keeps track so that when I reply it comes from the right account.</p>
<p>There&#8217;s more!  I can have separate signatures for each account (really really irritating missing feature on iPhone), and when I compose a new email to a contact, the BlackBerry usually guesses correctly which account I want to send it from - probably based on some analysis of past correspondence.</p>
<p>With iPhone I have to click on mail, click on the account, click on inbox.  And then back out through those screens to check my next account.  Just enough extra clicks to be annoying, and I can&#8217;t see all my emails from all accounts at the same time.</p>
<p>Email is part of BlackBerry&#8217;s DNA - it&#8217;s initial killer app was email, and the business and devices were built around that, and it shows.</p>
<h3>3.  The Keyboard</h3>
<p><img src="http://www.thinkingblackberry.com/wp-content/uploads/keyboards.png" alt="keyboards" title="keyboards" width="420" height="200" class="alignnone size-full wp-image-277" /><br />
While the iPhone&#8217;s virtual keyboard is a pretty phenomenal piece of engineering, and amazingly usable (more than I can say for BlackBerry&#8217;s <a href="http://na.blackberry.com/eng/devices/blackberrystorm/" onclick="javascript:pageTracker._trackPageview('/outbound/article/na.blackberry.com');">attempt at the same thing</a> - but that&#8217;s a post for another day), nothing on any mobile device has yet delivered the same instant easy usability that the physical BlackBerry keyboard has.  Not much more to say than that, but I will add that I&#8217;ve noticed a change in my behavior with regards to email, and I think it&#8217;s largely because of the lack of keyboard on an iPhone:</p>
<p>The iPhone keyboard, even being slightly more difficult to use than BlackBerry&#8217;s real keyboard, has put enough of a barrier in place (at least in my head) that I reply to a lot less email, and so get a lot less done away from the desktop.  Meaning my response time has gone down, and there&#8217;s always more email waiting for me to reply to when I do get to a desktop.</p>
<h3>4.  The notification light</h3>
<p>Yes, this thing:</p>
<p><img src="http://www.thinkingblackberry.com/wp-content/uploads/bbled.jpg" alt="bbled" title="bbled" width="500" height="296" class="alignnone size-full wp-image-275" /></p>
<p>Amazingly simple, but I really miss it.  I&#8217;m used to glancing down at my device to see if anything new had come in - or looking at it lying on a table.  iPhone doesn&#8217;t have an LED indicator for new email, so I can&#8217;t do that.  Again, email is part of the core DNA of BlackBerry, all the way down through the hardware, and this shows it.  </p>
<h3>5.  Total integration - email, calendar, contacts, notes, tasks</h3>
<p>This is probably a bunch of things, but I&#8217;ll put them all together here.  BlackBerry just delivers a better experience when going between all the above applications.  It syncs them more readily, makes it easier to link calendar entries to notes to tasks to contacts, etc.  It&#8217;s difficult to quantify but the overall experience is just smoother - obviously this is based on years of development and user feedback from RIM.   It&#8217;s core to the BlackBerry experience and they still do it better than iPhone (even with it&#8217;s super slick UI)</p>
<h3>Runners Up</h3>
<h4>BlackBerry Messenger</h4>
<p>Really great, and hugely popular, but I honestly never used it enough for it to make my personal top 5</p>
<h4>Camera</h4>
<p>The camera on my Curve 8900 blew away the iPhone (still does) but there are better mobile cameras out there than the best that BlackBerry or iPhone offer</p>
<h3>Things I specifically left out</h3>
<h4>Security</h4>
<p>Yes, BlackBerry email (within a corporate environment) is very very secure.  But for my use, I don&#8217;t really care.  Most of my email is GMail based anyway, and so I&#8217;m always sending stuff to other people via plain unencrypted protocols.  If I really care about security I send an encrypted attachment or use something other than email to do it.</p>
<h4>Battery Life</h4>
<p>I&#8217;ve gotten so used to plugging my devices in every night that this hasn&#8217;t been an issue with any mobile device (even though I use my iPhone for playing music as well as email/phone/etc).  As long as the battery lasts the day, I&#8217;m happy.</p>
<h4>Expandable memory</h4>
<p>True, BlackBerry does support micro SD cards, but the support is hobbled by two things: 1. You can&#8217;t use the SD cards for app storage, and 2. for most devices at least, you have to remove the battery to remove the SD card - no hot-swapping</p>
<h3>Conclusion</h3>
<p>Yes, most of my points were focused on email, but that&#8217;s kind of the point.  Email is one of the things I <em>need</em> to do from a mobile device.  Probably the thing I do the most.  Much more common than talking on the phone anyway (ironically?).<br />
The BlackBerry email experience comes from a combination of hardware and software, focused to specific tasks, along with the BlackBerry services provided by carriers and RIM.   It isn&#8217;t as versatile as iPhone but the tasks that it focuses on, it does <em>very well</em>.   BlackBerry&#8217;s email is good enough that it&#8217;s a viable alternative to a desktop email client - iPhone&#8217;s is usable, but just isn&#8217;t at the same level.   Is that enough to let BlackBerry hold it&#8217;s own against iPhone?  I think so, but only time will tell.</p>
<p>Agree?  Disagree?  Leave a comment and let me know!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thinkingblackberry.com/archives/274/feed</wfw:commentRss>
		<feedburner:origLink>http://www.thinkingblackberry.com/archives/274</feedburner:origLink></item>
		<item>
		<title>BlackBerry JDE Plug-In for Eclipse 1.1 Beta - Part 1</title>
		<link>http://feedproxy.google.com/~r/ThinkingBlackberry/~3/KyQ1ODs6TsE/260</link>
		<comments>http://www.thinkingblackberry.com/archives/260#comments</comments>
		<pubDate>Mon, 23 Nov 2009 19:48:15 +0000</pubDate>
		<dc:creator>anthony</dc:creator>
		
		<category><![CDATA[1.1]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[basics]]></category>

		<category><![CDATA[eclipse]]></category>

		<category><![CDATA[advanced]]></category>

		<category><![CDATA[blackberry]]></category>

		<category><![CDATA[verification error]]></category>

		<guid isPermaLink="false">http://www.thinkingblackberry.com/?p=260</guid>
		<description><![CDATA[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 - [...]]]></description>
			<content:encoded><![CDATA[<p>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.</p>
<p>Being a huge fan of Eclipse for BlackBerry development - despite <a href="http://www.thinkingblackberry.com/archives/204" >numerous problems</a> - I was eager to try out this version.  I discovered a few interesting quirks, but overall a much more solid development experience.</p>
<p><span id="more-260"></span></p>
<p><strong>Installation</strong></p>
<p>Installation is significantly easier with this version, mainly because the Eclipse Update Site for BlackBerry now seems to be working properly (some people were able to use it fine with v1.0 of the plugin, but I never did get it to work).  The Plug-in ships with v5.0 of the JDE by default, but you can easily add 4.2.1-4.7.1. </p>
<p>The installer is available on the developer zone (<a href="http://www.blackberry.com/developers" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.blackberry.com');">http://www.blackberry.com/developers</a>) - newly redesigned (and in a way which does make things easier).  Click on development beta software on the left hand nav bar, the download is right there.</p>
<p>This version of the plug-in runs on Eclipse 3.5 Ganymede (1.0 ran on Eclipse 3.4) available free from eclipse.org/downloads.  Not much difference between 3.5 and 3.4 in my experience (I&#8217;m sure the Eclipse team would beg to differ) aside from a few things in different places, including the software updates feature, which we can use to get older JDE versions installed with the plug-in.</p>
<p>The basic installation process itself is self explanatory - just run the wizard and follow the prompts - I won&#8217;t go into details.</p>
<p><strong>Installing older JDE versions</strong></p>
<p>JDE 5.0 is great, but is only shipping on a few devices right now, so you&#8217;ll likely need to get at least one of the older versions.  You can do this by going to <code>Install New Software</code> from the Eclipse Help menu.  Click the Add button and enter http://www.blackberry.com/go/eclipseUpdate/3.5/java in the Location field for the Add dialog.   Then name the site something meaningful (RIM suggests <em>BlackBerry Java Plug-in Update Site</em>, I just used <em>BlackBerry Updates</em>):</p>
<div id="attachment_261" class="wp-caption alignnone" style="width: 418px"><img src="http://www.thinkingblackberry.com/wp-content/uploads/addsite.png" alt="Adding the BlackBerry Update Site" title="Eclipse 3.5 Add Site dialog" width="408" height="169" class="size-full wp-image-261" /><p class="wp-caption-text">Adding the BlackBerry Update Site</p></div>
<p>Once this is done and you&#8217;ve clicked OK, you&#8217;ll see a list of the JDE versions available from the site.  I just selected all - figuring that I might as well get everything over with at once:</p>
<div id="attachment_262" class="wp-caption alignnone" style="width: 653px"><img src="http://www.thinkingblackberry.com/wp-content/uploads/availablesoftware.png" alt="Selecting the earlier JDE versions" title="Eclipse 3.5 Available Software" width="643" height="560" class="size-full wp-image-262" /><p class="wp-caption-text">Selecting the earlier JDE versions</p></div>
<p>Click Next and then Next again, accept the license agreement and let the downloading commence.  A warning - this is not a fire-and-forget installation:  You will be asked for your developer zone login (email and password) and not right away, so at least make sure your computer is in sight so you&#8217;ll see the dialogs (yes, one for each JDE version) when they pop-up.  You&#8217;ll also be asked to restart Eclipse when finished.  It only takes a few seconds, so definitely a good idea.</p>
<h2>Ch-ch-ch changes</h2>
<p>If you&#8217;re familiar with the earlier JDE Plug-in, a lot of things have changed - pretty much all for the better, and all much more in keeping with the Eclipse way of doing things.  I&#8217;ll go through the list that I&#8217;ve seen so far.  I was tripped up on some of these - maybe I just don&#8217;t read documentation well - but hopefully I&#8217;ll save someone else the trouble.</p>
<h3>Difference 1: Project-specific JRE versions</h3>
<p>You now specify a different version of the JRE (Java Runtime Environment - basically the JDE) for each project in your workspace.  This is a cleaner implementation in many ways, and probably more in keeping with Eclipse, but can be a bit annoying - after all, if you have more than one project in one workspace, don&#8217;t you often want to have them all running on a simulator at once?  Ah well.  There are a couple of places where you can specify this.  First is in the new project dialog box:</p>
<p>Create a new BlackBerry project by clicking <code>File->New->Project...</code> and selecting BlackBerry Project.  You&#8217;ll notice a field called JRE Version which is pre-populated with BlackBerry JRE 5.0.0.  All of the JRE&#8217;s we selected from the BlackBerry Update site are available here:</p>
<div id="attachment_263" class="wp-caption alignnone" style="width: 559px"><img src="http://www.thinkingblackberry.com/wp-content/uploads/newblackberryproject.png" alt="Selecting the JRE version for a new project" title="New BlackBerry Project" width="549" height="601" class="size-full wp-image-263" /><p class="wp-caption-text">Selecting the JRE version for a new project</p></div>
<p>What about changing the version for an existing project?  I had a little trouble finding this (anyone else?).  It&#8217;s available in a couple of spots, but the easiest one that I&#8217;ve found is right clicking the <code>JRE System Library</code> item under your project and selecting <code>Properties</code>:</p>
<div id="attachment_264" class="wp-caption alignnone" style="width: 347px"><img src="http://www.thinkingblackberry.com/wp-content/uploads/jrepropertiesmenu.png" alt="Right Click JRE System Library and select Properties" title="JRE System Library Context Menu" width="337" height="380" class="size-full wp-image-264" /><p class="wp-caption-text">Right Click JRE System Library and select Properties</p></div>
<p>The properties dialog box will allow you to select a different JRE/JDE version:</p>
<div id="attachment_265" class="wp-caption alignnone" style="width: 814px"><img src="http://www.thinkingblackberry.com/wp-content/uploads/jrepropertiesdialog.png" alt="The JRE System Library Properties dialog" title="JRE System Library Properties" width="804" height="544" class="size-full wp-image-265" /><p class="wp-caption-text">The JRE System Library Properties dialog</p></div>
<h3>Difference 2: Location of resources in a compiled application</h3>
<p>A <em>huge </em>fix in this version of the Plug-in is that folders besides <code>src </code>now work correctly all the time for source &#038; resource files!   In fact by default there&#8217;s a <code>res </code>folder in every new project for your resources.  So to emphasize, I&#8217;m much happier dealing with the following quirk than the way things existed before - and great job RIM for fixing this.  </p>
<p>The problem is that stuff placed in these folders ends up at the root level of your COD file.  That is, if you have a setup like the following, with an image under <code>res</code>:</p>
<div id="attachment_266" class="wp-caption alignnone" style="width: 274px"><img src="http://www.thinkingblackberry.com/wp-content/uploads/iconinresfolder.png" alt="An image under the res folder" title="Icon in res Folder" width="264" height="245" class="size-full wp-image-266" /><p class="wp-caption-text">An image under the res folder</p></div>
<p>The following code (which may have worked under the older plugin):</p>
<pre name="code" class="java">
		Bitmap bmp = Bitmap.getBitmapResource("res/icon.png");

		// bmp is null, so the following will throw an Exception
		int height = bmp.getHeight();
</pre>
<p>Will now cause problems, because res/icon.png will not be found.  Instead you have to load the image from the root:</p>
<pre name="code" class="java">
		Bitmap bmp = Bitmap.getBitmapResource("icon.png");

		// this works now
		int height = bmp.getHeight();
</pre>
<p>Just something to get used to - and you may want to update your build scripts according to the new reality.</p>
<h3>Difference 3: Verification Errors</h3>
<p>This one really tripped me up - there are some differences in the way things are compiled and/or run on the simulator with this version, which can cause obscure verification errors.   While I&#8217;m sure several things can cause this, the problems with my applications had to do with using the Java <code>class</code> keyword in certain ways in static contexts.  Specifically as a parameter to another constructor seemed to cause problems.  I&#8217;ll illustrate:</p>
<p>One of our apps, Super Baby GO, uses a pattern similar to the following (admittedly rather contrived) example:</p>
<pre name="code" class="java">
public class HelloWorldMainScreen extends MainScreen {

	static String className;

	static {
		className = new String(HelloWorldMainScreen.class.getName());
	}
</pre>
<p>This did work in previous versions, and causes no problems on device (when built using Ant for example).  When deployed and run in the simulator from the 1.1 Plug-in, you get a RuntimeException with the message Verification Error 1756 at some offset (the offset changes depending on your program):</p>
<div id="attachment_268" class="wp-caption alignnone" style="width: 330px"><img src="http://www.thinkingblackberry.com/wp-content/uploads/verificationerror.png" alt="RuntimeException Verification Error 1756 with the BlackBerry Eclipse 1.1 Plug-in" title="Verification Error 1756" width="320" height="240" class="size-full wp-image-268" /><p class="wp-caption-text">RuntimeException Verification Error 1756 with the BlackBerry Eclipse 1.1 Plug-in</p></div>
<p>Some hint to what causes this can be found in the simulator Event Log (hold the CTRL key on your keyboard and type L G L G).  Look at those VM:VECMm, VM:VECCs etc. lines.  They tell you where the error happened (in this case I&#8217;ve already given it away, it&#8217;s in the static class initializer - represented by clinit below):</p>
<div id="attachment_269" class="wp-caption alignnone" style="width: 330px"><img src="http://www.thinkingblackberry.com/wp-content/uploads/verificationerroreventlog.png" alt="The Event Logs around the Verification Error 1756" title="Event Log for Verification Error" width="320" height="240" class="size-full wp-image-269" /><p class="wp-caption-text">The Event Logs around the Verification Error 1756</p></div>
<p>The problem is that using the class keyword as a constructor parameter in a static (class initialization) context causes problems with this version of the Plug-in.  Fortunately this is easily resolved by using a temporary variable:</p>
<pre name="code" class="java">
public class HelloWorldMainScreen extends MainScreen {

	static String className;

	static {
		String strClass = HelloWorldMainScreen.class.getName();
		className = new String(strClass);
	}
</pre>
<p>No significant problems doing this, the real time-waster for me was figuring out what caused this in the first place!  </p>
<p>There are still a few things to talk about, including differences to debug configuration setup, and signing key management, but I&#8217;ll leave that for another post on another day.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thinkingblackberry.com/archives/260/feed</wfw:commentRss>
		<feedburner:origLink>http://www.thinkingblackberry.com/archives/260</feedburner:origLink></item>
		<item>
		<title>GPS Class</title>
		<link>http://feedproxy.google.com/~r/ThinkingBlackberry/~3/k8Xszq-risI/226</link>
		<comments>http://www.thinkingblackberry.com/archives/226#comments</comments>
		<pubDate>Thu, 24 Sep 2009 18:47:13 +0000</pubDate>
		<dc:creator>justin</dc:creator>
		
		<category><![CDATA[basics]]></category>

		<category><![CDATA[components]]></category>

		<category><![CDATA[gps]]></category>

		<category><![CDATA[blackberry]]></category>

		<category><![CDATA[example]]></category>

		<category><![CDATA[lbs]]></category>

		<category><![CDATA[location]]></category>

		<guid isPermaLink="false">http://www.thinkingblackberry.com/?p=226</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>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&#8217;m sure it could be changed to use a lister if that is what you are looking.  Remember <strong>It&#8217;s code, you can do anything!</strong> <img src='http://www.thinkingblackberry.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Here is my GPS class that I use:</p>
<pre name="code" class="java">
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;
	}
}
</pre>
<p>Once you have added the GPS class to your project you can then use it the following way:</p>
<pre name="code" class="java">
GPS gps = new GPS();
gps.start();
</pre>
<p>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.</p>
<p>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:</p>
<pre name="code" class="java">
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 &amp; 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() &gt; 10)
						if(thetxt.length() &gt; 25)
							txtGPS.setText("Waiting for GPS.");
						else
							txtGPS.setText(thetxt + ".");
					else
						txtGPS.setText("Waiting for GPS.");
				}
			}
		}
	}
}
</pre>
<p>Here is a screen shot from my simulator:<br />
<div id="attachment_243" class="wp-caption alignnone" style="width: 490px"><img src="http://www.thinkingblackberry.com/wp-content/uploads/gpsscreen.png" alt="GPSScreen in use with the GPS class" width="480" height="360" class="size-full wp-image-243" /><p class="wp-caption-text">GPSScreen in use with the GPS class</p></div></p>
<p>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.</p>
<p>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. </p>
<p>Here is some related GPS information:</p>
<ul>
<ol><a href="http://www.blackberry.com/developers/docs/4.5.0api/javax/microedition/location/Location.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.blackberry.com');">Java Doc: javax.microedition.location.Location</a>
</ol>
<ol>
<a href="http://docs.blackberry.com/en/developers/deliverables/1125/GPS%20and%20BlackBerry%20Maps%20Development%20Guide.pdf" onclick="javascript:pageTracker._trackPageview('/outbound/article/docs.blackberry.com');">GPS and BlackBerry Maps Doc from RIM</a></ol>
</ul>
<p>Enjoy!</p>
<p>Justin</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thinkingblackberry.com/archives/226/feed</wfw:commentRss>
		<feedburner:origLink>http://www.thinkingblackberry.com/archives/226</feedburner:origLink></item>
		<item>
		<title>Welcome Justin!</title>
		<link>http://feedproxy.google.com/~r/ThinkingBlackberry/~3/kZ-yTPjikkE/254</link>
		<comments>http://www.thinkingblackberry.com/archives/254#comments</comments>
		<pubDate>Thu, 24 Sep 2009 18:45:01 +0000</pubDate>
		<dc:creator>anthony</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.thinkingblackberry.com/?p=254</guid>
		<description><![CDATA[I&#8217;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&#8217;s GPS to show a map and give you information about golf [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve convinced someone else to write <a href="http://www.thinkingblackberry.com/archives/226" >a post</a> about GPS for Thinking BlackBerry!  </p>
<p>Justin is a BlackBerry developer (among other platforms) and has created a couple of great BlackBerry applications, including <a href="http://www.bbgpsgolf.com/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.bbgpsgolf.com');">BBGPSGolf</a>, a great <em>free </em>golf application for BlackBerry that uses the device&#8217;s GPS to show a map and give you information about golf courses (distances to the green, etc) on your device while you&#8217;re on the course.  </p>
<p>Anyway, he graciously offered to share some of his GPS expertise with us so read <a href="http://www.thinkingblackberry.com/archives/226" >his post</a> and if he gets enough good feedback maybe he&#8217;ll share some more of his BlackBerry development expertise!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thinkingblackberry.com/archives/254/feed</wfw:commentRss>
		<feedburner:origLink>http://www.thinkingblackberry.com/archives/254</feedburner:origLink></item>
		<item>
		<title>Non Coding Related (Mostly)</title>
		<link>http://feedproxy.google.com/~r/ThinkingBlackberry/~3/JHgM7WPKPx4/224</link>
		<comments>http://www.thinkingblackberry.com/archives/224#comments</comments>
		<pubDate>Wed, 02 Sep 2009 01:51:37 +0000</pubDate>
		<dc:creator>anthony</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.thinkingblackberry.com/?p=224</guid>
		<description><![CDATA[I&#8217;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, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been meaning to write this post for a while, but it sounds too much like making excuses.   Well, in a way it is.  </p>
<p>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.</p>
<p>First, I&#8217;ve started a company called <a href="http://www.zeebu.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.zeebu.com');">Zeebu Mobile</a> doing - what else? - BlackBerry application development, specifically in educational and early childhood applications.  We just released our first product, <a href="http://babygo.zeebu.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/babygo.zeebu.com');">Baby GO!</a>, which is free and runs on all BlackBerry devices with OS 4.2.0 and higher.</p>
<p>Second, I&#8217;ve been writing a book called <a href="http://www.apress.com/book/view/9781430272250" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.apress.com');">Beginning BlackBerry Development</a> which will be published (hopefully!) in late October.  </p>
<p>No worries about the book - it doesn&#8217;t restrict me in any way from posting, except that it&#8217;s taking up a lot of my time.  I&#8217;m still free to write about the topics I cover in the book on this blog.</p>
<p>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.</p>
<p>-Anthony</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thinkingblackberry.com/archives/224/feed</wfw:commentRss>
		<feedburner:origLink>http://www.thinkingblackberry.com/archives/224</feedburner:origLink></item>
		<item>
		<title>BlackBerry Arithmetic Performance</title>
		<link>http://feedproxy.google.com/~r/ThinkingBlackberry/~3/R57aHBO2xuc/220</link>
		<comments>http://www.thinkingblackberry.com/archives/220#comments</comments>
		<pubDate>Sun, 30 Aug 2009 20:14:49 +0000</pubDate>
		<dc:creator>anthony</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.thinkingblackberry.com/?p=220</guid>
		<description><![CDATA[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&#8217;re doing (though double is always slowest, usually by a wide margin). [...]]]></description>
			<content:encoded><![CDATA[<p>Playing with some animation for a new BlackBerry product (see next post) and wondering about performance of double/float/Fixed32 arithmetic I came across <a href="http://www.blurrywords.com/2009/05/02/blackberry-java-arithmetic-comparisons/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.blurrywords.com');">this post on Blurry Words</a>, which is <em>exactly</em> what I was looking for.</p>
<p>Basically performance depends on the type of arithmetical operation you&#8217;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:</p>
<p><strong>BlackBerry Bold</strong></p>
<table class="data" border="0" width="100%">
<tbody>
<tr>
<td width="25%" align="center" valign="top"><strong><span style="color: #111199">Variable Type</span></strong></td>
<td width="25%" align="center" valign="top"><strong><span style="color: #111199">Add/Sub (ms)</span></strong></td>
<td width="25%" align="center" valign="top"><strong><span style="color: #111199">Mult (ms)</span></strong></td>
<td width="25%" align="center" valign="top"><strong><span style="color: #111199">Div (ms)</span></strong></td>
</tr>
<tr>
<td width="150" align="center" valign="top">Fixed32</td>
<td width="150" align="center" valign="top">153</td>
<td width="150" align="center" valign="top">597</td>
<td width="150" align="center" valign="top">776</td>
</tr>
<tr>
<td width="150" align="center" valign="top">float</td>
<td width="150" align="center" valign="top">317</td>
<td width="150" align="center" valign="top">242</td>
<td width="150" align="center" valign="top">550</td>
</tr>
<tr>
<td width="150" align="center" valign="top">double</td>
<td width="150" align="center" valign="top">514</td>
<td width="150" align="center" valign="top">366</td>
<td width="150" align="center" valign="top">1931</td>
</tr>
<tr>
<td width="150" align="center" valign="top">long</td>
<td width="150" align="center" valign="top">114</td>
<td width="150" align="center" valign="top">117</td>
<td width="150" align="center" valign="top">225</td>
</tr>
<tr>
<td width="150" align="center" valign="top">int</td>
<td width="150" align="center" valign="top">96</td>
<td width="150" align="center" valign="top">90</td>
<td width="150" align="center" valign="top">114</td>
</tr>
<tr>
<td width="150" align="center" valign="top">short</td>
<td width="150" align="center" valign="top">102</td>
<td width="150" align="center" valign="top">102</td>
<td width="150" align="center" valign="top">125</td>
</tr>
<tr>
<td width="150" align="center" valign="top">byte</td>
<td width="150" align="center" valign="top">104</td>
<td width="150" align="center" valign="top">107</td>
<td width="150" align="center" valign="top">127</td>
</tr>
</tbody>
</table>
<p>The net.rim.device.api.math.Fixed32 class is interesting - I&#8217;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.  </p>
<p>Though I&#8217;ve gotta disagree with the poster&#8217;s conclusions - Fixed32 is not strictly legacy, it&#8217;s only been available since OS 4.0, at which time float and double were available on BlackBerry.  </p>
<p>There&#8217;s a lot more interesting discussion and more results for different devices just in this post, so I encourage to <a href="http://www.blurrywords.com/2009/05/02/blackberry-java-arithmetic-comparisons/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.blurrywords.com');">read the original!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thinkingblackberry.com/archives/220/feed</wfw:commentRss>
		<feedburner:origLink>http://www.thinkingblackberry.com/archives/220</feedburner:origLink></item>
		<item>
		<title>Sibling CODs - or How to Make Your App Install Over The Air</title>
		<link>http://feedproxy.google.com/~r/ThinkingBlackberry/~3/HpeQyFR9U5U/214</link>
		<comments>http://www.thinkingblackberry.com/archives/214#comments</comments>
		<pubDate>Tue, 21 Jul 2009 17:23:07 +0000</pubDate>
		<dc:creator>anthony</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.thinkingblackberry.com/?p=214</guid>
		<description><![CDATA[It&#8217;s been way too long since I wrote a post - interesting aside for bloggers: don&#8217;t get out of the rhythm, it&#8217;s incredibly hard to start back up again once it&#8217;s no longer part of your daily routine.  Anyway, I&#8217;ve been busy (more on that later) but due to demand am now committed to [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been way too long since I wrote a post - interesting aside for bloggers: don&#8217;t get out of the rhythm, it&#8217;s incredibly hard to start back up again once it&#8217;s no longer part of your daily routine.  Anyway, I&#8217;ve been busy (more on that later) but due to demand am now committed to start posting again, and it was a recent <a href="/archives/141#comment-80">comment on an earlier post</a> that gave me the idea for this one: short but sweet and valuable to all aspiring BlackBerry app developers.<br />
<span id="more-214"></span></p>
<h2>Big CODs</h2>
<p>BlackBerry applications are compiled using the RAPC tool (which is called automatically by the JDE or the JDE Plug-in for Eclipse) into .cod files (pronounced like the fish by most developers).  A .cod is basically a .jar file, which is further compressed, optionally signed, and has any unused code removed.  They&#8217;re only usable by the BlackBerry - no other J2ME devices.</p>
<p>Because of some deep technical reasons (I think to do with the way the flash file system used to work on the device) a .cod file can only be a certain size.  Or more correctly, a .cod file can only have a certain amount of code or static data (resources mostly).  That limit is about 64k - so theorietically a .cod file could be almost twice that limit, with 64k each of code and data, but in practice that never happens, and in fact there seems to be another limit.  In any case, the exact number isn&#8217;t all that important - the point is that most modern applications have no trouble breaking through either or both of those size barriers.</p>
<p>So what happens when you make an application that produces a .cod that&#8217;s too big?  The RAPC compiler breaks the .cod into smaller .cod files, and renames them based on your initial .cod file.  So instead of having:</p>
<table>
<tr>
<th>File</th>
<th>Size</th>
</tr>
<tr>
<td>myapp.cod</td>
<td>552,966</td>
</tr>
</table>
<p>You get something like:</p>
<table>
<tr>
<th>File</th>
<th>Size</th>
</tr>
<tr>
<td>myapp.cod</td>
<td>58,016</td>
</tr>
<tr>
<td>myapp-1.cod</td>
<td>56,380</td>
</tr>
<tr>
<td>myapp-2.cod</td>
<td>57,980</td>
</tr>
<tr>
<td>myapp-3.cod</td>
<td>55,528</td>
</tr>
<tr>
<td>myapp-4.cod</td>
<td>53,816</td>
</tr>
<tr>
<td>myapp-5.cod</td>
<td>52,968</td>
</tr>
<tr>
<td>myapp-6.cod</td>
<td>50,004</td>
</tr>
<tr>
<td>myapp-7.cod</td>
<td>57,252</td>
</tr>
<tr>
<td>myapp-8.cod</td>
<td>53,772</td>
</tr>
<tr>
<td>myapp-9.cod</td>
<td>56,224</td>
</tr>
</table>
<p>Or at least - that would make sense. Actually it&#8217;s something slightly different.</p>
<h2>Sibling COD files</h2>
<p>In reality what you get is:</p>
<table>
<tr>
<th>File</th>
<th>Size</th>
</tr>
<tr>
<td>myapp.cod</td>
<td>552,966</td>
</tr>
</table>
<p>So what gives?  Well if we take a closer look at that big cod file, what you&#8217;ll notice is this: it&#8217;s actually a .zip file!  That&#8217;s right - rename it to myapp.zip and open it and inside you&#8217;ll see:</p>
<table>
<tr>
<th>File</th>
<th>Size</th>
</tr>
<tr>
<td>myapp.cod</td>
<td>58,016</td>
</tr>
<tr>
<td>myapp-1.cod</td>
<td>56,380</td>
</tr>
<tr>
<td>myapp-2.cod</td>
<td>57,980</td>
</tr>
<tr>
<td>myapp-3.cod</td>
<td>55,528</td>
</tr>
<tr>
<td>myapp-4.cod</td>
<td>53,816</td>
</tr>
<tr>
<td>myapp-5.cod</td>
<td>52,968</td>
</tr>
<tr>
<td>myapp-6.cod</td>
<td>50,004</td>
</tr>
<tr>
<td>myapp-7.cod</td>
<td>57,252</td>
</tr>
<tr>
<td>myapp-8.cod</td>
<td>53,772</td>
</tr>
<tr>
<td>myapp-9.cod</td>
<td>56,224</td>
</tr>
</table>
<p>Those similarly-named files inside the big .cod/.zip file are called <em>sibling COD files</em>.</p>
<h2>So What?</h2>
<p>So, ok all your .cod files are packaged up into a .zip.  Sensible, right?  Just load that one file and everything works.  Well, that&#8217;s true, except if your trying to download your app to your BlackBerry without using a BES.  Understand that sentence - you can load one big  .cod file if you&#8217;re doing it through the desktop manager, or if you&#8217;re downloading through a BES, but if you&#8217;re not attached to a BES and want to download it directly to your device, you&#8217;re out of luck.</p>
<p>Fortunately the solution is relatively simple - just unzip that big .cod/.zip and post all the individual files to the same directory, along with the .jad file.  Then things will work fine - the browser will even know enough to show the user the total app size before downloading.  </p>
<p>In fact, if you want to automate all that, I recommend the excellent (and free) <a href="http://bb-ant-tools.sourceforge.net/main" onclick="javascript:pageTracker._trackPageview('/outbound/article/bb-ant-tools.sourceforge.net');">bb-ant-tools</a>, which includes a nice Ant task called jadtool that does the unzipping of the sibling cods for you.</p>
<p>So there you go - sibling CODs!  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.thinkingblackberry.com/archives/214/feed</wfw:commentRss>
		<feedburner:origLink>http://www.thinkingblackberry.com/archives/214</feedburner:origLink></item>
		<item>
		<title>What would you like to know about BlackBerry development?</title>
		<link>http://feedproxy.google.com/~r/ThinkingBlackberry/~3/9_ZfF6wfJHc/208</link>
		<comments>http://www.thinkingblackberry.com/archives/208#comments</comments>
		<pubDate>Thu, 19 Mar 2009 02:33:36 +0000</pubDate>
		<dc:creator>anthony</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.thinkingblackberry.com/?p=208</guid>
		<description><![CDATA[I&#8217;ve gotten several good ideas for posts from the readers of this blog, so I&#8217;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 [...]]]></description>
			<content:encoded><![CDATA[<div class="sticky_post"><p>I&#8217;ve gotten several good ideas for posts from the readers of this blog, so I&#8217;ve decided (based on a user comment) to put a sticky post up solely for the purpose of soliciting new post ideas.</p>
<p>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&#8217;ll pick the ones that are most in demand or that I think would make the best posts.</p>
<p>I&#8217;ll start off with some ideas:</p>
<ul>
<li>BlackBerry networking - TCP/BIS/BES - what are they and how do you use them?</li>
<li>Resource bundles and localization</li>
<li>Debugging with the Eclipse debugger</li>
<li>Debugging your application on a real BlackBerry using the Eclipse debugger (or the JDE debugger)</li>
</ul>
<p>Thanks!</p>
<p>Anthony</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.thinkingblackberry.com/archives/208/feed</wfw:commentRss>
		<feedburner:origLink>http://www.thinkingblackberry.com/archives/208</feedburner:origLink></item>
		<item>
		<title>A suggestion on how to fix the BlackBerry JDE Eclipse Plugin</title>
		<link>http://feedproxy.google.com/~r/ThinkingBlackberry/~3/5XALQNK6T0c/204</link>
		<comments>http://www.thinkingblackberry.com/archives/204#comments</comments>
		<pubDate>Tue, 10 Mar 2009 03:08:56 +0000</pubDate>
		<dc:creator>anthony</dc:creator>
		
		<category><![CDATA[eclipse]]></category>

		<category><![CDATA[blackberry]]></category>

		<category><![CDATA[opinion]]></category>

		<guid isPermaLink="false">http://www.thinkingblackberry.com/?p=204</guid>
		<description><![CDATA[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&#8217;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&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago, I wrote a <a href="/archives/21">post about setting up the JDE Eclipse Plugin</a>, which extolled the virtues of the JDE Plugin for Eclipse.  As I said then, I&#8217;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&#8217;ve now used the plugin for a few more months, and, while I still believe it&#8217;s the best way to develop BlackBerry applications, I&#8217;m also less in love with it than I was.  Basically, the JDE&#8217;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&#8217;s better to work in Eclipse.</p>
<p>But - there <em><strong>are</strong></em> some pretty significant quirks.  </p>
<p>Big ones that I haven&#8217;t found good workarounds for include:<br />
- <code>src</code> is the only &#8216;officially&#8217; recognized source folder.  I don&#8217;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 <code>src</code> 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)<br />
- you can&#8217;t add 3rd party .jar files to a BlackBerry project in Eclipse (mentioned <a href="http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&#038;message.id=11279" onclick="javascript:pageTracker._trackPageview('/outbound/article/supportforums.blackberry.com');">here</a>).  The only way around this is to use source files (for KXML/KXML-RPC, the most common one I&#8217;ve seen, source is thankfully available, though you have to dig)<br />
- 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.</p>
<p>There are others, but you get the idea</p>
<p>Don&#8217;t let these scare you away (unless one really is a showstopper) - Eclipse is <em>still</em> the best way to go.  </p>
<p>Now, here&#8217;s my suggestion for fixing things:</p>
<p><strong>Open source the BlackBerry JDE Plugin for Eclipse!</strong></p>
<p>That&#8217;s right, open source it.  <em>Please</em>.  Listen, RIM, if your&#8217;e reading: There&#8217;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&#8217;ve leapfrogged you, <em>and you&#8217;re falling further behind</em>.  </p>
<p>You don&#8217;t have to make it GPL or even LGPL.  Something less idealistic would be fine.  You don&#8217;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&#8217;s wrong and FIX IT.  </p>
<p>Thank you!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thinkingblackberry.com/archives/204/feed</wfw:commentRss>
		<feedburner:origLink>http://www.thinkingblackberry.com/archives/204</feedburner:origLink></item>
		<item>
		<title>Making a Custom Screen, Vertically Scrolling and more</title>
		<link>http://feedproxy.google.com/~r/ThinkingBlackberry/~3/8MoFzrY48zU/201</link>
		<comments>http://www.thinkingblackberry.com/archives/201#comments</comments>
		<pubDate>Thu, 05 Mar 2009 03:01:20 +0000</pubDate>
		<dc:creator>anthony</dc:creator>
		
		<category><![CDATA[components]]></category>

		<category><![CDATA[ui]]></category>

		<category><![CDATA[blackberry]]></category>

		<guid isPermaLink="false">http://www.thinkingblackberry.com/?p=201</guid>
		<description><![CDATA[It&#8217;s been a couple of weeks since my last post - I&#8217;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&#8217;re all long enough that I don&#8217;t have the energy to finish them.  Luckily [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a couple of weeks since my last post - I&#8217;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&#8217;re all long enough that I don&#8217;t have the energy to finish them.  Luckily I got inspiration for a new post from this <a href="/archives/116#comment-19">reader comment</a>!  It&#8217;s fairly simple, but led to me finding a small bug in my <a href="/archives/133">GridLayoutManager</a>, and does illustrate some interesting things about BlackBerry layout managers and screens, so read on (and keep those comments coming!):</p>
<p><span id="more-201"></span></p>
<p>The question (from Tony Bruce) was:</p>
<blockquote><p>What happens if you add more fields than you have vertical space? I’m a BB dev newbie but it seams like if you add more fields than you have vertical space then eventually inside sublayout it is going to call layoutChild with a negative height. Is there some extra mojo you have to add if you want the grid to be scrollable so it can be bigger than the screen and the focused field is always visible?</p></blockquote>
<p>There are two parts to my answer.  To get scrolling behavior, just do what I did in my example screen.  That is, create a <code>MainScreen</code>, create a <code>GridLayoutManager</code>, and then add the <code>GridLayoutManager</code> to the screen using the add(Field) method.  When you add enough items to make the manager layout taller than the available screen height, scroll arrows will appear and the display will scroll to show the focused field.  This works because <code>MainScreen</code>&#8217;s <em>delegate manager</em> is a <code>VerticalFieldManager</code> with scrolling enabled.  What&#8217;s a delegate manager?  That&#8217;s something you need to know if you ever make your own Screen.</p>
<h3>Delegate Managers</h3>
<p>Although <code>Screen</code> is a subclass of <code>Manager</code>, it actually doesn&#8217;t do any of the layout of fields added using its add (and insert) methods directly.  Instead, each <code>Screen</code> delegates layout to a manager - the delegate manager.  Notice that <code>Screen</code>&#8217;s constructor requires a <code>Manager</code> - you specify the Screen&#8217;s delegate manager at construction time, and can&#8217;t change it later.  This means among other things that a <code>MainScreen</code> will always have a scrollable <code>VerticalFieldManager</code> as it&#8217;s main area - so if you want other behavior you can&#8217;t use <code>MainScreen</code>!</p>
<p>Easy enough - and this explains why we don&#8217;t need to do any additional work to the GridFieldManager example to make it scrollable - it&#8217;s automatically inside a vertically scrolling manager already!  A couple more things about delegate managers, if you&#8217;re thinking of making your own screen.</p>
<p>First, the screen gets to set the position and size of its delegate manager.  This is done in the <code>layoutDelegate</code> and <code>setPositionDelegate</code> methods.  (You <em>don&#8217;t</em> have to make your delegate use the entire size of your screen).</p>
<p>Second, don&#8217;t worry about laying out any fields that are added to the <code>Screen</code> from within the <code>Screen</code> itself - that&#8217;s all done by the delegate.  The screen deals with those field in the add (and insert) methods, and then basically forgets about them.  This should be obvious but since it derives from <code>Manager</code>, I feel it&#8217;s worth saying explicitly - don&#8217;t make a <code>Screen</code> the same way you make a <code>Manager</code>.</p>
<h3>Part Two: Mea Culpa</h3>
<p>Part two will actually be quick - as the commenter pointed out, at some point <code>GridFieldManager</code> might end up setting fields to negative height.  As we&#8217;ve just seen, in the case where we add it to a <!--more-->MainScreen, this isn&#8217;t an issue as we have a huge vertical space to play with.  However it is a bug when we&#8217;re not in a vertically scrolling manager.  So I made a couple of small changes to check that we don&#8217;t go above the available height.  The interesting change is this, which is a fairly useful convention in a lot of layout methods - it ensures you respect the height (in this case) and width given by your manager:</p>
<pre name="code" class="java">
		setExtent(totalWidth, Math.min(y, height));
</pre>
<p>Updated in the <a href="/wp-content/uploads/GridFieldManager.java">usual spot</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thinkingblackberry.com/archives/201/feed</wfw:commentRss>
		<feedburner:origLink>http://www.thinkingblackberry.com/archives/201</feedburner:origLink></item>
	</channel>
</rss>
