The Cobbler’s Children Have No Shoes

The Cobbler’s Children Have No Shoes

You know the old saw.

The Cobbler’s Children Have No Shoes.

Same’s been true with me and updating my own marketing material lately.

To correct that, I’ve been playing around with Animoto this week (http://www.animoto.com).

Verdict: Me like. Me like lots.

Anyway, here’s the result:

iPhone Apps

Android Apps

Blackberry Apps

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.

My Last Blackberry Bitch This Week – I Promise

My Last Blackberry Bitch This Week – I Promise

How do you know when I’m working on a Blackberry Project?

Because of my non-stop bitching about how poor a job the makers of Blackberry have done implementing their SDK.

It would lead one to believe that I don’t like developing for Blackberry on principle. That is not, in fact, the case.

I mean, I love my kids, I love the color of money, and working on Blackberry projects helps me help the ones I love by allowing me to feed, clothe, house, and school them.

But I can’t for the life of me figure out how the management at Blackberry allows some of the big omissions in their platform persist.

What has set me off today, you ask?

This little beauty:

In Blackberry’s Java implementation, there is no way to disable a button programmatically, without deleting it.

Read that again.

In Blackberry’s Java implementation, there is no way to disable a button programmatically, without deleting it.

Seriously.

Again, it’s not like this thing hasn’t been out a few years. I mean, not to shame them or anything, but back in 1996 Visual Basic was able to do this.

Android can do this. Apple can do this.

C’mon Blackberry. You’ve got to do better than this.

Blackberry Numeric Formatted Output – You’re SOL

Blackberry Numeric Formatted Output – You’re SOL

If you’ve tried to do some basic formatting for – oh say – currency or thousands-separated floating point numbers in Blackberry Java, you quickly realize something:

You’re spit outta luck.

For you old C developers, I daresay you can’t do without printf, fprintf, or sprintf for doing external and internal string formatting.

But somehow, the geniuses behind Blackberry failed to supply one of the most basic elements used by developers in their apps – the ability to easily format numeric strings for output.

It’s not like Java doesn’t have a Formatter class – it’s just that Blackberry’s version of it doesn’t support locale-specific decimal points and separators. So, something like Formatter fmt = new Formatter("###,###.00") – which works like a charm in most Java environments and on Android – is exception city on Blackberry.

In short, you’re screwed.

There is a solution – write your own formatter (ugh).

The fine folks at Sun do have a sample implementation of a Java printf analog (http://java.sun.com/developer/technicalArticles/Programming/sprintf/PrintfFormat.java). Unfortunately, they prohibit it’s use in commercial applications. Which means it’s worthless as a solution for professional developers.

This may seem like a trivial thing.

Except that you have to take time away from doing real project work to fix a shortcoming in the Blackberry SDK, so that your app can have basic numeric and currency string formatting.

And for those playing along at home, time is money. You heard it here first.

There really isn’t an excuse for this type of shortcoming, in a product line years on the market.