<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>naviina</title>
	<atom:link href="http://www.naviina.eu/wp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.naviina.eu/wp</link>
	<description>the naviina blog</description>
	<lastBuildDate>Fri, 21 May 2010 13:46:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Coloured Debug Output on BlackBerry</title>
		<link>http://www.naviina.eu/wp/blackberry/coloured-debug-output-on-blackberry/</link>
		<comments>http://www.naviina.eu/wp/blackberry/coloured-debug-output-on-blackberry/#comments</comments>
		<pubDate>Tue, 04 May 2010 12:28:13 +0000</pubDate>
		<dc:creator>roygbiv</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://www.naviina.eu/wp/?p=865</guid>
		<description><![CDATA[While working on a project that involved lots of time sensitive heuristics that prevented stepping through the code I got frustrated with having to search for my debug output hidden amongst the Rim VM messages:

VM:TI2Rv=119
VM:TI2Rv=112
VM:TR2Iv=37
VM:TR2Iv=36
VM:TR2Iv=43
VM:TR2Iv=49
VM:TR2Iv=91
VM:TR2Iv=79
VM:TR2Iv=42
VM:TR2Iv=44
VM:TR2Iv=54
VM:TR2Iv=45
VM:TR2Iv=48
VM:TR2Iv=50
VM:TR2Iv=51
VM:TR2Iv=47
VM:TR2Iv=57
VM:-CR=0
PhoneFolders.getInstance(): _instance is null
PhoneFolders.getInstance(): have _instance
Something I&#8217;m interested in   Memory Tab. Check &#8216;Simulate SD Card Inserted&#8217; and &#8216;Use PC [...]]]></description>
			<content:encoded><![CDATA[<p>While working on a project that involved lots of time sensitive heuristics that prevented stepping through the code I got frustrated with having to search for my debug output hidden amongst the Rim VM messages:</p>
<p><span id="more-865"></span></p>
<blockquote><p>VM:TI2Rv=119<br />
VM:TI2Rv=112<br />
VM:TR2Iv=37<br />
VM:TR2Iv=36<br />
VM:TR2Iv=43<br />
VM:TR2Iv=49<br />
VM:TR2Iv=91<br />
VM:TR2Iv=79<br />
VM:TR2Iv=42<br />
VM:TR2Iv=44<br />
VM:TR2Iv=54<br />
VM:TR2Iv=45<br />
VM:TR2Iv=48<br />
VM:TR2Iv=50<br />
VM:TR2Iv=51<br />
VM:TR2Iv=47<br />
VM:TR2Iv=57<br />
VM:-CR=0<br />
PhoneFolders.getInstance(): _instance is null<br />
PhoneFolders.getInstance(): have _instance<br />
Something I&#8217;m interested in <span style="color: red"><<<</span><br />
VM:ICSFv=1,w=131044<br />
JVM: bklt[1] @35661: JBSC on=1<br />
JVM: bklt[1] @35661: SC 1<br />
JVM: bklt @35661: setTimer 22<br />
Starting com_naviina_boelexdebug_app<br />
Started com_naviina_boelexdebug_app(161)<br />
Foreground com_naviina_boelexdebug_app(161)</p></blockquote>
<p>I resorted to putting an ugly prefix at the start of every line so my output would stand out:</p>
<p>System.out.println(&#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221; + someParam);</p>
<p>Below is the source for a class that has helped me a lot when having to work without being able to step through code. It outputs html markup to a file in the simulator SD card directory, used in conjunction with the <a href="https://addons.mozilla.org/en-US/firefox/addon/115">ReloadEvery Firefox plugin</a> it allows you to see only the information you need without the distraction of the VM output. Plus it has the added benefit of being able to colour-code the output from different classes in your project.</p>
<pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.OutputStream</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.microedition.io.Connector</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.microedition.io.file.FileConnection</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Web <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> MODE_OUTPUT <span style="color: #339933;">=</span> 0;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> MODE_SDCARD <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span>;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">int</span> outputmode <span style="color: #339933;">=</span> MODE_SDCARD;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> debugFile <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;file:///SDCard/debug.htm&quot;</span>;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aoutputstream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">OutputStream</span></a> os <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span>;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> FileConnection fc <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span>;
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> setOutputMode<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> _outputmode<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        outputmode <span style="color: #339933;">=</span> _outputmode;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> out<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> message<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>outputmode<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">case</span> MODE_OUTPUT<span style="color: #339933;">:</span>
                <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>message<span style="color: #009900;">&#41;</span>;
                <span style="color: #000000; font-weight: bold;">break</span>;
            <span style="color: #000000; font-weight: bold;">case</span> MODE_SDCARD<span style="color: #339933;">:</span>
                writeLine<span style="color: #009900;">&#40;</span>message <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #009900;">&#41;</span>;
                <span style="color: #000000; font-weight: bold;">break</span>;
        <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> out<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> message, <span style="color: #000066; font-weight: bold;">int</span> textColor<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>outputmode<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">case</span> MODE_OUTPUT<span style="color: #339933;">:</span>
                <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;span style=<span style="color: #000099; font-weight: bold;">\&quot;</span>color: &quot;</span> <span style="color: #339933;">+</span> color2web<span style="color: #009900;">&#40;</span>textColor<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span> <span style="color: #339933;">+</span> message <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;&lt;/span&gt;&lt;br&gt;&quot;</span><span style="color: #009900;">&#41;</span>;
                <span style="color: #000000; font-weight: bold;">break</span>;
            <span style="color: #000000; font-weight: bold;">case</span> MODE_SDCARD<span style="color: #339933;">:</span>
                writeLine<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;span style=<span style="color: #000099; font-weight: bold;">\&quot;</span>color: &quot;</span> <span style="color: #339933;">+</span> color2web<span style="color: #009900;">&#40;</span>textColor<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span> <span style="color: #339933;">+</span> message <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;&lt;/span&gt;&lt;br&gt;&quot;</span><span style="color: #009900;">&#41;</span>;
                <span style="color: #000000; font-weight: bold;">break</span>;
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> out<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> message, <span style="color: #000066; font-weight: bold;">int</span> textColor, <span style="color: #000066; font-weight: bold;">int</span> backgroundColor<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>outputmode<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">case</span> MODE_OUTPUT<span style="color: #339933;">:</span>
                <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;span style=<span style="color: #000099; font-weight: bold;">\&quot;</span>color: &quot;</span> <span style="color: #339933;">+</span> color2web<span style="color: #009900;">&#40;</span>textColor<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;; background-color:&quot;</span> <span style="color: #339933;">+</span> color2web<span style="color: #009900;">&#40;</span>backgroundColor<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span> <span style="color: #339933;">+</span> message <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;&lt;/span&gt;&lt;br&gt;&quot;</span><span style="color: #009900;">&#41;</span>;
                <span style="color: #000000; font-weight: bold;">break</span>;
            <span style="color: #000000; font-weight: bold;">case</span> MODE_SDCARD<span style="color: #339933;">:</span>
                writeLine<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;span style=<span style="color: #000099; font-weight: bold;">\&quot;</span>color: &quot;</span> <span style="color: #339933;">+</span> color2web<span style="color: #009900;">&#40;</span>textColor<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;; background-color:&quot;</span> <span style="color: #339933;">+</span> color2web<span style="color: #009900;">&#40;</span>backgroundColor<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span> <span style="color: #339933;">+</span> message <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;&lt;/span&gt;&lt;br&gt;&quot;</span><span style="color: #009900;">&#41;</span>;
                <span style="color: #000000; font-weight: bold;">break</span>;
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> color2web<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> color<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> webcolor <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;#&quot;</span> <span style="color: #339933;">+</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainteger+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Integer</span></a>.<span style="color: #006633;">toHexString</span><span style="color: #009900;">&#40;</span>color<span style="color: #009900;">&#41;</span>;
        <span style="color: #000000; font-weight: bold;">return</span> webcolor;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> writeLine<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> line<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>fc <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                    fc <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>FileConnection<span style="color: #009900;">&#41;</span> Connector.<span style="color: #006633;">open</span><span style="color: #009900;">&#40;</span>debugFile, Connector.<span style="color: #006633;">READ_WRITE</span><span style="color: #009900;">&#41;</span>;
                    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>fc.<span style="color: #006633;">exists</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        fc.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aioexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IOException</span></a> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    ex.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
            os <span style="color: #339933;">=</span> fc.<span style="color: #006633;">openOutputStream</span><span style="color: #009900;">&#40;</span>fc.<span style="color: #006633;">fileSize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
            line <span style="color: #339933;">=</span> line <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> lineArray <span style="color: #339933;">=</span> line.<span style="color: #006633;">getBytes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
            os.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>lineArray, 0, lineArray.<span style="color: #006633;">length</span><span style="color: #009900;">&#41;</span>;
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aioexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IOException</span></a> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            ex.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">finally</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                os.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
            <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aioexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IOException</span></a> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                ex.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> clearOutput<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>fc <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                fc <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>FileConnection<span style="color: #009900;">&#41;</span> Connector.<span style="color: #006633;">open</span><span style="color: #009900;">&#40;</span>debugFile, Connector.<span style="color: #006633;">READ_WRITE</span><span style="color: #009900;">&#41;</span>;
            <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aioexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IOException</span></a> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                ex.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
            <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>fc.<span style="color: #006633;">exists</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                fc.<span style="color: #006633;">delete</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
                fc.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
            <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aioexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IOException</span></a> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                ex.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre>
<p>Instructions for use:</p>
<p>1 &#8211; make sure your simulator has an SD card directory setup on you computer. To do this on later RIM JDE versions go to Edit > Preferences > Simulator Tab >  Memory Tab. Check &#8216;Simulate SD Card Inserted&#8217; and &#8216;Use PC Filesystem for SD Card Files&#8217; and select a directory to use by clicking Browse under &#8216;PC filesystem path for SD Card files&#8217;.</p>
<p>2 &#8211; Create the class (Web.java) and add to your project. Syntax for output is:</p>
<pre class="java java" style="font-family:monospace;">Web.<span style="color: #006633;">out</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Test Standard Out&quot;</span><span style="color: #009900;">&#41;</span>;
Web.<span style="color: #006633;">out</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Test Black Out&quot;</span>, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acolor+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Color</span></a>.<span style="color: #006633;">BLACK</span><span style="color: #009900;">&#41;</span>;
Web.<span style="color: #006633;">out</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Test Red Out&quot;</span>, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acolor+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Color</span></a>.<span style="color: #006633;">RED</span><span style="color: #009900;">&#41;</span>;
Web.<span style="color: #006633;">out</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Test Yellow Text, Red background&quot;</span>, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acolor+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Color</span></a>.<span style="color: #006633;">YELLOW</span>, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acolor+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Color</span></a>.<span style="color: #006633;">RED</span><span style="color: #009900;">&#41;</span>;</pre>
<p>3 &#8211; To delete the file contents add the following at the start of your application:</p>
<pre class="java java" style="font-family:monospace;">Web.<span style="color: #006633;">clearOutput</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</pre>
<p>4 &#8211; Run your app once to create the debug.html file on the SDCard, open it in Firefox and (assuming you installed the <a href="https://addons.mozilla.org/en-US/firefox/addon/115">ReloadEvery plugin</a> already) right-click on the page and select &#8216;Reload Every&#8230;&#8217;, choose &#8216;Reload Every 5s&#8217; or choose custom and create a delay of a second or two.</p>
<p>5 &#8211; enjoy clear, clean and colour-coded debugging.</p>
<p>Note &#8211; There&#8217;s also the option to send these html tagged messages to the standard debug output, you can copy the output to a file and see your coloured information stand out clearly amongst the other irrelevant messages, just set the outputmode:</p>
<pre class="java java" style="font-family:monospace;">Web.<span style="color: #006633;">setOutputMode</span><span style="color: #009900;">&#40;</span>Web.<span style="color: #006633;">MODE_OUTPUT</span><span style="color: #009900;">&#41;</span>;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.naviina.eu/wp/blackberry/coloured-debug-output-on-blackberry/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find Your MP BlackBerry application</title>
		<link>http://www.naviina.eu/wp/blackberry/find-your-mp-blackberry-application/</link>
		<comments>http://www.naviina.eu/wp/blackberry/find-your-mp-blackberry-application/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 14:15:22 +0000</pubDate>
		<dc:creator>roygbiv</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[Free]]></category>
		<category><![CDATA[Product_BlackBerry]]></category>

		<guid isPermaLink="false">http://www.naviina.eu/wp/?p=851</guid>
		<description><![CDATA[Find Your MP is a BlackBerry application for UK users that allows you to query the TheyWorkForYou.com database and find out information about MPs based on postcode, name and consituency.  The MP detail screen shows what party the MP belongs to and any positions they&#8217;ve held over various parliament sessions.

The application also displays how [...]]]></description>
			<content:encoded><![CDATA[<p>Find Your MP is a BlackBerry application for UK users that allows you to query the <a href="http://www.theyworkforyou.com/" target="_blank">TheyWorkForYou.com</a> database and find out information about MPs based on postcode, name and consituency.  The MP detail screen shows what party the MP belongs to and any positions they&#8217;ve held over various parliament sessions.</p>
<p><span id="more-851"></span></p>
<p>The application also displays how an MP voted in the <a href="http://en.wikipedia.org/wiki/Digital_Economy_Act_2010" target="_blank">Digital Economy Bill</a> reading in the House of Commons.</p>
<p>In addition, Find Your MP has a link to the related <a href="http://www.voterpower.org.uk" target="_blank">VoterPower</a> mobile site so you can see just how little/much your vote is worth.</p>
<p><img src="http://naviina.eu/resources/twfy001.png" alt="Screenshots" /></p>
<p>The MP and consituency lists are both quite large, after the first time they&#8217;re loaded a copy persists on the device to cut down bandwidth for you and the TheyWorkForYou servers, at any time you can refresh this information from the menu item on both the &#8216;View and Search Mps&#8217; and &#8216;View and Search constituencies&#8217; screens.</p>
<p><img src="http://naviina.eu/resources/twfy002.png" alt="Screenshots" /></p>
<p>Thanks to Matthew at <a href="http://www.theyworkforyou.com/" target="_blank">TheyWorkForYou.com</a> for putting up with my inane API questions over the last 24 hours and Wonky for the logo.</p>
<p><a href="http://appworld.blackberry.com/webstore/content/8439" target="_blank">Find Your MP is available in BlackBerry AppWorld</a> or download it from <a href="http://m.naviina.eu" target="_blank">m.naviina.eu</a> using your BlackBerry browser. (Requires OS4.5 or later)</p>
<p><img src="http://naviina.eu/resources/fympwebbanner.png" alt="Find Your MP" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.naviina.eu/wp/blackberry/find-your-mp-blackberry-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LittleMandlebrot sample code</title>
		<link>http://www.naviina.eu/wp/blackberry/littlemandlebrot-sample-code/</link>
		<comments>http://www.naviina.eu/wp/blackberry/littlemandlebrot-sample-code/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 11:53:27 +0000</pubDate>
		<dc:creator>roygbiv</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.naviina.eu/wp/?p=843</guid>
		<description><![CDATA[Realised today that I&#8217;m 32 and have never coded the Mandlebrot Set. 

Here&#8217;s a quick hack adapted (pretty much line for line) for BlackBerry from Daniel Shiffman&#8217;s example at Processing.org:
package com.naviina.littlemandlebrot;
&#160;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.container.MainScreen;
&#160;
public class LittleMandlebrot extends UiApplication &#123;
&#160;
    public static void main&#40;String&#91;&#93; args&#41; &#123;
       [...]]]></description>
			<content:encoded><![CDATA[<p>Realised today that I&#8217;m 32 and have never coded the Mandlebrot Set. </p>
<p><span id="more-843"></span></p>
<p>Here&#8217;s a quick hack adapted (pretty much line for line) for BlackBerry from <a href="http://www.shiffman.net/" target="_blank">Daniel Shiffman&#8217;s</a> <a href="http://processing.org/learning/topics/mandelbrot.html" target="_blank">example</a> at <a href="http://processing.org/" target="_blank">Processing.org</a>:</p>
<pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.naviina.littlemandlebrot</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.system.Display</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.Graphics</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.UiApplication</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.container.MainScreen</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> LittleMandlebrot <span style="color: #000000; font-weight: bold;">extends</span> UiApplication <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">new</span> LittleMandlebrot<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">enterEventDispatcher</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> LittleMandlebrot<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        pushScreen<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> LittleMandlebrotScreen<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> LittleMandlebrotScreen <span style="color: #000000; font-weight: bold;">extends</span> MainScreen <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">int</span> screenWidth <span style="color: #339933;">=</span> Display.<span style="color: #006633;">getWidth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #000066; font-weight: bold;">int</span> screenHeight <span style="color: #339933;">=</span> Display.<span style="color: #006633;">getHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #000066; font-weight: bold;">float</span> xmin <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">2.5</span>;
    <span style="color: #000066; font-weight: bold;">float</span> ymin <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">2</span>;
    <span style="color: #000066; font-weight: bold;">float</span> wh <span style="color: #339933;">=</span> <span style="color: #cc66cc;">4</span>;
    <span style="color: #000066; font-weight: bold;">float</span> xmax <span style="color: #339933;">=</span> xmin <span style="color: #339933;">+</span> wh;
    <span style="color: #000066; font-weight: bold;">float</span> ymax <span style="color: #339933;">=</span> ymin <span style="color: #339933;">+</span> wh;
    <span style="color: #000066; font-weight: bold;">int</span> maxiterations <span style="color: #339933;">=</span> <span style="color: #cc66cc;">200</span>;
    <span style="color: #000066; font-weight: bold;">float</span> dx <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>xmax <span style="color: #339933;">-</span> xmin<span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span>screenWidth<span style="color: #009900;">&#41;</span>;
    <span style="color: #000066; font-weight: bold;">float</span> dy <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>ymax <span style="color: #339933;">-</span> ymin<span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span>screenHeight<span style="color: #009900;">&#41;</span>;
    <span style="color: #000066; font-weight: bold;">float</span> y <span style="color: #339933;">=</span> ymin;
&nbsp;
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> paint<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Agraphics+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Graphics</span></a> graphics<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        drawMandlebrot<span style="color: #009900;">&#40;</span>graphics<span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">void</span> drawMandlebrot<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Agraphics+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Graphics</span></a> graphics<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Starting Mandlebrot calculations&quot;</span><span style="color: #009900;">&#41;</span>;
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> j <span style="color: #339933;">=</span> 0; j <span style="color: #339933;">&lt;</span> screenHeight; j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">float</span> x <span style="color: #339933;">=</span> xmin;
            <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> 0; i <span style="color: #339933;">&lt;</span> screenWidth; i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">float</span> a <span style="color: #339933;">=</span> x;
                <span style="color: #000066; font-weight: bold;">float</span> b <span style="color: #339933;">=</span> y;
                <span style="color: #000066; font-weight: bold;">int</span> n <span style="color: #339933;">=</span> 0;
                <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>n <span style="color: #339933;">&lt;</span> maxiterations<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000066; font-weight: bold;">float</span> aa <span style="color: #339933;">=</span> a <span style="color: #339933;">*</span> a;
                    <span style="color: #000066; font-weight: bold;">float</span> bb <span style="color: #339933;">=</span> b <span style="color: #339933;">*</span> b;
                    <span style="color: #000066; font-weight: bold;">float</span> twoab <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#41;</span> <span style="color: #cc66cc;">2.0</span> <span style="color: #339933;">*</span> a <span style="color: #339933;">*</span> b;
                    a <span style="color: #339933;">=</span> aa <span style="color: #339933;">-</span> bb <span style="color: #339933;">+</span> x;
                    b <span style="color: #339933;">=</span> twoab <span style="color: #339933;">+</span> y;
                    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>aa <span style="color: #339933;">+</span> bb <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">16.0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #000000; font-weight: bold;">break</span>;
                    <span style="color: #009900;">&#125;</span>
                    n++;
                <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>n <span style="color: #339933;">==</span> maxiterations<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    graphics.<span style="color: #006633;">setColor</span><span style="color: #009900;">&#40;</span>0x000000<span style="color: #009900;">&#41;</span>;
                    graphics.<span style="color: #006633;">drawPoint</span><span style="color: #009900;">&#40;</span>i, j<span style="color: #009900;">&#41;</span>;
                <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                    graphics.<span style="color: #006633;">setColor</span><span style="color: #009900;">&#40;</span>n <span style="color: #339933;">*</span> <span style="color: #cc66cc;">16</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span>;
                    graphics.<span style="color: #006633;">drawPoint</span><span style="color: #009900;">&#40;</span>i, j<span style="color: #009900;">&#41;</span>;
                <span style="color: #009900;">&#125;</span>
                x <span style="color: #339933;">+=</span> dx;
            <span style="color: #009900;">&#125;</span>
            y <span style="color: #339933;">+=</span> dy;
        <span style="color: #009900;">&#125;</span>
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Finished Mandlebrot drawing&quot;</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.naviina.eu/wp/blackberry/littlemandlebrot-sample-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Work in progress sneak peek.</title>
		<link>http://www.naviina.eu/wp/blackberry/work-in-progress-sneak-peek/</link>
		<comments>http://www.naviina.eu/wp/blackberry/work-in-progress-sneak-peek/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 16:44:14 +0000</pubDate>
		<dc:creator>roygbiv</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.naviina.eu/wp/?p=839</guid>
		<description><![CDATA[Current project, making the BlackBerry look more stylish, one app at a time.


]]></description>
			<content:encoded><![CDATA[<p>Current project, making the BlackBerry look more stylish, one app at a time.</p>
<p><span id="more-839"></span></p>
<p><img src="http://naviina.eu/resources/manczeit8900.png" alt="ManchesterZeitgeist" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.naviina.eu/wp/blackberry/work-in-progress-sneak-peek/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>o2 Mobile Broadband on Mac OS X 10.6.2</title>
		<link>http://www.naviina.eu/wp/blog/o2-mobile-broadband-on-mac-os-x-10-6-2/</link>
		<comments>http://www.naviina.eu/wp/blog/o2-mobile-broadband-on-mac-os-x-10-6-2/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 13:52:55 +0000</pubDate>
		<dc:creator>roygbiv</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.naviina.eu/wp/?p=816</guid>
		<description><![CDATA[The installer that comes with the Huawei E160 3G USB stick crashes on Snow Leapord, follow these steps to get your 3G Pay-as-you-go dongle up and running without o2&#8217;s buggy utility app.


- As per the instructions put your SIM into the USB 3G modem then plug it into your Mac.
- Wait for the CD image [...]]]></description>
			<content:encoded><![CDATA[<p>The installer that comes with the Huawei E160 3G USB stick crashes on Snow Leapord, follow these steps to get your 3G Pay-as-you-go dongle up and running without o2&#8217;s buggy utility app.</p>
<p><span id="more-816"></span></p>
<ul>
<li>- As per the instructions put your SIM into the USB 3G modem then plug it into your Mac.</li>
<li>- Wait for the CD image to mount then ctrl-click the MobileConnect appliction and select &#8216;Show Package Contents&#8217;.</li>
<li>- Drill down into the directory structure and double-click Mobile_Connect_Drv_App.pkg &#8211; this will install the drivers for the USB modem.</li>
<li>- OSX should pick up the new connection, click to open Network Preferences or navigate to System Preferences > Network</li>
<li>- Select &#8216;HUAWEI Mobile&#8217; from the pane on the left and enter the following details:<br />
<blockquote><ul>
<li></li>
<li>- Telephone Number: *99#</li>
<li>- Account Name: o2bb</li>
<li>- Password: password</li>
</ul>
</blockquote>
</li>
<li>- Click advanced, set the following details in the modem pane then click OK:<br />
<blockquote><ul>
<li></li>
<li>- Vendor: Generic</li>
<li>- Model: GPRS (GSM/3G)</li>
<li>- APN: m-bb.o2.co.uk</li>
</ul>
</blockquote>
</li>
<li>- Select &#8216;Show modem status in menu bar&#8217; so you get some feedback then click Connect</li>
<li>- Assuming everything&#8217;s gone as planned you can now launch your web browser, navigate to https://mobilebroadbandaccess.o2.co.uk and follow the on-screen instructions to buy data access (you&#8217;ll need your SIM number which is printed on the creditcard you just popped it out of)</li>
<li>- Disconnect the connection by clicking the phone icon in the menu-bar and select &#8216;Disconnect HUAWEI Mobile&#8217; then restart it by doing the same and choosing &#8216;Connect HUAWEI Mobile&#8217;.</li>
<li>- Browse the web!</li>
</ul>
<p>This worked for me &#8211; your mileage may vary.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naviina.eu/wp/blog/o2-mobile-broadband-on-mac-os-x-10-6-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Magic String &#8211; BlackBerry</title>
		<link>http://www.naviina.eu/wp/blackberry/the-magic-string-blackberry/</link>
		<comments>http://www.naviina.eu/wp/blackberry/the-magic-string-blackberry/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 08:31:42 +0000</pubDate>
		<dc:creator>roygbiv</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.naviina.eu/wp/?p=786</guid>
		<description><![CDATA[I had some discussion on Twitter this week about the secret connection string that allows BlackBerry applications to use Rim&#8217;s BIS-B transport for network connections &#8211; I couldn&#8217;t put my point across in a tweet so here&#8217;s the gist. 

A few years ago a rumour went round that there was a special suffix you could [...]]]></description>
			<content:encoded><![CDATA[<p>I had some discussion on Twitter this week about the secret connection string that allows BlackBerry applications to use Rim&#8217;s BIS-B transport for network connections &#8211; I couldn&#8217;t put my point across in a tweet so here&#8217;s the gist. </p>
<p><span id="more-786"></span></p>
<p>A few years ago a rumour went round that there was a special suffix you could add to your connection string on a BlackBerry app that magically removed all the headaches associated with using DirectTCP and tunelling through the carriers WAP gateway, it did away with the need for users to enter their carrier APN settings &#8211; or maintain an unreliable internal look-up list. </p>
<p>Actually I remember someone noticing that Googletalk connected fine without the APN being entered, they hacked into the app and found a lookup list of APNs, they did some more digging and found that this was a red-herring to disguise the actual connection method, this was back when it was unclear who&#8217;d developed Googletalk.</p>
<p>Fast-forward a couple of years and this connection method has become semi-official, if you want to connect using this suffix you&#8217;re supposed to apply to Rim.</p>
<p>There&#8217;s an <a href="http://supportforums.blackberry.com/t5/Java-Development/Connecting-your-BlackBerry-http-and-socket-connections-to-the/m-p/206254" target="_blank">extremely useful sticky thread on the official BlackBerry forums by Peter Strange</a> that goes into detail about the different connection methods on BlackBerry so I won&#8217;t repeat that content here &#8211; but it&#8217;s an essential read for any BlackBerry developer.</p>
<p>Why does Rim want this connection string kept secret? When you apply to Rim for permission to use this connection method you have to fill in a form that states various parameters including:</p>
<p>- Size of each transaction.<br />
- Frequency of connections.</p>
<p>How large is the data your app will be sending and how often will it send it? This data allows Rim to properly scale the service and ensure it runs smoothly. If lots of third party developers use this method without thinking about the impact they&#8217;re having it could lead to an unreliable service. Imagine a developer that has a video upload application, it uses a lot of bandwidth and they use this connection string unofficially, now imagine their app becomes &#8216;the next big thing&#8217; and they suddenly have millions of users &#8211; it&#8217;d potentially knock out BIS-B &#8211; and BIS-B is the channel BIS (consumer) BlackBerry&#8217;s use to browse the web from the native browser.</p>
<p>Should you use the magic string? I have in the past and the app is still up and running fine. Someone in Rim told me around a year ago that they&#8217;re looking into possibly having a whitelist of approved apps in the future and blocking any apps using the channel without permission. I don&#8217;t know if this has changed. If you do use it your users might one day find their app can&#8217;t connect anymore, then again; this might never happen. Plus, as <a href="http://twitter.com/davidmccormack" target="_blank">David McCormack said on Twitter</a>:</p>
<blockquote><p>Doing so would break countless popular apps &#8211; a bad move if they&#8217;re trying to boost the platform&#8217;s popularity among developers.</p></blockquote>
<p>We&#8217;re in a bit of a crazy situation. If we don&#8217;t use this extremely robust and reliable method of connecting to the network our apps are inferior to competitors who do use it, if we do use it (without permission) we don&#8217;t make any friends at Rim. We&#8217;re not all huge enterprise alliance partners so the situation essentially creates two tiers of apps. The wealthy get a more reliable connection method.</p>
<p>Another question is why on earth does a company that&#8217;s a leader in security expose such a big feature with nothing more than a special secret string? Security through obscurity is no security at all.</p>
<p>This post is largely conjecture and opinion, if there are any errors let me know and I&#8217;ll put in a correction.</p>
<hr />
<div align="right">
feedback, errata, insults: <img src="http://www.naviina.eu/resources/roygbivsig.png" align="middle" STYLE="border: none;">
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.naviina.eu/wp/blackberry/the-magic-string-blackberry/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>NordvästLibrary for BlackBerry Developers</title>
		<link>http://www.naviina.eu/wp/blackberry/nordvastlibrary-for-blackberry-developers/</link>
		<comments>http://www.naviina.eu/wp/blackberry/nordvastlibrary-for-blackberry-developers/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 16:07:25 +0000</pubDate>
		<dc:creator>roygbiv</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[Product_BlackBerry]]></category>

		<guid isPermaLink="false">http://www.naviina.eu/wp/?p=763</guid>
		<description><![CDATA[NordvästLibrary is a growing collection of components you can use in your BlackBerry applications. There are two versions of the library; one for pre-OS5.0 API and another for post-OS5.0 API.

Latest Version: 1.1
Browse the Javadoc
NordScreen is a screen class that behaves the same way as MainScreen but has some added functionality, it includes the transition behavior [...]]]></description>
			<content:encoded><![CDATA[<p>NordvästLibrary is a growing collection of components you can use in your BlackBerry applications. There are two versions of the library; one for pre-OS5.0 API and another for post-OS5.0 API.</p>
<p><span id="more-763"></span></p>
<p>Latest Version: 1.1<br />
Browse the <a href="http://www.naviina.eu/software/nordvastlibrary/doc/" target="_blank">Javadoc</a></p>
<p><strong>NordScreen</strong> is a screen class that behaves the same way as MainScreen but has some added functionality, it includes the transition behavior described in the <a href="http://www.naviina.eu/wp/blackberry/blackberry-transitionscreen-class/" target="_blank">BlackBerryTransitionScreen class post</a> (for the OS5.0 version of the library) and also the Loading popup described in the <a href="http://www.naviina.eu/wp/blackberry/loading-class-for-blackberry/" target="_blank">Loading class for BlackBerry post</a>.</p>
<p><strong>NordFieldManager</strong> is similar to the <a href="http://docs.blackberry.com/en/developers/deliverables/11945/Eyelid_field_925609_11.jsp" target="_blank">EyelidFieldManager</a> new to OS5.0 but allows greater control over the behavior of the top and bottom managers. It also adds the ability to add fields into a standard VerticalFieldManager as well as using absolute coordinates. In addition it enables developers to have the same behavior as the EyelidFieldManager on pre-OS5.0 devices (although the transparancy on the animated VerticalFieldManagers is lost). </p>
<p><strong>SpacerField</strong> is similar to the native <a href="http://www.blackberry.com/developers/docs/4.2api/net/rim/device/api/ui/component/SeparatorField.html" target="_blank">SeparatorField</a> but is a little more versatile and allows you set the color, height and width with various constructors. Is useful for padding and laying out screens.</p>
<p><strong>CuteLabel</strong> is a fantastic little field for creating header sections and clickable labels. You can have an icon aligned to the left or right and control all aspects of the look n&#8217; feel.</p>
<p>We&#8217;ll add more to this post as new features are added.</p>
<p><a rel="license" href="http://creativecommons.org/licenses/by-nd/3.0/" target="_blank"><img alt="Creative Commons License" style="border-width:0" src="http://creativecommons.org/images/public/somerights20.png" /></a></p>
<p>Use of the library is subject to a CreativeCommons Licence, you are free to use the library in commercial works but must include a notification giving attribution to naviina &#8211; this can be as simple as a LabelField on your &#8216;about screen&#8217; saying something similar to:</p>
<blockquote><p><strong>This product uses the NordvästLibrary from naviina.eu</strong></p></blockquote>
<p><strong>1.1</strong> <a href="http://www.naviina.eu/software/nordvastlibrary/NordvastLibrary1_1.zip">Download here</a> &#8211; added SpacerField and CuteLabel classes.</p>
<p><strong>1.0</strong> Download the early first release <a href="http://www.naviina.eu/software/nordvastlibrary/NordvastLibrary1_0.zip">here</a>.</p>
<p>Please mail roygbiv at the address below with any issues.</p>
<hr />
<div align="right">
feedback, errata, insults: <img src="http://www.naviina.eu/resources/roygbivsig.png" align="middle" STYLE="border: none;">
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.naviina.eu/wp/blackberry/nordvastlibrary-for-blackberry-developers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BlackBerry TransitionScreen class</title>
		<link>http://www.naviina.eu/wp/blackberry/blackberry-transitionscreen-class/</link>
		<comments>http://www.naviina.eu/wp/blackberry/blackberry-transitionscreen-class/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 09:49:24 +0000</pubDate>
		<dc:creator>roygbiv</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://www.naviina.eu/wp/?p=753</guid>
		<description><![CDATA[I&#8217;m working on a project that&#8217;s going to be using the 5.0 api so sat down this weekend and wrapped up the screen transition logic into a nice simple class (as suggested here).

Usage &#8211; extend TransitionScreen and pass one of the 5 transition type constants to the super class:
import net.rim.device.api.ui.TransitionContext;
&#160;
public class MyScreen extends TransitionScreen&#123;
&#160;
  [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on a project that&#8217;s going to be using the 5.0 api so sat down this weekend and wrapped up the screen transition logic into a nice simple class (<a href="http://www.naviina.eu/wp/blackberry/simple-transition-screen-example-for-blackberry-5-0-beta">as suggested here</a>).</p>
<p><span id="more-753"></span></p>
<p>Usage &#8211; extend TransitionScreen and pass one of the 5 transition type constants to the super class:</p>
<pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.TransitionContext</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyScreen <span style="color: #000000; font-weight: bold;">extends</span> TransitionScreen<span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> MyScreen<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">TRANSITION_FADE</span><span style="color: #009900;">&#41;</span>;
        setTitle<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;My Screen&quot;</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre>
<p>and the class source:</p>
<pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.TransitionContext</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.Ui</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.UiEngineInstance</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.container.MainScreen</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TransitionScreen <span style="color: #000000; font-weight: bold;">extends</span> MainScreen <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> TransitionScreen<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> transitionType<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        attachTransition<span style="color: #009900;">&#40;</span>transitionType<span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//second constructor for passing styles to MainScreen superclass </span>
    <span style="color: #000000; font-weight: bold;">public</span> TransitionScreen<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> transitionType, <span style="color: #000066; font-weight: bold;">long</span> mainscreenStyle<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>mainscreenStyle<span style="color: #009900;">&#41;</span>;
        attachTransition<span style="color: #009900;">&#40;</span>transitionType<span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> attachTransition<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> transitionType<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        UiEngineInstance engine <span style="color: #339933;">=</span> Ui.<span style="color: #006633;">getUiEngineInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
        TransitionContext pushAction <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span>;
        TransitionContext popAction <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span>;
&nbsp;
        <span style="color: #000000; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>transitionType<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">case</span> TransitionContext.<span style="color: #006633;">TRANSITION_FADE</span><span style="color: #339933;">:</span>
                pushAction <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TransitionContext<span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">TRANSITION_FADE</span><span style="color: #009900;">&#41;</span>;
                popAction <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TransitionContext<span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">TRANSITION_FADE</span><span style="color: #009900;">&#41;</span>;
&nbsp;
                pushAction.<span style="color: #006633;">setIntAttribute</span><span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">ATTR_DURATION</span>, <span style="color: #cc66cc;">750</span><span style="color: #009900;">&#41;</span>;
                popAction.<span style="color: #006633;">setIntAttribute</span><span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">ATTR_DURATION</span>, <span style="color: #cc66cc;">750</span><span style="color: #009900;">&#41;</span>;
                <span style="color: #000000; font-weight: bold;">break</span>;
            <span style="color: #000000; font-weight: bold;">case</span> TransitionContext.<span style="color: #006633;">TRANSITION_NONE</span><span style="color: #339933;">:</span>
                pushAction <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TransitionContext<span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">TRANSITION_NONE</span><span style="color: #009900;">&#41;</span>;
                popAction <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TransitionContext<span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">TRANSITION_NONE</span><span style="color: #009900;">&#41;</span>;
                <span style="color: #000000; font-weight: bold;">break</span>;
            <span style="color: #000000; font-weight: bold;">case</span> TransitionContext.<span style="color: #006633;">TRANSITION_SLIDE</span><span style="color: #339933;">:</span>
                pushAction <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TransitionContext<span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">TRANSITION_SLIDE</span><span style="color: #009900;">&#41;</span>;
                popAction <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TransitionContext<span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">TRANSITION_SLIDE</span><span style="color: #009900;">&#41;</span>;
&nbsp;
                pushAction.<span style="color: #006633;">setIntAttribute</span><span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">ATTR_DURATION</span>, <span style="color: #cc66cc;">750</span><span style="color: #009900;">&#41;</span>;
                pushAction.<span style="color: #006633;">setIntAttribute</span><span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">ATTR_DIRECTION</span>, TransitionContext.<span style="color: #006633;">DIRECTION_LEFT</span><span style="color: #009900;">&#41;</span>;
&nbsp;
                popAction.<span style="color: #006633;">setIntAttribute</span><span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">ATTR_DURATION</span>, <span style="color: #cc66cc;">750</span><span style="color: #009900;">&#41;</span>;
                popAction.<span style="color: #006633;">setIntAttribute</span><span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">ATTR_DIRECTION</span>, TransitionContext.<span style="color: #006633;">DIRECTION_RIGHT</span><span style="color: #009900;">&#41;</span>;
                <span style="color: #000000; font-weight: bold;">break</span>;
            <span style="color: #000000; font-weight: bold;">case</span> TransitionContext.<span style="color: #006633;">TRANSITION_WIPE</span><span style="color: #339933;">:</span>
                pushAction <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TransitionContext<span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">TRANSITION_WIPE</span><span style="color: #009900;">&#41;</span>;
                popAction <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TransitionContext<span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">TRANSITION_WIPE</span><span style="color: #009900;">&#41;</span>;
                <span style="color: #000000; font-weight: bold;">break</span>;
            <span style="color: #000000; font-weight: bold;">case</span> TransitionContext.<span style="color: #006633;">TRANSITION_ZOOM</span><span style="color: #339933;">:</span>
                pushAction <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TransitionContext<span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">TRANSITION_ZOOM</span><span style="color: #009900;">&#41;</span>;
                popAction <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TransitionContext<span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">TRANSITION_ZOOM</span><span style="color: #009900;">&#41;</span>;
                <span style="color: #000000; font-weight: bold;">break</span>;
            <span style="color: #000000; font-weight: bold;">default</span><span style="color: #339933;">:</span>
                pushAction <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TransitionContext<span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">TRANSITION_NONE</span><span style="color: #009900;">&#41;</span>;
                popAction <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TransitionContext<span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">TRANSITION_NONE</span><span style="color: #009900;">&#41;</span>;
        <span style="color: #009900;">&#125;</span>
        engine.<span style="color: #006633;">setTransition</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span>, <span style="color: #000000; font-weight: bold;">this</span>, UiEngineInstance.<span style="color: #006633;">TRIGGER_PUSH</span>, pushAction<span style="color: #009900;">&#41;</span>;
        engine.<span style="color: #006633;">setTransition</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, <span style="color: #000066; font-weight: bold;">null</span>, UiEngineInstance.<span style="color: #006633;">TRIGGER_POP</span>, popAction<span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre>
<p>In the above code I&#8217;ve customized the values for the SLIDE and FADE transition, I&#8217;m not a fan of WIPE and ZOOM so I&#8217;ve left the default behavior intact as they won&#8217;t get used. In all other respects this class behaves the same as MainScreen so just use it in the same way as normal.</p>
<hr />
<div align="right">
feedback, errata, insults: <img src="http://www.naviina.eu/resources/roygbivsig.png" align="middle" STYLE="border: none;">
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.naviina.eu/wp/blackberry/blackberry-transitionscreen-class/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>BUnit2 &#8211; update to old port of JMUnit to BlackBerry</title>
		<link>http://www.naviina.eu/wp/blackberry/bunit2-update-to-old-port-of-jmunit-to-blackberry/</link>
		<comments>http://www.naviina.eu/wp/blackberry/bunit2-update-to-old-port-of-jmunit-to-blackberry/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 09:52:57 +0000</pubDate>
		<dc:creator>roygbiv</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://www.naviina.eu/wp/?p=733</guid>
		<description><![CDATA[Update to bUnit which was a quick port I did of JMUnit a few years ago. BUnit2 has taken the old version and polished it to make it a little slicker, it should also be more useable/useful.


You can now add seperators between groups of tests and different test classes. I&#8217;ve also added a couple of [...]]]></description>
			<content:encoded><![CDATA[<p>Update to <a href="http://sourceforge.net/projects/b-unittesting/" target="_blank">bUnit</a> which was a quick port I did of <a href="http://sourceforge.net/projects/jmunit/" target="_blank">JMUnit</a> a few years ago. BUnit2 has taken the old version and polished it to make it a little slicker, it should also be more useable/useful.</p>
<p><span id="more-733"></span></p>
<p><img src="http://www.naviina.eu/wp/wp-content/uploads/2009/11/BUnit2.png" alt="BUnit2" title="BUnit2" width="472" height="705" class="alignnone size-full wp-image-739" /></p>
<p>You can now add seperators between groups of tests and different test classes. I&#8217;ve also added a couple of convenience tests for &#8216;greater than&#8217; and &#8216;less than&#8217; (integer only).</p>
<p>Illustrating adding a display separator as seen in above screenshot:</p>
<pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> DemoAppTests <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> DemoAppTests<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> runTests<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> AssertionFailedException <span style="color: #009900;">&#123;</span>
        Assertion.<span style="color: #006633;">addSeparator</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Config Tests&quot;</span><span style="color: #009900;">&#41;</span>;
        testSetUsername<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
        testPasswordsMatch<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
        testIncorrectPassword<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
        testNewPassword<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
        Assertion.<span style="color: #006633;">addSeparator</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Network Tests&quot;</span><span style="color: #009900;">&#41;</span>;
        testCanPing<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
        testCanDownload<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
        testConfigSax<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
        testIconDownload<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
        testGetRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
        testPostRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
    ...</pre>
<p>The name-spacing has also been tidied up:</p>
<blockquote><p>com.naviina.bunit &#8211; Contains display screen and test runner class<br />
com.naviina.bunit.jmunit &#8211; All the ported JMUnit source plus some BlackBerry specific logic/fields<br />
com.naviina.bunit.resources &#8211; couple of images (thanks to <a href="http://www.famfamfam.com/" target="_blank">famfamfam</a>)<br />
com.naviina.bunit.tests &#8211; Where you keep your tests</p></blockquote>
<p>If you have a large number of tests you may want to thread the logic and/or bypass the ui and write directly to System.out instead &#8211; the source is easily hackable. If you&#8217;re using it as-is you just need to add your test class to the tests package then add a call to it in the RunTests() method of TestRunner.java (you can also add multiple test classes to keep things manageable). <a href="http://www.naviina.eu/wp/wp-content/uploads/2009/11/BUnit2Beta.zip">Download a beta version here</a>, it includes the demo tests shown above, I&#8217;ll review the codebase and make sure the correct GNU notifications are in place before I figure out the <a href="http://sourceforge.net/projects/b-unittesting/" target="_blank">SourceForge repository</a> again (it&#8217;s been a while). If you use this please let me know, I&#8217;ve been finding out lately that lots of people have been using the old version and I had no idea.</p>
<hr />
<div align="right">
feedback, errata, insults: <img src="http://www.naviina.eu/resources/roygbivsig.png" align="middle" STYLE="border: none;">
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.naviina.eu/wp/blackberry/bunit2-update-to-old-port-of-jmunit-to-blackberry/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Simple Transition Screen Example For BlackBerry (5.0 Beta)</title>
		<link>http://www.naviina.eu/wp/blackberry/simple-transition-screen-example-for-blackberry-5-0-beta/</link>
		<comments>http://www.naviina.eu/wp/blackberry/simple-transition-screen-example-for-blackberry-5-0-beta/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 15:36:12 +0000</pubDate>
		<dc:creator>roygbiv</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://www.naviina.eu/wp/?p=711</guid>
		<description><![CDATA[The BlackBerry API for OS 5.0 (beta) introduces the ability to use slick screen transitions (Viigo has had this for a while) but for some reason both examples from Rim use needlessly complex logic that is guaranteed to confuse newer BlackBerry developers, below is a very simple application that doesn&#8217;t make use of Runnable/Threads.

First create [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://na.blackberry.com/eng/developers/devbetasoftware/javasdk5.jsp" target="_blank">BlackBerry API for OS 5.0 (beta)</a> introduces the ability to use slick screen transitions (<a href="http://www.viigo.com" target="_blank">Viigo</a> has had this for a while) but for some reason <a href="http://docs.blackberry.com/en/developers/deliverables/9094/Screen_transitions_detailed_overview_806391_11.jsp" target="_blank">both</a> <a href="http://www.blackberry.com/go/screentransitionssample" target="_blank">examples</a> from Rim use needlessly complex logic that is guaranteed to <a href="http://en.wikipedia.org/wiki/Red_herring_(idiom)" target="_blank">confuse</a> newer BlackBerry developers, below is a very simple application that doesn&#8217;t make use of Runnable/Threads.</p>
<p><span id="more-711"></span></p>
<p>First create your app and push a homescreen to start on:</p>
<pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.UiApplication</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ScreenTransitions <span style="color: #000000; font-weight: bold;">extends</span> UiApplication<span style="color: #009900;">&#123;</span>
    ScreenTransitions app <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">this</span>;
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">new</span> ScreenTransitions<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">enterEventDispatcher</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> ScreenTransitions<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        pushScreen<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> HomeScreen<span style="color: #009900;">&#40;</span>app<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre>
<p>The homescreen class including the procedure to attach the transition to the target screen:</p>
<pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.Field</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.FieldChangeListener</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.component.ButtonField</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.container.MainScreen</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.*</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.container.*</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.component.*</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> HomeScreen <span style="color: #000000; font-weight: bold;">extends</span> MainScreen <span style="color: #000000; font-weight: bold;">implements</span> FieldChangeListener <span style="color: #009900;">&#123;</span>
    ScreenTransitions app;
    ButtonField nextButton <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ButtonField<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Next Screen&quot;</span>, ButtonField.<span style="color: #006633;">CONSUME_CLICK</span><span style="color: #009900;">&#41;</span>;
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> HomeScreen<span style="color: #009900;">&#40;</span>ScreenTransitions app<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        setTitle<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Home Screen&quot;</span><span style="color: #009900;">&#41;</span>;
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">app</span> <span style="color: #339933;">=</span> app;
        nextButton.<span style="color: #006633;">setChangeListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>;
        add<span style="color: #009900;">&#40;</span>nextButton<span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> fieldChanged<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Afield+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Field</span></a> field, <span style="color: #000066; font-weight: bold;">int</span> context<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>field <span style="color: #339933;">==</span> nextButton<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            ContentScreen contentScreen <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ContentScreen<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
            UiEngineInstance engine <span style="color: #339933;">=</span> Ui.<span style="color: #006633;">getUiEngineInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
            TransitionContext transitionContextPush <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TransitionContext<span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">TRANSITION_SLIDE</span><span style="color: #009900;">&#41;</span>;
            transitionContextPush.<span style="color: #006633;">setIntAttribute</span><span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">ATTR_DURATION</span>, <span style="color: #cc66cc;">750</span><span style="color: #009900;">&#41;</span>;
            transitionContextPush.<span style="color: #006633;">setIntAttribute</span><span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">ATTR_DIRECTION</span>, TransitionContext.<span style="color: #006633;">DIRECTION_LEFT</span><span style="color: #009900;">&#41;</span>;
&nbsp;
            TransitionContext transitionContextPop <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TransitionContext<span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">TRANSITION_SLIDE</span><span style="color: #009900;">&#41;</span>;
            transitionContextPop.<span style="color: #006633;">setIntAttribute</span><span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">ATTR_DURATION</span>, <span style="color: #cc66cc;">750</span><span style="color: #009900;">&#41;</span>;
            transitionContextPop.<span style="color: #006633;">setIntAttribute</span><span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">ATTR_DIRECTION</span>, TransitionContext.<span style="color: #006633;">DIRECTION_RIGHT</span><span style="color: #009900;">&#41;</span>;
            transitionContextPop.<span style="color: #006633;">setIntAttribute</span><span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">ATTR_KIND</span>, TransitionContext.<span style="color: #006633;">KIND_OUT</span><span style="color: #009900;">&#41;</span>;
&nbsp;
            engine.<span style="color: #006633;">setTransition</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span>, contentScreen, UiEngineInstance.<span style="color: #006633;">TRIGGER_PUSH</span>, transitionContextPush<span style="color: #009900;">&#41;</span>;
            engine.<span style="color: #006633;">setTransition</span><span style="color: #009900;">&#40;</span>contentScreen, <span style="color: #000066; font-weight: bold;">null</span>, UiEngineInstance.<span style="color: #006633;">TRIGGER_POP</span>, transitionContextPop<span style="color: #009900;">&#41;</span>;
&nbsp;
            app.<span style="color: #006633;">pushScreen</span><span style="color: #009900;">&#40;</span>contentScreen<span style="color: #009900;">&#41;</span>;
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> onClose<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">exit</span><span style="color: #009900;">&#40;</span>0<span style="color: #009900;">&#41;</span>;
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span>;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre>
<p>Finally, your target screen:</p>
<pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.container.MainScreen</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> ContentScreen <span style="color: #000000; font-weight: bold;">extends</span> MainScreen <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> ContentScreen<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        setTitle<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content Screen&quot;</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre>
<p>This creates an application with a screen that scrolls in from right to left when it&#8217;s pushed and the opposite when it&#8217;s popped, you could create a custom screen that extends MainScreen with it&#8217;s own pushScreen method to hide all the UiEngine logic and keep things clean. Remember it&#8217;ll be months, maybe a year, before the majority of your users have gone through the 12-18 month upgrade cycle and will have access to the new features introduced in OS 5.0.</p>
<p>A really nice cross-fade effect is possible by swapping out the TransitionContext code in the example above with:</p>
<pre class="java java" style="font-family:monospace;">TransitionContext transitionContextIn <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TransitionContext<span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">TRANSITION_FADE</span><span style="color: #009900;">&#41;</span>;
transitionContextIn.<span style="color: #006633;">setIntAttribute</span><span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">ATTR_DURATION</span>, <span style="color: #cc66cc;">750</span><span style="color: #009900;">&#41;</span>;
&nbsp;
TransitionContext transitionContextOut <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TransitionContext<span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">TRANSITION_FADE</span><span style="color: #009900;">&#41;</span>;
transitionContextOut.<span style="color: #006633;">setIntAttribute</span><span style="color: #009900;">&#40;</span>TransitionContext.<span style="color: #006633;">ATTR_DURATION</span>, <span style="color: #cc66cc;">750</span><span style="color: #009900;">&#41;</span>;</pre>
<p>Setting the ATTR_KIND value is supposed to indicate which way an effect works, a fade effect with ATTR_KIND of KIND_IN would change the opacity from 0% to 100% while KIND_OUT would reverse the effect from 100% to 0%.</p>
<hr />
<div align="right">
feedback, errata, insults: <img src="http://www.naviina.eu/resources/roygbivsig.png" align="middle" STYLE="border: none;">
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.naviina.eu/wp/blackberry/simple-transition-screen-example-for-blackberry-5-0-beta/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
