<?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; Java</title>
	<atom:link href="http://blog.cluepusher.dk/tag/java/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>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>Xydroid &#8211; Xymon monitoring on Android phones</title>
		<link>http://blog.cluepusher.dk/2009/10/06/xydroid-xymon-monitoring-on-android-phones/</link>
		<comments>http://blog.cluepusher.dk/2009/10/06/xydroid-xymon-monitoring-on-android-phones/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 17:11:03 +0000</pubDate>
		<dc:creator>mihtjel</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[Techie stuff]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Xydroid]]></category>
		<category><![CDATA[Xymon]]></category>

		<guid isPermaLink="false">http://blog.cluepusher.dk/?p=173</guid>
		<description><![CDATA[Finally, an update for the blog! Well, what has been going on with me? I&#8217;ve been busy at work, and perhaps even busier with my studies. I&#8217;m currently doing a course on Concurrency, which got me started on a bit of lovely threaded java programming again. It&#8217;s nice to be back to writing a bit [...]]]></description>
			<content:encoded><![CDATA[<p>Finally, an update for the blog! Well, what has been going on with me? I&#8217;ve been busy at work, and perhaps even busier with my studies. I&#8217;m currently doing a course on <a href="http://www.cs.au.dk/dConc/">Concurrency</a>, which got me started on a bit of lovely threaded java programming again. It&#8217;s nice to be back to writing a bit of code, and boy have things gotten better over the few years since I last did anything major with it.</p>
<p>In other news, a couple of friends have bought themselves new <a href="http://en.wikipedia.org/wiki/Android_(mobile_device_platform)">Android</a> phones, the <a href="http://en.wikipedia.org/wiki/HTC_Hero">HTC Hero</a>. More and more of them are coming now, and it really looks like a wagon I&#8217;m liable to jump on any day now. They just need to release a new revision of the hardware, preferably something with one of the new <a href="http://en.wikipedia.org/wiki/Snapdragon_(processor)">Snapdragon CPU</a>s in it &#8230;</p>
<p>So what could be more logical than to do a bit of programming for the Android platform? I struggled for a short while to figure out anything worthwhile to write, but then I came up with this: How nice would it be to get the status of your monitored systems direct on your phone? No more needing to browse to the <span style="text-decoration: line-through;">hobbit</span> Xymon system now, just a look at the phone to see how everything you care about is doing. Well, in theory. Except I don&#8217;t have the phone yet. Slight flaw in the plan.</p>
<p>None the less, I&#8217;ve made the software, in a sort of early beta version, and it&#8217;s available on a webpage of its own: <a href="http://mihtjel.dk/xydroid/">Xydroid</a>. Feel free to have a look .. if you want to actually use it, you should probably get in touch, and I&#8217;ll be sure to work on it enough that it will actually work properly as well.</p>
<p>After I&#8217;d started writing the software &#8211; actually, after I&#8217;d gotten quite far in the process &#8211; I found out that other&#8217;s have actually done the same as well, in the form of <a href="http://www.dot-knowledge.de/Home/android/xymon-monitor">Xymon Monitor</a>, for which they charge €2.99. Well, at least this might end up as the slightly cheaper alternative <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/06/xydroid-xymon-monitoring-on-android-phones/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

