<?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>Bloggings of randomness &#187; Techie stuff</title>
	<atom:link href="http://blog.cluepusher.dk/category/tech/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.cluepusher.dk</link>
	<description>Diary and thoughtspace of Rune B. Broberg</description>
	<lastBuildDate>Mon, 26 Sep 2011 20:10:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How noisy is my ATX power supply?</title>
		<link>http://blog.cluepusher.dk/2011/09/26/how-noisy-is-my-atx-power-supply/</link>
		<comments>http://blog.cluepusher.dk/2011/09/26/how-noisy-is-my-atx-power-supply/#comments</comments>
		<pubDate>Mon, 26 Sep 2011 20:10:57 +0000</pubDate>
		<dc:creator>mihtjel</dc:creator>
				<category><![CDATA[Techie stuff]]></category>

		<guid isPermaLink="false">http://blog.cluepusher.dk/?p=223</guid>
		<description><![CDATA[Like so many others, I have constructed a simple lab supply, mainly for 12v DC, from an old but usable ATX power supply. The instructions on how to do this are countless, and there&#8217;s really nothing very complicated about it. I thought I&#8217;d done fairly well when I was finished with it &#8211; it delivers [...]]]></description>
			<content:encoded><![CDATA[<p>Like so many others, I have constructed a simple lab supply, mainly for 12v DC, from an old but usable ATX power supply. The instructions on how to do this are countless, and there&#8217;s really nothing very complicated about it. I thought I&#8217;d done fairly well when I was finished with it &#8211; it delivers far more power than any of the proper lab supplies at <a href="http://osaa.dk/">OSAA</a>, and it was very, very cheap. Free, mostly.</p>
<p>As it turns out, there is a bit of noise on the output of one of these ATX supplies. I discovered this after working some hours on a design involving a MAX660CPA at OSAA, and in particular on eliminating the noise it produced. After succeeding, I came home only to discover that the noise had reappeared! And even spread to the +5v rail, not just the -5v. And the +12v rail&#8230; at which point I started considering that it might not be the MAX660.</p>
<p>Today I decided to do a quick measurement of the noise produced at idle from the power supply (the +5v and +3.3v rails are loaded by resistors inside the PSU to stabilize the outputs). All the following pics are quick snaps from my phone, at 50μs/div horizontal:</p>
<div id="attachment_224" class="wp-caption aligncenter" style="width: 410px"><a href="http://blog.cluepusher.dk/wp-content/uploads/2011/09/6186568258_ea98b8778a_b.jpg"><img class="size-medium wp-image-224" title="12v" src="http://blog.cluepusher.dk/wp-content/uploads/2011/09/6186568258_ea98b8778a_b-400x253.jpg" alt="" width="400" height="253" /></a><p class="wp-caption-text">12v rail - 50mV/div vertical</p></div>
<div id="attachment_225" class="wp-caption aligncenter" style="width: 410px"><a href="http://blog.cluepusher.dk/wp-content/uploads/2011/09/5v.jpg"><img class="size-medium wp-image-225" title="5v" src="http://blog.cluepusher.dk/wp-content/uploads/2011/09/5v-400x275.jpg" alt="" width="400" height="275" /></a><p class="wp-caption-text">5v rail - 10mV/div vertical</p></div>
<div id="attachment_226" class="wp-caption aligncenter" style="width: 410px"><a href="http://blog.cluepusher.dk/wp-content/uploads/2011/09/3.3v.jpg"><img class="size-medium wp-image-226" title="3.3v" src="http://blog.cluepusher.dk/wp-content/uploads/2011/09/3.3v-400x239.jpg" alt="" width="400" height="239" /></a><p class="wp-caption-text">3.3v rail - 10mV/div vertical</p></div>
<p>To summarize:</p>
<ul>
<li>12v rail shows 50mV consistent ripple, and 200mV peak-to-peak spikes</li>
<li>5v rail shows about 30mV consistent ripple, and about 60mV peak-to-peak spikes</li>
<li>3.3v rail shows a very clear 20mV peak-to-peak square wave, and about 50mV peak-to-peak spikes</li>
</ul>
<p>My guess is my next post is going to have to be on how to clean up these power outputs for the sort of work I want to do currently of measuring a few mV of change across a small resistor to calculate current. <img src='http://blog.cluepusher.dk/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cluepusher.dk/2011/09/26/how-noisy-is-my-atx-power-supply/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple fan mod for Tektronix 2235</title>
		<link>http://blog.cluepusher.dk/2011/02/16/simple-fan-mod-for-tektronix-2235/</link>
		<comments>http://blog.cluepusher.dk/2011/02/16/simple-fan-mod-for-tektronix-2235/#comments</comments>
		<pubDate>Wed, 16 Feb 2011 19:28:22 +0000</pubDate>
		<dc:creator>mihtjel</dc:creator>
				<category><![CDATA[Techie stuff]]></category>

		<guid isPermaLink="false">http://blog.cluepusher.dk/?p=219</guid>
		<description><![CDATA[After repairing my Tektronix 2235 oscilloscope, I noticed that the heat sink cooling the MOSFET in the switching power supply, as well as the two transistors in the inverter circuit, was getting rather warm &#8211; and more than I liked it, anyway. I definitely didn&#8217;t fancy having to repair it all again, or getting something [...]]]></description>
			<content:encoded><![CDATA[<p>After repairing my Tektronix 2235 oscilloscope, I noticed that the heat sink cooling the MOSFET in the switching power supply, as well as the two transistors in the inverter circuit, was getting rather warm &#8211; and more than I liked it, anyway. I definitely didn&#8217;t fancy having to repair it all again, or getting something happen to it like <a href="http://www.flickr.com/photos/mihtjel/5444727509/">the 2230 we looked at fixing</a> &#8211; briefly &#8211; at <a href="http://osaa.dk">OSAA</a>.</p>
<p>So I decided to do a little mod, inspired by the service manual for a Tektronix 2236 &#8211; same scope with a counter/multimeter addon, and, crucially, a fan to cool the power supply. All the markings etc. were there on the circuit board of my scope, it just didn&#8217;t have any components installed.</p>
<p>To do the mod, you need:</p>
<ol>
<li>270μF capacitor, 25v or summat. I used a 220μF low ESR one I had anyway.</li>
<li>A 22 Ohm resistor, 1/4 watt</li>
<li>A diode. I used a BYV 26C, 1A 600V switchmode-diode. This is absolutely overkill, but then again, I had one from when I fixed the power supply&#8230; It needs to rectify the -8.6V 20KHz from the transformer, and deliver enough power to run the fan, so possibly not a 1N4148..</li>
<li>60mm 12V fan &#8211; the one I used is 1.4W at 12V, and ends up running at -5.71V, slowly and quietly. The original specs call for using +5 instead of ground, giving about 10V total across the fan &#8211; but then it&#8217;ll be noisy.</li>
</ol>
<p>The components are the 965 components on the circuit &#8211; they&#8217;re near all the caps for the low voltage supplies. CR965 is the diode, C965 is the capacitor and R965 is the resistor. And there&#8217;s even two pads for soldering in a connector for the fan.</p>
<p>Of course, this is all done at your own risk &#8211; I&#8217;ve yet to see if my scope blows up from this, though I doubt it. And it does mean I&#8217;ll be able to hear if it&#8217;s on or not, rather than having to wait for something to show up on the CRT &#8230; <img src='http://blog.cluepusher.dk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cluepusher.dk/2011/02/16/simple-fan-mod-for-tektronix-2235/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Notes on fixing a Tektronix 2235</title>
		<link>http://blog.cluepusher.dk/2011/01/27/notes-on-fixing-a-tektronix-2235/</link>
		<comments>http://blog.cluepusher.dk/2011/01/27/notes-on-fixing-a-tektronix-2235/#comments</comments>
		<pubDate>Thu, 27 Jan 2011 21:37:36 +0000</pubDate>
		<dc:creator>mihtjel</dc:creator>
				<category><![CDATA[Techie stuff]]></category>

		<guid isPermaLink="false">http://blog.cluepusher.dk/?p=216</guid>
		<description><![CDATA[A colleague found an old Tektronix 2235 in his shed, and thought nicely I might like to have it. Sadly, it blew its fuse after working for a few minutes when he plugged it in &#8211; and I decided to have a go at fixing it. MOSFET P9070 had died a violent death, with notable [...]]]></description>
			<content:encoded><![CDATA[<p>A colleague found an old Tektronix 2235 in his shed, and thought nicely I might like to have it. Sadly, it blew its fuse after working for a few minutes when he plugged it in &#8211; and I decided to have a go at fixing it.</p>
<p>MOSFET P9070 had died a violent death, with notable effects on the MOLEX connector it&#8217;s in, as well as the plastic surround strapping it to the heat sink. It had killed R909 &#8211; the 39 ohm resistor between it and Q908, not on the schematic but in an addendum &#8211; Q908 and CR907 as well.</p>
<p>The MOSFET can be an IRF720 it seems, which is a nice and cheap component. Q908 I ended up using a 2N2907, which was slightly more difficult to come by. It&#8217;s just a PNP switching transistor, so might be easier to find something else that&#8217;ll stand the voltage.</p>
<p>The diode I first tried replacing with a 1N4007 &#8211; this didn&#8217;t turn out well. Another colleague found me a BYV 26E, 1000v/1a 75ns fast recovery diode, which works fine. However: After the first killing of the diode, it appears the MOSFET and transistor were taken out again, and I failed to notice. Caveat: Check these components every time a line power trial fails, as they may just be fried&#8230;</p>
<p>I ended up replacing U930 with a TL494 (about $1 for that) as well, and found a good way of testing it: Apply ~10v between TP940 and pin 12 of U930, and look for a sawtooth signal at pin 5.</p>
<p>Some of my testing I did with line voltage, but as mentioned before, I had problems with components dying on me. I ended up using a lab DC supply, set to between 25v and 50V, connected between TP950 and the upper leg of R926, so just after the rectifier. When connected this way, with a BAD MOSFET in place, output voltage could be seen at measuring points 42 and 43 &#8211; just after Q946/7 that is.</p>
<p>With a good MOSFET in place, the switch-mode circuit wouldn&#8217;t start (and P9070 not open) as the trigger voltage across VR925 does not rise high enough (at 50V DC supply) &#8211; shorting VR925 briefly opens Q930, and the supply starts running. I&#8217;m not entirely sure why this is necessary; I hope it will work just fine once I put in the proper 400v MOSFET and give it 240v AC &#8230;</p>
<p>Other observations: I disconnected the high-voltage wire to the voltage tripler, and taped up the end securely, while working on the prereg. This removed the nasty 2Kv from the board, but there&#8217;s still 100v around there, so don&#8217;t touch it &#8230; <img src='http://blog.cluepusher.dk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I changed a few capacitors, since I was changing components anyway, but it seems that the ones I pulled out of it &#8211; from 1985 &#8211; were just fine, and didn&#8217;t need replacement. Quality stuff.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cluepusher.dk/2011/01/27/notes-on-fixing-a-tektronix-2235/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>APK for ICSReader</title>
		<link>http://blog.cluepusher.dk/2010/03/03/apk-for-icsreader/</link>
		<comments>http://blog.cluepusher.dk/2010/03/03/apk-for-icsreader/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 20:10:00 +0000</pubDate>
		<dc:creator>mihtjel</dc:creator>
				<category><![CDATA[Techie stuff]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Calendar]]></category>

		<guid isPermaLink="false">http://blog.cluepusher.dk/?p=211</guid>
		<description><![CDATA[Due to the amazing interest shown in my ICS Reader app for Android, I have decided to actually release it! For now, here is the APK of ICSReader. I may well release the code, but I&#8217;d have to have a quick look through it first.]]></description>
			<content:encoded><![CDATA[<p>Due to the <a href="http://blog.cluepusher.dk/2009/11/25/new-android-app-icsreader/">amazing interest</a> shown in my ICS Reader app for Android, I have decided to actually release it! For now, here is the <a href="http://mihtjel.dk/icsreader/icsreader.apk">APK of ICSReader</a>.</p>
<p>I may well release the code, but I&#8217;d have to have a quick look through it first.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cluepusher.dk/2010/03/03/apk-for-icsreader/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Oracle released Beehive 2.0.1</title>
		<link>http://blog.cluepusher.dk/2010/02/07/oracle-released-beehive-2-0-1/</link>
		<comments>http://blog.cluepusher.dk/2010/02/07/oracle-released-beehive-2-0-1/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 09:50:31 +0000</pubDate>
		<dc:creator>mihtjel</dc:creator>
				<category><![CDATA[Techie stuff]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[Oracle Beehive]]></category>

		<guid isPermaLink="false">http://blog.cluepusher.dk/2010/02/07/oracle-released-beehive-2-0-1/</guid>
		<description><![CDATA[Just a quick reminder, as much for myself as for my readers &#8211; Oracle has released Beehive 2.0.1, which I will be looking at in about two weeks, to see if it will be able to replace our current Collaboration Suite Calendar installation. Sadly, it still seems like Oracle insist that you must use their [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick reminder, as much for myself as for my readers &#8211; Oracle has released Beehive 2.0.1, which I will be looking at in about two weeks, to see if it will be able to replace our current Collaboration Suite Calendar installation. Sadly, it still seems like Oracle insist that you must use their inferior email server to use the rest of the system.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cluepusher.dk/2010/02/07/oracle-released-beehive-2-0-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>New Android app: ICSReader</title>
		<link>http://blog.cluepusher.dk/2009/11/25/new-android-app-icsreader/</link>
		<comments>http://blog.cluepusher.dk/2009/11/25/new-android-app-icsreader/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 18:46:11 +0000</pubDate>
		<dc:creator>mihtjel</dc:creator>
				<category><![CDATA[Techie stuff]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Calendar]]></category>

		<guid isPermaLink="false">http://blog.cluepusher.dk/?p=204</guid>
		<description><![CDATA[After having ranted quite a bit about the lack of support for standards-based calendars and PIM in Android, I decided to implement something myself, to at least get it to a level where an Android phone would be of use to me. Since we have a functioning iCalendar export from our Oracle Collaboration Suite calendar [...]]]></description>
			<content:encoded><![CDATA[<p>After having ranted quite a bit about the lack of support for standards-based calendars and PIM in Android, I decided to implement something myself, to at least get it to a level where an Android phone would be of use to me. Since we have a functioning <a href="http://en.wikipedia.org/wiki/ICalendar">iCalendar</a> export from our Oracle Collaboration Suite calendar at work, I decided to start out writing a parser for that. ICSReader is the result.</p>
<p>The software does a bit more than just read iCalendar files by now, and since it&#8217;s reached the critical junction where I want to expand the functionality significantly, the time has come where it gets its very first version number: <strong>0.1</strong></p>
<p>The very first version, 0.1, has the following features:</p>
<ul>
<li>Imports an ICS file into a local database from an HTTP URL</li>
<li>Display of current events (ongoing, as well as -10/+30 minutes)</li>
<li>Display of the events of the next 48 hours</li>
<li>Display of events on a day by day basis</li>
<li>Detail display for each event</li>
</ul>
<p>More importantly, it lacks the following features:</p>
<ul>
<li>Support for multiple iCalendar sources</li>
<li>Support for individual ICS files, for instance from emails (via Intents)</li>
<li>A week view</li>
<li>A month view</li>
<li>Notifications, alarms, participants, GPS integration, peace on earth, end to world hunger, etc. etc.</li>
</ul>
<p>The observant reader will have noticed that I have yet to provide a link to this software. Currently, it&#8217;s only been built for Android 2.0, and while it may serve a purpose for some people in need of an iCalendar reader, it is not yet sufficiently polished for me to feel comfortable in publishing it. If you happen to need it, post a comment, and I might well reconsider and post a usable build. Otherwise, I am going to work towards a new version with at the least support for multiple iCalendar sources before releasing it.</p>
<p>Got some new features you really want in an Android calendar application? Post a comment, and I&#8217;ll have a look. <img src='http://blog.cluepusher.dk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><strong>Update</strong>: I <a href="http://blog.cluepusher.dk/2010/03/03/apk-for-icsreader/">released the app</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cluepusher.dk/2009/11/25/new-android-app-icsreader/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Creating a custom CursorAdapter for Android</title>
		<link>http://blog.cluepusher.dk/2009/11/16/creating-a-custom-cursoradapter-for-android/</link>
		<comments>http://blog.cluepusher.dk/2009/11/16/creating-a-custom-cursoradapter-for-android/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 18:09:13 +0000</pubDate>
		<dc:creator>mihtjel</dc:creator>
				<category><![CDATA[Techie stuff]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.cluepusher.dk/?p=194</guid>
		<description><![CDATA[I&#8217;ve been writing a bit more Android code, and came upon the need to write a custom CursorAdapter for a ListView, as the way I wanted to display data from a Cursor was dependent on relationships between different fields of the database. Of the problems I encountered, the most obvious was when I tried to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been writing a bit more Android code, and came upon the need to write a custom <a href="http://developer.android.com/reference/android/widget/CursorAdapter.html">CursorAdapter</a> for a <a href="http://developer.android.com/reference/android/widget/ListView.html">ListView</a>, as the way I wanted to display data from a <a href="http://developer.android.com/reference/android/database/Cursor.html">Cursor</a> was dependent on relationships between different fields of the database.</p>
<p>Of the problems I encountered, the most obvious was when I tried to inflate views using <a href="http://developer.android.com/reference/android/view/View.html#inflate(android.content.Context,%20int,%20android.view.ViewGroup)">View.inflate()</a>, and found I would get the following error:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">UnsupportedOperationException</span><span style="color: #339933;">:</span> addView<span style="color: #009900;">&#40;</span><span style="color: #003399;">View</span>, LayoutParams<span style="color: #009900;">&#41;</span>
is not supported in AdapterView at android.<span style="color: #006633;">widget</span>.<span style="color: #006633;">AdapterView</span></pre></div></div>

<p>After a bit of rummaging around, I found that the following bit of code would work when attached to a ListView using <a href="http://developer.android.com/reference/android/widget/ListView.html#setAdapter(android.widget.ListAdapter)">setAdapter()</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ExampleCursorAdapter <span style="color: #000000; font-weight: bold;">extends</span> CursorAdapter <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> ExampleCursorAdapter<span style="color: #009900;">&#40;</span><span style="color: #003399;">Context</span> context, <span style="color: #003399;">Cursor</span> c<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>context, c<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> bindView<span style="color: #009900;">&#40;</span><span style="color: #003399;">View</span> view, <span style="color: #003399;">Context</span> context, <span style="color: #003399;">Cursor</span> cursor<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		TextView summary <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>TextView<span style="color: #009900;">&#41;</span>view.<span style="color: #006633;">findViewById</span><span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">summary</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		summary.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span>cursor.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span>
				cursor.<span style="color: #006633;">getColumnIndex</span><span style="color: #009900;">&#40;</span>ExampleDB.<span style="color: #006633;">KEY_EXAMPLE_SUMMARY</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">View</span> newView<span style="color: #009900;">&#40;</span><span style="color: #003399;">Context</span> context, <span style="color: #003399;">Cursor</span> cursor, ViewGroup parent<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		LayoutInflater inflater <span style="color: #339933;">=</span> LayoutInflater.<span style="color: #006633;">from</span><span style="color: #009900;">&#40;</span>context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">View</span> v <span style="color: #339933;">=</span> inflater.<span style="color: #006633;">inflate</span><span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">layout</span>.<span style="color: #006633;">item</span>, parent, <span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		bindView<span style="color: #009900;">&#40;</span>v, context, cursor<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> v<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The above example code doesn&#8217;t actually require a CursorAdapter, it would easily be implemented using a <a href="http://developer.android.com/reference/android/widget/SimpleCursorAdapter.html">SimpleCursorAdapter</a>, but it serves to show the idea. Basicly, get a LayoutInflater from the context, and use the version of <a href="http://developer.android.com/reference/android/view/LayoutInflater.html#inflate(int,%20android.view.ViewGroup)">inflate()</a> that does not attach to the root view.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cluepusher.dk/2009/11/16/creating-a-custom-cursoradapter-for-android/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Writing Parcelable classes for Android</title>
		<link>http://blog.cluepusher.dk/2009/10/28/writing-parcelable-classes-for-android/</link>
		<comments>http://blog.cluepusher.dk/2009/10/28/writing-parcelable-classes-for-android/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 17:52:51 +0000</pubDate>
		<dc:creator>mihtjel</dc:creator>
				<category><![CDATA[Techie stuff]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Xydroid]]></category>

		<guid isPermaLink="false">http://blog.cluepusher.dk/?p=187</guid>
		<description><![CDATA[I&#8217;ve just released version 0.3 of Xydroid, my small Xymon monitoring app. It should now be a bit more suited to Android 2.0, and have just a couple fewer bugs in it. As it turns out, the main problem with running under Android 2.0 for my app was de-parceling of a Parcelable representation of the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just released version <strong>0.3</strong> of <a href="http://mihtjel.dk/xydroid/">Xydroid</a>, my small Xymon monitoring app. It should now be a bit more suited to Android 2.0, and have just a couple fewer bugs in it.</p>
<p>As it turns out, the main problem with running under Android 2.0 for my app was de-parceling of a <a href="http://d.android.com/reference/android/os/Parcelable.html">Parcelable</a> representation of the XML files used by Xydroid. Up until now, I had just written out all the data in the tree when parceling, and read until no data was left when de-parceling. As it turns out, if this parcelable class is put into a bundle with other data, such as strings or integers, the de-parceling code will just continue reading along the bundle. The error I tended to encounter would be &#8220;Unmarshalling unknown type code 6946932&#8243; (or some other number), presumably as I tried to read a String from where an integer existed or similar.</p>
<p>The solution seems to be to write how much data you are planning to parcel as the first bit of information, and only read back this many chunks before passing control back. This works both in 2.0 and 1.5/1.6, whereas reading until there was no more data seemed to work in 1.5/1.6 but not 2.0 — though this might just have been pure luck.</p>
<p><strong>Update:</strong> I thought I had better actually show how I ended up implementing my Parcelable classes, so here is a quick example of how to wrap a HashMap in something parcelable:<br />
<span id="more-187"></span><br />
<strong>ParcelTest.java</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.HashMap</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.os.Parcel</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.os.Parcelable</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ParcelTest <span style="color: #000000; font-weight: bold;">implements</span> Parcelable <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">HashMap</span> map<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> ParcelTest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        map <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">HashMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> ParcelTest<span style="color: #009900;">&#40;</span>Parcel in<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        map <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">HashMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        readFromParcel<span style="color: #009900;">&#40;</span>in<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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: #000000; font-weight: bold;">final</span> Parcelable.<span style="color: #006633;">Creator</span> CREATOR <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Parcelable.<span style="color: #006633;">Creator</span><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;">public</span> ParcelTest createFromParcel<span style="color: #009900;">&#40;</span>Parcel in<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ParcelTest<span style="color: #009900;">&#40;</span>in<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">public</span> ParcelTest<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> newArray<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> size<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ParcelTest<span style="color: #009900;">&#91;</span>size<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> describeContents<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;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> writeToParcel<span style="color: #009900;">&#40;</span>Parcel dest, <span style="color: #000066; font-weight: bold;">int</span> flags<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        dest.<span style="color: #006633;">writeInt</span><span style="color: #009900;">&#40;</span>map.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> s<span style="color: #339933;">:</span> map.<span style="color: #006633;">keySet</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>
            dest.<span style="color: #006633;">writeString</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            dest.<span style="color: #006633;">writeString</span><span style="color: #009900;">&#40;</span>map.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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;">void</span> readFromParcel<span style="color: #009900;">&#40;</span>Parcel in<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">int</span> count <span style="color: #339933;">=</span> in.<span style="color: #006633;">readInt</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> count<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            map.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>in.<span style="color: #006633;">readString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, in.<span style="color: #006633;">readString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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: #003399;">String</span> get<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> key<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> map.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>key<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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> put<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> key, <span style="color: #003399;">String</span> value<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        map.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>key, value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Update 2:</strong> Stefan requested that I post some code showing how to use this implementation, so here is a supplier and a consumer activity, using this Parcelable object:</p>
<p><strong>ExampleSupplierActivity.java</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.app.Activity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.content.Intent</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.os.Bundle</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ExampleSupplierActivity <span style="color: #000000; font-weight: bold;">extends</span> Activity <span style="color: #009900;">&#123;</span>
    @Override
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> onCreate<span style="color: #009900;">&#40;</span>Bundle savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span><span style="color: #009900;">&#40;</span>savedInstanceState<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        ParcelTest p <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ParcelTest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        p.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;green&quot;</span>, <span style="color: #0000ff;">&quot;go&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        p.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;yellow&quot;</span>, <span style="color: #0000ff;">&quot;wait&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        p.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;red&quot;</span>, <span style="color: #0000ff;">&quot;stop&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        Bundle b <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Bundle<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        b.<span style="color: #006633;">putParcelable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;com.example.trafficlight&quot;</span>, p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        Intent i <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Intent<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, ExampleConsumerActivity.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        i.<span style="color: #006633;">putExtras</span><span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        startActivity<span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>ExampleConsumerActivity.java</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.app.Activity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.os.Bundle</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ExampleConsumerActivity <span style="color: #000000; font-weight: bold;">extends</span> Activity <span style="color: #009900;">&#123;</span>
    @Override
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> onCreate<span style="color: #009900;">&#40;</span>Bundle savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span><span style="color: #009900;">&#40;</span>savedInstanceState<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Bundle b <span style="color: #339933;">=</span> getIntent<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getExtras</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        ParcelTest p <span style="color: #339933;">=</span> b.<span style="color: #006633;">getParcelable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;com.example.trafficlight&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003399;">String</span> red <span style="color: #339933;">=</span> p.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;red&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">// ...</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><em>Disclaimer</em>: This isn&#8217;t the actual code from my system, and I haven&#8217;t tested it. If you want efficient code, you will likely need to change things; If you want safe code, you will most certainly need to do things in a less careless way. If you find any bugs, please leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cluepusher.dk/2009/10/28/writing-parcelable-classes-for-android/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>New SDK means strange new bugs</title>
		<link>http://blog.cluepusher.dk/2009/10/27/new-sdk-means-strange-new-bugs/</link>
		<comments>http://blog.cluepusher.dk/2009/10/27/new-sdk-means-strange-new-bugs/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 22:42:43 +0000</pubDate>
		<dc:creator>mihtjel</dc:creator>
				<category><![CDATA[Techie stuff]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Xydroid]]></category>
		<category><![CDATA[Xymon]]></category>

		<guid isPermaLink="false">http://blog.cluepusher.dk/?p=184</guid>
		<description><![CDATA[When I noticed the Android 2.0 software development kit had been launched, I hurried up and installed it. Okay, it did take the better part of 5 hours before it was properly installed, as Google&#8217;s servers were probably overloaded. None the less, I managed it at least, and fired up an Android 2.0 emulator, taking [...]]]></description>
			<content:encoded><![CDATA[<p>When I noticed the <a href="http://developer.android.com/sdk/index.html">Android 2.0 software development kit</a> had been launched, I hurried up and installed it. Okay, it did take the better part of 5 hours before it was properly installed, as Google&#8217;s servers were probably overloaded. None the less, I managed it at least, and fired up an Android 2.0 emulator, taking a moment to marvel at the fancy new settings that have been added for creating <abbr title="Android Virtual Device">AVD</abbr>s, before hurrying on to install my app, <a href="http://mihtjel.dk/xydroid/">Xydroid</a>.</p>
<p>As usual, it exhibited the crash right at first time start, probably as both the main thread and the update thread try to create the database, and they step on each others toes. I&#8217;ll be sure to get that fixed any day now. Somehow.</p>
<p>There&#8217;s also a new crash, though — this one is right after adding a new source, where the app tries to launch an activity that lets the user select the services to monitor. This gets a runtime error with a null pointer exception, whereas launching the activity separately, after the source has been added works fine. This could be a change in the way bundles between activities are handled in Android 2.0 versus 1.6.</p>
<p>I will probably have to get my act together and release a version 0.3 with these couple of bugs fixed, as well as plenty of testing done for differing screen sizes. One of the great advantages of Android can be said to be the number of different devices you can use it on — and it&#8217;s one of the major drawbacks as well, as there will always be a lot of different things to consider when designing the user interface. I do still prefer it over the iPhone, though <img src='http://blog.cluepusher.dk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cluepusher.dk/2009/10/27/new-sdk-means-strange-new-bugs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What are Google going to do about PIM? Well, more&#8230;</title>
		<link>http://blog.cluepusher.dk/2009/10/27/what-are-google-going-to-do-about-pim-well-more/</link>
		<comments>http://blog.cluepusher.dk/2009/10/27/what-are-google-going-to-do-about-pim-well-more/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 18:12:50 +0000</pubDate>
		<dc:creator>mihtjel</dc:creator>
				<category><![CDATA[Techie stuff]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Calendar]]></category>

		<guid isPermaLink="false">http://blog.cluepusher.dk/?p=182</guid>
		<description><![CDATA[A short while ago, I asked what Google were going to do with PIM in Android. Now it seems there&#8217;s an answer, or at least part of it, in the release of the Android 2.0 SDK: They&#8217;re going to support third party adapters. The nice people at Engadget have a summary of some of the [...]]]></description>
			<content:encoded><![CDATA[<p>A short while ago, I <a href="http://blog.cluepusher.dk/2009/10/15/android-what-are-google-going-to-do-with-pim/">asked</a> what Google were going to do with PIM in Android. Now it seems there&#8217;s an answer, or at least part of it, in the <a href="http://android-developers.blogspot.com/2009/10/announcing-android-20-support-in-sdk.html">release of the Android 2.0 SDK</a>: They&#8217;re going to support third party adapters.</p>
<p>The nice people at Engadget have a <a href="http://www.engadget.com/2009/10/27/android-2-0-support-officially-added-to-sdk/">summary of some of the changes</a>, and among them one can find:</p>
<ul>
<li>Third-party &#8220;sync adapters&#8221; allow apps to tie in to the phone&#8217;s sync services</li>
</ul>
<p>Hopefully, this means they&#8217;re actually going to start working on some nice built-in adapters as well, but at least it seems they&#8217;re opening up the sync parts of the platform from 2.0, contrary to what had earlier been reported. Yay.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cluepusher.dk/2009/10/27/what-are-google-going-to-do-about-pim-well-more/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

