Testing J2ME Timers

And I thought developing against cron was bad.

In J2ME, at least on BlackBerry devices, one cannot test Timer and TimerTask objects by simply changing the device clock. J2ME apps seems to remember the time at which they were launched, rather than pinging what the clock on the device says.

Testing involves shutting down the app, resetting the clock, and starting the app back up. Time consuming if you’re working on an app with some heavy startup / shutdown overhead.

Gettting TCP connections to work on an AT&T BlackBerry

If you’re trying to run an app that requires TCP connectivity and find it to be mysteriously failing, then probably your BlackBerry is missing it’s APN settings.  See Options -> Advanced Options -> TCP.

There are four recommendations floating around the net.  So far, this works for me:

APN: wap.cingular
Username for APN: <blank>
Password for APN: <blank>

Other allegedly successful access patterns, eg:

APN: <blank>
Username for APN: <blank>
Password for APN:

APN: proxy
Username for APN: <blank>
Password for APN: <blank>

APN: isp.cingular
Username for APN: <blank>
Password for APN: <blank>

would appear to be lies and damned lies.

On the backend, bad APN’s will fail with “Invalid tunnel name” if the device can’t figure out what type of network connection you’re trying to use, otherwise “Open tunnel – failure” if it thinks it can connect but authentication fails.

Oh BlackBerry people, why have you made basic networking so complex?  We at our little startup are starting to think we can’t afford to support network-enabled apps on your devices.  Life is so much easier on the iPhone…

BlackBerry WiFi Connectivity Rain Dance

If you ever find yourself unable to get your BlackBerry to connect to wifi, try the following:

Settings -> Options -> Advanced Options -> Host Routing Table

In the “HRT Editor”, click the BlackBerry button and select “Register Now”.  You should get a “Registration message sent!” message and see some network activity.  Click “OK” and try to access the Internet again.

If you’re lucky, you now get to say “Voilla!” This seems to work about 80% of the time.

I think this is how BlackBerry locks down their devices so that folks are required to purchase data plans from a carrier.  No SIM card, no data plan, no wifi.

Would that this were rather more seamless.

Running the BlackBerry Simulator on Vista

BlackBerry Simulator mysteriously dying every time you try to fire it up on Vista?  Same here. It’s a good thing I’ve become a compulsive reader of release notes. From the the latest JDE 4.6.0 docs:

If you install the BlackBerry® Java® Development Environment on a computer with Windows Vista™, if Use Account Control is turned on, launching the BlackBerry® Smartphone simulator might produce error messages and the simulator might not start.

Translation:  Simulator will definitely. not. start.  And of course they mean User Access Control. How-To Geek has an easy way to kill UAC here.