Debugging for the New Blackberry 9800

Debugging for the New Blackberry 9800

Hopefully, a helpful hint:

Use the Blackberry SDK version of the 9800 simulator, and not the one that you can download separately from the Blackberry website.

The SDK simulator seems to work fairly well; the separate download version tends to lock up when trying to access embedded web controls.

This may be a very temporary thing. But for now, I can say at least anecdotally this has been my experience.

Advertisements
Windows Phone 7 – Some Initial Thoughts

Windows Phone 7 – Some Initial Thoughts

I’ve just started playing around with the Windows Phone 7 SDK. Here are some of my initial thoughts:

  • The Windows Phone 7 UX / UI tools make what’s available on Android and Blackberry look lame by comparison (Android’s UI tools: slim; Blackberry’s: none). In fact, I would even go as far to say that Microsoft Expression Blend is a more powerful design tool that Apple’s Interface Builder.
  • The overall UI itself is taking me some getting used to. It’s a little on the spare side for my tastes.
  • The simulator is rock solid. Love the fact that I can compile and test without restarting the simulator each time, and even if I DO have to start the simulator each time, it takes only seconds to start and not minutes (** cough cough ** android ** cough ** blackberry ** cough ** cough **).

I’m still wading through the documentation and working through the labs, but I have to say my initial impression is… very favorable.

I have yet to do anything substantive (create an HTTP connection, start a thread, download an image, cache / persist data, etc.). What I see so far is causing me to rethink whether Microsoft may yet have a chance in the “phone wars.”

Playing a Sound File in a Blackberry Java App

Playing a Sound File in a Blackberry Java App

Without a lot of undo fuss, here’s one way to play a sound file in a Blackberry Java app:

Class cl = null;
try {
cl = Class.forName("com.mycompany.myapp.MyAppMainClass");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
if (cl!=null) {
InputStream is = cl.getResourceAsStream("/someSoundFile.mp3");
try {
Player player = Manager.createPlayer(is, "audio/mpeg");
player.realize();
player.prefetch();
player.start();
is.close();
} catch (IOException e) {
e.printStackTrace();
} catch (MediaException e) {
e.printStackTrace();
}
}

I usually create a package under the res (resource) package, name it sounds, and plop my sound files there.
Easy Peasy.

Hiding Blackberry Background Processes

Hiding Blackberry Background Processes

If you’ve ever developed a Blackberry app that has an Alternate Entry Point and runs in the background, you’re familiar with this typical scenario in your main application class (or something very much like it):

public static void main(String args[]) {

if (args.length>0 && args[0].equals("autostartup"))

{

MyApp app = new MyApp();

app.registerPushApplication();

app.enterEventDispatcher();

}

else

{

new MyApp().showGUI();

}

}

But wait a minute… how come I can ** still ** see my application’s autostart instance in the “Switch Applications” dialog?!?

This isn’t what I wanted.

Here’s the additional “secret sauce” you need:

First, declare a private global boolean in your main application class. I call mine (usually) _acceptsForeground and set it to false initially.

Next, in your main application class handle the UIApplication.acceptsForeground callback and code it like this:


protected boolean acceptsForeground() {

return _acceptsForeground;

}

Finally, in your showGUI() method (or whatever you call your analogous implementation) you need to add the following two (2) lines of code at the beginning of the method:

_acceptsForeground = true;

UiApplication.getUiApplication.requestForeground();

And that’s that. No longer will your application’s autostart instance appear in your task switcher.

The Alternative to the Blackberry Battery Pull

The Alternative to the Blackberry Battery Pull

Tired of yanking your Blackberry battery out when things go wonky?

Fear not, friends.

I have a tip.

There is a Blackberry equivalent to the Windows Ctrl-Alt-Delete three-finger salute.

Press the Alt, Right-Shift, and Del keys and hold them down.

It’s the little things, right?

A nice little BES / BIS “gotcha”

A nice little BES / BIS “gotcha”

A funny thing happened while testing today.

Well. It really wasn’t that funny.

Just strange.

I was testing a new Blackberry app to run solely over BIS and / or solely over BES.

And all hell started breaking loose.

JSON wouldn’t parse. Calls broke. Dogs and cats lied down next to each other.

After a little digging, I discovered that when an app makes calls over BIS or BES, there’s a good chance the data you get back will be a mixed stream of UTF-16 and UTF-8 data.

Not just a good chance. In my case, it ALWAYS returned mixed data.

Talk about your basic cluster smuck.

The fix turned out to be simple enough. I just had to set x-rim-transcode-content in my HTTP headers to none and voila! Problem solved. Nothing but good ol’ pure UTF-8.

I can’t imagine how many people out there are having this problem.  But I hope this little “heads up” can save someone a little grief.

Blackberry BrowserFieldListener downloadProgress

Blackberry BrowserFieldListener downloadProgress

The downloadProgress event for BrowserFieldListener never fires.

Let me repeat.

The downloadProgress event for BrowserFieldListener never fires.

So, this is causing me to put together a dirty hack. And it will work.

But once again, spending development time to fix documented Blackberry “features” that simply don’t work.

Like isFocus.

And now, downloadProgress.