<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>IdleSun&#039;s Weblog</title>
	<atom:link href="http://idlesun.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://idlesun.wordpress.com</link>
	<description>Java, Flex, JavaScript, Agile, SCRUM, and etc.</description>
	<lastBuildDate>Mon, 23 Jan 2012 04:17:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='idlesun.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>IdleSun&#039;s Weblog</title>
		<link>http://idlesun.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://idlesun.wordpress.com/osd.xml" title="IdleSun&#039;s Weblog" />
	<atom:link rel='hub' href='http://idlesun.wordpress.com/?pushpress=hub'/>
		<item>
		<title>How to make a TextView scrollable with a Scrollbar</title>
		<link>http://idlesun.wordpress.com/2011/08/27/scrollabletextview/</link>
		<comments>http://idlesun.wordpress.com/2011/08/27/scrollabletextview/#comments</comments>
		<pubDate>Sat, 27 Aug 2011 08:08:16 +0000</pubDate>
		<dc:creator>idlesun</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[Layout]]></category>
		<category><![CDATA[ScrollBar]]></category>
		<category><![CDATA[ScrollView]]></category>
		<category><![CDATA[TextView]]></category>

		<guid isPermaLink="false">http://idlesun.wordpress.com/?p=213</guid>
		<description><![CDATA[I believed that it is possible to make a TextView scrollable without putting it in a ScrollView before actually doing it. I could do it as I expected. But what I didn&#8217;t expect was that I need to do something in the layout  XML as well as in the Java code in order to have [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=idlesun.wordpress.com&amp;blog=4833467&amp;post=213&amp;subd=idlesun&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I believed that it is possible to make a TextView scrollable without putting it in a ScrollView before actually doing it. I could do it as I expected. But what I didn&#8217;t expect was that I need to do something in the layout  XML as well as in the Java code in order to have a scrollable TextBar with a ScrollBar.</p>
<p>As you  may know already, to make a TextView Scrollable the <strong>setMovementMethod()</strong> has to be called like below in the Java code:</p>
<p><pre class="brush: java;">
  . . .
  mTxtOutput = (TextView)findViewById(R.id.txtOutput);
  mTxtOutput.setMovementMethod(ScrollingMovementMethod.getInstance());
  . . .
</pre></p>
<p>So, it is easy. However, there will be no scroll bar when scrolling it. To add a scroll bar, the<strong> android:scrollbars</strong> attribute has to be set in the layout file like this:</p>
<p><pre class="brush: xml;">
  . . .
  &lt;TextView android:id=&quot;@+id/txtOutput&quot; android:scrollbars=&quot;vertical&quot;
    android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;fill_parent&quot;/&gt;
  . . .
</pre></p>
<p>Now, this TextView is scrollable and has a (vertical) scroll bar. It must be lighter than using a ScrollView, which I like. What I don&#8217;t like about this trick is that two different kinds of files must be touched. As far as I know, You cannot make a TextView scrollable in the layout. And you cannot enable scroll bars in the java code. Too bad, right?<br />
Another point to note is that with this trick there will be <strong>no fading edge effect</strong> which is given when <strong>ScrollView</strong> is used. So, I would use this trick only for simple samples.</p>
<p>As an appendix, here is very simple layout code for a scrollable TextView with a vertical scroll bar (using a ScrollView):</p>
<p><pre class="brush: xml;">
  . . .
  &lt;ScrollView android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;fill_parent&quot;&gt;
    &lt;TextView android:layout_height=&quot;wrap_content&quot; android:layout_width=&quot;fill_parent&quot;/&gt;
  &lt;/ScrollView&gt;
  . . .
</pre></p>
<p><em>Note that you need enough number of lines of text in a TextView to try scrolling.</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/idlesun.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/idlesun.wordpress.com/213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/idlesun.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/idlesun.wordpress.com/213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/idlesun.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/idlesun.wordpress.com/213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/idlesun.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/idlesun.wordpress.com/213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/idlesun.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/idlesun.wordpress.com/213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/idlesun.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/idlesun.wordpress.com/213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/idlesun.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/idlesun.wordpress.com/213/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=idlesun.wordpress.com&amp;blog=4833467&amp;post=213&amp;subd=idlesun&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://idlesun.wordpress.com/2011/08/27/scrollabletextview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/58bacfd98c7a07de9a3419ef2321f99a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">idlesun</media:title>
		</media:content>
	</item>
		<item>
		<title>Android Parcelable Example 3 &#8211; Subclass, Inheritance</title>
		<link>http://idlesun.wordpress.com/2011/07/29/android-parcelable-example-3-subclasses/</link>
		<comments>http://idlesun.wordpress.com/2011/07/29/android-parcelable-example-3-subclasses/#comments</comments>
		<pubDate>Fri, 29 Jul 2011 07:04:19 +0000</pubDate>
		<dc:creator>idlesun</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[dalvik vm crash]]></category>
		<category><![CDATA[Inheritance]]></category>
		<category><![CDATA[Parcelable]]></category>
		<category><![CDATA[Subclass]]></category>

		<guid isPermaLink="false">http://idlesun.wordpress.com/?p=202</guid>
		<description><![CDATA[There are always things I (or we) can do and also things I cannot (unless I put a lot of effort or find some magical trick). Parcelable with inheritance is just like that. Starting with things we can do, Parcelable classes have inheritance relationships among them. And any of them can be parceled,  and transferred. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=idlesun.wordpress.com&amp;blog=4833467&amp;post=202&amp;subd=idlesun&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There are always things I (or we) can do and also things I cannot (unless I put a lot of effort or find some magical trick). Parcelable with inheritance is just like that.</p>
<p>Starting with things we can do, Parcelable classes have inheritance relationships among them. And any of them can be parceled,  and transferred. Key point in building inheritance between Parcelable classes is proper calling of super class&#8217; parceling methods and constructors. The following example shows three classes &#8211; Shape &lt;- Rectangle &lt;- RoundedRectangle &#8211; with linear inheritance relationship:</p>
<p><pre class="brush: java;">
class Shape implements Parcelable {
  public int left;
  public int top;
  public int width;
  public int height;

  // CREATOR part is omitted

  protected Shape(Parcel in) {
    readFromParcel(in);
  }

  public void readFromParcel(Parcel in) {
    left = in.readInt();
    top = in.readInt();
    width = in.readInt();
    height = in.readInt();
  }

  @Override
  public int describeContents() {
    return 0;
  }

  @Override
  public void writeToParcel(Parcel out, int flags) {
    out.writeInt(left);
    out.writeInt(top);
    out.writeInt(width);
    out.writeInt(height);
  }
}

class Rectangle extends Shape {
  // CREATOR part is omitted

  protected Rectangle(Parcel in) {
    super(in);
  }
}

class RoundedRectangle extends Rectangle {
  public int radius;
  // CREATOR part is omitted

  protected RoundedRectangle(Parcel in) {
    super(in);
  }

  public void readFromParcel(Parcel in) {
    super.readFromParcel(in);
    radius = in.readInt();
  }

  @Override
  public void writeToParcel(Parcel out, int flags) {
    super.writeToParcel(out, flags);
    out.writeInt(radius);
  }
}
</pre></p>
<p>Please note that:</p>
<ul>
<li>Only first Parcelable super class, Shape, needs to use &#8220;implements&#8221; explicitly.</li>
<li>Only first Parcelable super class, Shape, needs to define describeContents() method.</li>
<li>If there is no new attribute in a sub-class, Rectangle, no need to define parceling methods (because they are already in the super class).</li>
<li>Call super class&#8217; parceling methods first and add parceling statements for sub class&#8217; attributes, RoundedRectangle&#8217;s radius. (In fact, you can swtch the order as long as keeping the same order between reading and writing methods. But reverse order seems less readable)</li>
</ul>
<p>So, any of the above class object can be exchanged using Intent or Bundle with one condition, which defines things I cannot do.</p>
<p>The condition is that both sides, sender and receiver, shall use the same exact type (or class). For example, Rectangle object shall not be referred as Shape when it is written to a Parcel. In case of Rectangle as Shape, at least it won&#8217;t crash because Rectangle doesn&#8217;t have its own attribute. However, if RoundRectangle object is written to a Parcel as Rectangle (or Shape) it will crash when the receiver try to read it from a Parcel. And this crash is not an exception that can be caught. It is a VM crash. Since the failure in reading a Parcel  usually causes a VM crash, all Parcelable related code has to be thoroughly tested and verified.</p>
<p>This condition is not a big deal when only a single object or a collection of the same type objects is concerned because exact type can be used. However, it becomes a big deal if you try to take advantage of polymorphism with Parcelable objects. You may be think it is possible to make List&lt;Shape&gt; Parcelable and have it hold various objects of any sub classes of Shape. The fact is that you shall put  only Shape objects in the list because all object will be treated as Shape on the receiver side.</p>
<p>As looking into this topic more and more, I realized that having and trying to use inheritance in Parcelable classes makes things more complicated and harder to understand than they need to be. I would rather use composition if it is possible.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/idlesun.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/idlesun.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/idlesun.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/idlesun.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/idlesun.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/idlesun.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/idlesun.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/idlesun.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/idlesun.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/idlesun.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/idlesun.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/idlesun.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/idlesun.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/idlesun.wordpress.com/202/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=idlesun.wordpress.com&amp;blog=4833467&amp;post=202&amp;subd=idlesun&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://idlesun.wordpress.com/2011/07/29/android-parcelable-example-3-subclasses/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/58bacfd98c7a07de9a3419ef2321f99a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">idlesun</media:title>
		</media:content>
	</item>
		<item>
		<title>Android Parcelable Example 2 &#8211; Sub-object and List</title>
		<link>http://idlesun.wordpress.com/2011/07/15/android-parcelable-example-2-sub-object-and-list/</link>
		<comments>http://idlesun.wordpress.com/2011/07/15/android-parcelable-example-2-sub-object-and-list/#comments</comments>
		<pubDate>Fri, 15 Jul 2011 19:48:24 +0000</pubDate>
		<dc:creator>idlesun</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[composition]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[Parcelable]]></category>
		<category><![CDATA[subobject]]></category>

		<guid isPermaLink="false">http://idlesun.wordpress.com/?p=197</guid>
		<description><![CDATA[This second Parcelable example is to show how to make a class parcelable when its fields are class objects or a list of class objects. The key point here is that field objecs has to be parcelable too. So, here is the example class Group that has the detail field, which is an object of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=idlesun.wordpress.com&amp;blog=4833467&amp;post=197&amp;subd=idlesun&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This second Parcelable example is to show how to make a class parcelable when its fields are class objects or a list of class objects. The key point here is that field objecs has to be parcelable too. So, here is the example class Group that has the detail field, which is an object of GroupDetail class, and the itemList, which is a list of Item objects.</p>
<p><pre class="brush: java;">
public class Group implements Parcelable {
	public String		name;
	public GroupDetail	detail;
	public List&lt;Item&gt;	itemList;

	// CREATOR is omitted

	private Group(Parcel in) { readFromParcel(in);	}

	public void readFromParcel(Parcel in) {
		name = in.readString();
		detail = in.readParcelable(GroupDetail.class.getClassLoader());
		if (itemList == null) {
			itemList = new ArrayList();
		}
		in.readTypedList(itemList, Item.CREATOR);
	}

	@Override
	public void writeToParcel(Parcel out, int flags) {
		out.writeString(name);
		out.writeParcelable(detail, flags);
		out.writeTypedList(itemList);
	}
}
</pre></p>
<p>It is easy to know that readParceable() and writeParcelable() shall be used for parcelable field. What takes time is finding out how to pass the Class Loader to readParcelable() method. For a list of parcelable object, readTypedList() with CREATOR and writeTypedList(). readList() and writeList() can also be used but I assume &#8216;typed&#8217; version with CREATOR should give better performance.<br />
And now take a look at the GroupDetail class that is also Parcelable:</p>
<p><pre class="brush: java;">
public class GroupDetail implements Parcelable {
	public String	createdBy;
	public List&lt;String&gt;	managedBy;

	// CREATOR part is omitted

	private GroupDetail(Parcel in) { readFromParcel(in);	}

	public void readFromParcel(Parcel in) {
		createdBy = in.readString();
		if (managedBy == null) {
			managedBy = new ArrayList();
		}
		in.readStringList(managedBy);
	}

	@Override
	public void writeToParcel(Parcel out, int flags) {
		out.writeString(createdBy);
		out.writeStringList(managedBy);
	}
}
</pre></p>
<p>This code also shows how to handle a string list field in a Parcelable class. Last one is the Item class that is a simple Parcelable:</p>
<p><pre class="brush: java;">
public class Item implements Parcelable {
	public String	name;
	public String	description;

	private Item(Parcel in) {	readFromParcel(in); }

	public void readFromParcel(Parcel in) {
		name = in.readString();
		description = in.readString();
	}

	@Override
	public void writeToParcel(Parcel out, int flags) {
		out.writeString(name);
		out.writeString(description);
	}
}
</pre></p>
<p>Some takeaways from this example is:</p>
<ul>
<li>For fields of class objects or list of them, class loader or CREATOR will be needed.</li>
<li>In general, reading from a parcel requires more information on the types of data while writing to a parcel is relatively simeple.</li>
</ul>
<p>Next posting plan:</p>
<ul>
<li>Third example that shows the make classes parcelable with inheritance relations will posted later.</li>
<li>As a wrap-up of this series, an example app that demonstrates passing parcelable objects between an activity and a service.</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/idlesun.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/idlesun.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/idlesun.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/idlesun.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/idlesun.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/idlesun.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/idlesun.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/idlesun.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/idlesun.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/idlesun.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/idlesun.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/idlesun.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/idlesun.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/idlesun.wordpress.com/197/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=idlesun.wordpress.com&amp;blog=4833467&amp;post=197&amp;subd=idlesun&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://idlesun.wordpress.com/2011/07/15/android-parcelable-example-2-sub-object-and-list/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/58bacfd98c7a07de9a3419ef2321f99a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">idlesun</media:title>
		</media:content>
	</item>
		<item>
		<title>Android Parcelable Example 1 &#8211; boolean and enum</title>
		<link>http://idlesun.wordpress.com/2011/07/01/android-parcelable-example-1-boolean-and-enum/</link>
		<comments>http://idlesun.wordpress.com/2011/07/01/android-parcelable-example-1-boolean-and-enum/#comments</comments>
		<pubDate>Fri, 01 Jul 2011 18:44:50 +0000</pubDate>
		<dc:creator>idlesun</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[boolean]]></category>
		<category><![CDATA[enum]]></category>
		<category><![CDATA[Parcelable]]></category>

		<guid isPermaLink="false">http://idlesun.wordpress.com/?p=190</guid>
		<description><![CDATA[Parcelable examples in Android Dev Guide is too simple to figure out how to handle all real-world cases. So I made a couple of simple examples that shows how read-from and write-to Parcel code can be written. First one is to to show boolean and enum fields. Note that code for CREATOR is omitted for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=idlesun.wordpress.com&amp;blog=4833467&amp;post=190&amp;subd=idlesun&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Parcelable examples in Android Dev Guide is too simple to figure out how to handle all real-world cases. So I made a couple of simple examples that shows how read-from and write-to Parcel code can be written. First one is to to show boolean and enum fields. Note that code for CREATOR is omitted for simplicity.</p>
<p><pre class="brush: java;">
public class MyData extends Parcelable {
    public enum DataType { SIMPLE, COMPLEX; }

    public String name;
    public DataType type;
    public boolean simpleBool;
    public Boolean classBool;

    // Code for CREATOR is omitted

    public MyData()          { }  // needed for initial data creation in many cases
    public MyData(Parcel in) { readFromParcel(in); }

    public void readFromParcel(Parcel in) {
        name = in.readString();
        try {
            type = DataType.valueOf(in.readString());
        } catch (IllegalArgumentException x) {
            type = null;
        }
        simpleBool = (in.readInt() == 0) ? false : true;
        classBool = (in.readInt() == 0) ? false : true;
    }

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeString(name);
        out.writeString((DataType == null) ? &quot;&quot; : DataType.name());
        out.writeInt(simpleBool ? 1 : 0);
        out.writeInt((classBool != null &amp;&amp; classBool) ? 1 : 0);
    }
}

</pre></p>
<p>As shown above, code is a little bit more complicated than expected. In general two things should be considered when you read-to or write-from a Parcel:</p>
<ul>
<li>Type has to be converted to something that Parcel support. For example, <strong>boolean</strong> and <strong>Boolean</strong> to <strong>int</strong>, <strong>enum</strong> to <strong>String</strong>.</li>
<li>Potential exceptions shall be handled properly. For example, null-ness of any class type and illegal value for enum type.</li>
</ul>
<p>So, reading enum field becomes quite complicated and handling any class type including those with auto-boxing is not trivial.</p>
<p>Next posts will show how to handle list fields, composition and inheritance respectively.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/idlesun.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/idlesun.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/idlesun.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/idlesun.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/idlesun.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/idlesun.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/idlesun.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/idlesun.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/idlesun.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/idlesun.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/idlesun.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/idlesun.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/idlesun.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/idlesun.wordpress.com/190/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=idlesun.wordpress.com&amp;blog=4833467&amp;post=190&amp;subd=idlesun&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://idlesun.wordpress.com/2011/07/01/android-parcelable-example-1-boolean-and-enum/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/58bacfd98c7a07de9a3419ef2321f99a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">idlesun</media:title>
		</media:content>
	</item>
		<item>
		<title>How to make PreferenceActivity use non-default SharedPreferences</title>
		<link>http://idlesun.wordpress.com/2011/04/08/how-to-make-preferenceactivity-use-non-default-sharedpreferences/</link>
		<comments>http://idlesun.wordpress.com/2011/04/08/how-to-make-preferenceactivity-use-non-default-sharedpreferences/#comments</comments>
		<pubDate>Fri, 08 Apr 2011 05:49:44 +0000</pubDate>
		<dc:creator>idlesun</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[PreferenceActivity]]></category>
		<category><![CDATA[SharedPreferences]]></category>

		<guid isPermaLink="false">http://idlesun.wordpress.com/?p=182</guid>
		<description><![CDATA[As most of us know, PreferenceActivity is really easy to use and convenient. To make things even more easier, Android associates a PreferenceActivity (PreferenceFragment from HONEYCOMB) with  default SharedPreferences of the context that it belongs. However, sometimes you would like to use different name or mode than the default SharedPreferences, which is what happend to me. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=idlesun.wordpress.com&amp;blog=4833467&amp;post=182&amp;subd=idlesun&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As most of us know, PreferenceActivity is really easy to use and convenient. To make things even more easier, Android associates a PreferenceActivity (PreferenceFragment from HONEYCOMB) with  default SharedPreferences of the context that it belongs. However, sometimes you would like to use different name or mode than the default SharedPreferences, which is what happend to me.</p>
<p>Here is a way that I found. Logically it is simple. Because there is no explicit way to associate certain SharedPreferences to a PreferenceActivity, you need to change the settings of default SharedPreferences. Here is the code piece that shows how to:</p>
<p><pre class="brush: java;">
public class MyPreferencesActivity extends PreferenceActivity {
    protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);

         PreferenceManager prefMgr = getPreferenceManager();
         prefMgr.setSharedPreferencesName(&quot;my_preferences&quot;);
         prefMgr.setSharedPreferencesMode(MODE_WORLD_READABLE);

         addPreferencesFromResource(R.xml.preferences);
    }
}
</pre></p>
<p>You can verify the SharedPrefereces file name using DDMS File Explorer.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/idlesun.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/idlesun.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/idlesun.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/idlesun.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/idlesun.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/idlesun.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/idlesun.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/idlesun.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/idlesun.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/idlesun.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/idlesun.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/idlesun.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/idlesun.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/idlesun.wordpress.com/182/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=idlesun.wordpress.com&amp;blog=4833467&amp;post=182&amp;subd=idlesun&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://idlesun.wordpress.com/2011/04/08/how-to-make-preferenceactivity-use-non-default-sharedpreferences/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/58bacfd98c7a07de9a3419ef2321f99a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">idlesun</media:title>
		</media:content>
	</item>
		<item>
		<title>Android Handler and Message Tutorial</title>
		<link>http://idlesun.wordpress.com/2010/12/12/android-handler-and-message-tutorial/</link>
		<comments>http://idlesun.wordpress.com/2010/12/12/android-handler-and-message-tutorial/#comments</comments>
		<pubDate>Sun, 12 Dec 2010 01:44:22 +0000</pubDate>
		<dc:creator>idlesun</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://idlesun.wordpress.com/?p=159</guid>
		<description><![CDATA[There are many postings about Android Handler and Message. But it took me a while to make myself comfortable with them. So I made a tutorial sample to clarify: How to create a message and send it with data. How to use Handler to do something periodically. How multiple handlers work. What about thread? Which thread handlers [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=idlesun.wordpress.com&amp;blog=4833467&amp;post=159&amp;subd=idlesun&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There are many postings about Android Handler and Message. But it took me a while to make myself comfortable with them. So I made a tutorial sample to clarify:</p>
<ul>
<li>How to create a message and send it with data.</li>
<li>How to use Handler to do something periodically.</li>
<li>How multiple handlers work.</li>
<li>What about thread? Which thread handlers run on.</li>
</ul>
<p>The sample has two buttons to send a initial message to the corresponding handler respectively. Third button is to add some output message while handlers are working.</p>
<p><a href="http://idlesun.files.wordpress.com/2010/12/handler-sample.png"><img class="alignnone size-full wp-image-169" title="handler-sample" src="http://idlesun.files.wordpress.com/2010/12/handler-sample1.png" alt="Android Handler Sample" width="329" height="488" /></a></p>
<p>As the above screenshot shows, two handlers works just fine and even multiple looping from the same handler works find too. And everything is executed in the same thread as the main UI thread.  Handler is very easy and light-weight method to perform short tasks without creating a thread. But because of the fact of no-own-thread, the nature of the tasks to perform has to be considered first.</p>
<p>The source code of the TestHandlerActivity is shown below. The link to get full source is in the end.</p>
<p><pre class="brush: java;">
public class TestHandlerActivity extends Activity {
  static public enum WhatAbout { ART, LIFE, MONEY, WORLD };
  static public WhatAbout[] wa = WhatAbout.values();
  static TextView textOut;

  static Handler updater1 = new Handler() {
    @Override
    public void handleMessage(Message msg) {
      if (msg.what &lt; wa.length) {
        String header = &quot;[H:1,Th:&quot; + Thread.currentThread().getId() + &quot;] &quot;;
        switch (wa[msg.what]) {
        case ART:
          textOut.append(header + &quot;ART is Art.\n&quot;);
          break;
        case LIFE:
          textOut.append(header + &quot;LIFE is Life.\n&quot;);
          break;
        case MONEY:
          textOut.append(header + &quot;MONEY is Money.\n&quot;);
          break;
        case WORLD:
          textOut.append(header + &quot;WORLD is World.\n&quot;);
          break;
        }
        if (msg.what+1 &lt; wa.length)
          sendMessageDelayed(obtainMessage(msg.what+1, 0, 0), 2000);
      }
    }
  };

  static Handler updater2 = new Handler() {
    @Override
    public void handleMessage(Message msg) {
      if (msg.what &lt; wa.length) {
        String header = &quot;[H:2,Th:&quot; + Thread.currentThread().getId() + &quot;] &quot;;
        switch (wa[msg.what]) {
        case ART:
          textOut.append(header + &quot;ART is good.\n&quot;);
          break;
        case LIFE:
          textOut.append(header + &quot;LIFE is better.\n&quot;);
          break;
        case MONEY:
          textOut.append(header + &quot;MONEY is even better.\n&quot;);
          break;
        case WORLD:
          textOut.append(header + &quot;WORLD is chaos.\n&quot;);
          break;
        }
        if (msg.what+1 &lt; wa.length)
          sendMessageDelayed(obtainMessage(msg.what+1, 0, 0), 2000);
      }
    }
  };

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.test_handler);
    textOut = (TextView) this.findViewById(R.id.text_out);
    textOut.append(&quot;\n\n&quot;);

    ((Button) findViewById(R.id.btn_start1)).setOnClickListener( new OnClickListener() {
      public void onClick(View view) {
        updater1.sendMessage(updater1.obtainMessage(WhatAbout.ART.ordinal(), 0, 0));
      }
    });
    ((Button) findViewById(R.id.btn_start2)).setOnClickListener( new OnClickListener() {
      public void onClick(View view) {
        updater2.sendMessage(updater2.obtainMessage(WhatAbout.ART.ordinal(), 0, 0));
      }
    });
    ((Button) findViewById(R.id.btn_add)).setOnClickListener( new OnClickListener() {
      public void onClick(View view) {
        textOut.append(&quot;[H:-,Th:&quot; + Thread.currentThread().getId() + &quot;] -- You clicked. --\n&quot;);
      }
    });
    ((Button) findViewById(R.id.btn_exit)).setOnClickListener( new OnClickListener() {
      public void onClick(View view) {
        finish();
      }
    });
  }
}
</pre></p>
<p><em><strong><a href="http://idlesun.files.wordpress.com/2010/12/testhandler-zip.gif">For full source project, right click and save this link as &#8220;TestHandler.zip&#8221; and extract it</a></strong></em>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/idlesun.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/idlesun.wordpress.com/159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/idlesun.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/idlesun.wordpress.com/159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/idlesun.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/idlesun.wordpress.com/159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/idlesun.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/idlesun.wordpress.com/159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/idlesun.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/idlesun.wordpress.com/159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/idlesun.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/idlesun.wordpress.com/159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/idlesun.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/idlesun.wordpress.com/159/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=idlesun.wordpress.com&amp;blog=4833467&amp;post=159&amp;subd=idlesun&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://idlesun.wordpress.com/2010/12/12/android-handler-and-message-tutorial/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/58bacfd98c7a07de9a3419ef2321f99a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">idlesun</media:title>
		</media:content>

		<media:content url="http://idlesun.files.wordpress.com/2010/12/handler-sample1.png" medium="image">
			<media:title type="html">handler-sample</media:title>
		</media:content>
	</item>
		<item>
		<title>How to use an Java enum like an integer (for Android Message.what)</title>
		<link>http://idlesun.wordpress.com/2010/11/18/how-to-use-an-java-enum-like-an-integer-for-android-message-what/</link>
		<comments>http://idlesun.wordpress.com/2010/11/18/how-to-use-an-java-enum-like-an-integer-for-android-message-what/#comments</comments>
		<pubDate>Thu, 18 Nov 2010 04:52:56 +0000</pubDate>
		<dc:creator>idlesun</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://idlesun.wordpress.com/?p=152</guid>
		<description><![CDATA[Java enum is powerful. However, it is tricky if you want to use it as integer just like in C/C++. Actually, it is not easy at all because Java enum elements are objects. So it is best to use Java enum as enum. But what about the case you need to pass it back an [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=idlesun.wordpress.com&amp;blog=4833467&amp;post=152&amp;subd=idlesun&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Java enum is powerful. However, it is tricky if you want to use it as integer just like in C/C++. Actually, it is not easy at all because Java enum elements are objects. So it is best to use Java enum as enum. But what about the case you need to pass it back an forth as an integer. One example is when you want to use enum for a &#8216;what&#8217; of Android Message. Lets say you have defined the enum, WhatAbout, like this:</p>
<p><pre class="brush: java;">
enum WhatAbout { ART, LIFE, MONEY, WORLD };
</pre></p>
<p>And you want to sendMessage to someHandler like this:</p>
<p><pre class="brush: java;">
someHandler.sendMessage(updater.obtainMessage(WhatAbout.ART.ordinal(), 0, 0));
</pre></p>
<p>As you can see enum&#8217;s ordinal() method solves the issue. Now look at the receiver side. Here is the code for handleMessge() method of someHander</p>
<p><pre class="brush: java;">
  public void handleMessage(Message msg) {
    if (msg.what == WhatAbout.ART.ordinal()) {
      // Do something about ART
    } else if (msg.what == WhatAbout.LIFE.ordinal()) {
      // Do something about LIFE
    } else ...
  }
</pre></p>
<p>It will work, but looks ugly. Using switch must be better. However, unfortunately, the ordinal() method cannot be a case expression because it is not a constant expression. So here is my trick to get around that restriction and use switch:</p>
<p><pre class="brush: java;">
  static WhatAbout[] wa = WhatAbout.values();

  public void handleMessage(Message msg) {
    try {
      switch(wa[msg.what]) {
      case ART:
        // Do something about ART
        break;
      case LIFE:
        // Do something about LIFE
        break;
      ...
      }
    } catch (Exception x) {
      // Handle ArrayIndexOutOfBoundsException exception
    }
  }
</pre></p>
<p>The point is having an enum value array instantiated and use it in the switch expression.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/idlesun.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/idlesun.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/idlesun.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/idlesun.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/idlesun.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/idlesun.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/idlesun.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/idlesun.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/idlesun.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/idlesun.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/idlesun.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/idlesun.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/idlesun.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/idlesun.wordpress.com/152/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=idlesun.wordpress.com&amp;blog=4833467&amp;post=152&amp;subd=idlesun&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://idlesun.wordpress.com/2010/11/18/how-to-use-an-java-enum-like-an-integer-for-android-message-what/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/58bacfd98c7a07de9a3419ef2321f99a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">idlesun</media:title>
		</media:content>
	</item>
		<item>
		<title>Android SharedPreferences.edit().commit() lies! Not really.</title>
		<link>http://idlesun.wordpress.com/2010/11/11/android-sharedpreferences-edit-commit-lies-not-really/</link>
		<comments>http://idlesun.wordpress.com/2010/11/11/android-sharedpreferences-edit-commit-lies-not-really/#comments</comments>
		<pubDate>Thu, 11 Nov 2010 05:37:47 +0000</pubDate>
		<dc:creator>idlesun</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://idlesun.wordpress.com/?p=147</guid>
		<description><![CDATA[SharedPreferences.edit().commit() returned &#8216;true&#8217;. But SharedPreferences was not created. Actually, it was was my mistake. My code was like: Code should be like: As Android reference document said SharedPreferences.edit() returns always &#8220;NEW&#8221; editor(). So, in the upper code, &#8220;no change&#8221; has been committed successfully. I wasted a couple of hours because of this. Hopefully, this post can [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=idlesun.wordpress.com&amp;blog=4833467&amp;post=147&amp;subd=idlesun&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong><strong>SharedPreferences.</strong>edit().commit()</strong> returned &#8216;true&#8217;. But <strong>SharedPreferences</strong> was not created. Actually, it was was my mistake.</p>
<p>My code was like:</p>
<p><pre class="brush: java;">
SharedPreferences perfs = getSharedPreferences();
prefs.edit().putString(&quot;greeting&quot;, &quot;Hello there!&quot;);
prefs.edit().commit(); // ture, but nothing happens
</pre></p>
<p>Code should be like:</p>
<p><pre class="brush: java;">
SharedPreferences.Editor ed = getSharedPreferences().edit();
ed.putString(&quot;greeting&quot;, &quot;Hello there!&quot;);
ed.commit(); // true and preferences updated
</pre></p>
<p>As Android reference document said SharedPreferences.edit() returns always <strong>&#8220;NEW&#8221;</strong> editor(). So, in the upper code, &#8220;no change&#8221; has been committed successfully. I wasted a couple of hours because of this. Hopefully, this post can save somebody else&#8217;s time.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/idlesun.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/idlesun.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/idlesun.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/idlesun.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/idlesun.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/idlesun.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/idlesun.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/idlesun.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/idlesun.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/idlesun.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/idlesun.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/idlesun.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/idlesun.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/idlesun.wordpress.com/147/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=idlesun.wordpress.com&amp;blog=4833467&amp;post=147&amp;subd=idlesun&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://idlesun.wordpress.com/2010/11/11/android-sharedpreferences-edit-commit-lies-not-really/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/58bacfd98c7a07de9a3419ef2321f99a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">idlesun</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting Android source in Ubuntu 10.04</title>
		<link>http://idlesun.wordpress.com/2010/06/18/getting-android-source-in-ubuntu-10-04/</link>
		<comments>http://idlesun.wordpress.com/2010/06/18/getting-android-source-in-ubuntu-10-04/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 20:38:45 +0000</pubDate>
		<dc:creator>idlesun</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://idlesun.wordpress.com/?p=141</guid>
		<description><![CDATA[While I was following the Android instruction I ran into a couple of difficulties. So here is the list of them with how I resolved. Forcing WUBI to install 32bit version. I used Ubuntu Windows Installer (WUBI). It really simplified Windows-Ubuntu dual-boot setup. However, on my desktop it automatically choose 64bit Ubuntu without asking me. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=idlesun.wordpress.com&amp;blog=4833467&amp;post=141&amp;subd=idlesun&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>While I was following the <a title="Android Source Download" href="http://source.android.com/source/download.html" target="_blank">Android instruction </a>I ran into a couple of difficulties. So here is the list of them with how I resolved.</p>
<p><strong>Forcing WUBI to install 32bit version.</strong></p>
<p>I used Ubuntu Windows Installer (WUBI). It really simplified Windows-Ubuntu dual-boot setup. However, on my desktop it automatically choose 64bit Ubuntu without asking me. According to Android instruction 32-bit Ubuntu is preferred. So, I had to use command line option to install 32-bit Ubuntu using WUBI. From Windows command prompt, run</p>
<pre>&gt; wubi.exe --32bit
</pre>
<p>For more on WUBI: <a href="https://wiki.ubuntu.com/WubiGuide" target="_blank">Wubi Guide</a>.</p>
<p><strong>Couldn&#8217;t find package git-core</strong></p>
<p>Right after Ubuntu installation, if you follow Android instruction to install required packages then this error may occur. Then run this:</p>
<pre>&gt; sudo apt-get update</pre>
<p><strong>Couldn&#8217;t find package sun-java5-jdk</strong></p>
<p>This will occur because Ubutu 10 comes with jdk 6. I followed the instruction on <a href="http://zebardast.ir/en/installing-sun-jdk-5-on-ubuntu-9-10-and-10-04/">http://zebardast.ir/en/installing-sun-jdk-5-on-ubuntu-9-10-and-10-04/</a>.</p>
<p><strong>Making sure PATH includes ~/bin</strong></p>
<p>Once ~/bin is created, at home run:</p>
<pre>&gt; source .profile
&gt; echo $PATH</pre>
<p>Now, following Android instruction was good enough to finish the task.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/idlesun.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/idlesun.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/idlesun.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/idlesun.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/idlesun.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/idlesun.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/idlesun.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/idlesun.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/idlesun.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/idlesun.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/idlesun.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/idlesun.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/idlesun.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/idlesun.wordpress.com/141/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=idlesun.wordpress.com&amp;blog=4833467&amp;post=141&amp;subd=idlesun&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://idlesun.wordpress.com/2010/06/18/getting-android-source-in-ubuntu-10-04/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/58bacfd98c7a07de9a3419ef2321f99a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">idlesun</media:title>
		</media:content>
	</item>
		<item>
		<title>How to hide Android status bar and title bar.</title>
		<link>http://idlesun.wordpress.com/2010/06/05/android-fullscreen-app-with-no-title-bar/</link>
		<comments>http://idlesun.wordpress.com/2010/06/05/android-fullscreen-app-with-no-title-bar/#comments</comments>
		<pubDate>Sat, 05 Jun 2010 00:26:56 +0000</pubDate>
		<dc:creator>idlesun</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://idlesun.wordpress.com/?p=126</guid>
		<description><![CDATA[I  looked for how-to. And found one that uses API: http://www.anddev.org/hide_statusbar-title_on_qvga_-_getting_screen_resolution-t2689.html. This solution is nice when app window style needs to be determined and set dynamically. Later, I found an another way that uses style and much easier if app window style is fixed.  It is just adding the android:theme attribute to activity element in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=idlesun.wordpress.com&amp;blog=4833467&amp;post=126&amp;subd=idlesun&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I  looked for how-to. And found one that uses API:<a href="http://www.anddev.org/hide_statusbar-title_on_qvga_-_getting_screen_resolution-t2689.html"> http://www.anddev.org/hide_statusbar-title_on_qvga_-_getting_screen_resolution-t2689.html</a>. This solution is nice when app window style needs to be determined and set dynamically.</p>
<p>Later, I found an another way that uses style and much easier if app window style is fixed.  It is just adding the <strong>android:theme</strong> attribute to <strong>activity</strong> element in <strong>AdroidManifest.xml</strong> file:</p>
<p><pre class="brush: xml;">
&lt;activity android:name=&quot;.HelloWorld&quot; android:label=&quot;@string/app_name&quot; android:theme=&quot;@android:style/Theme.NoTitleBar.Fullscreen&quot;&gt;
</pre></p>
<p>For more info, check the last part of <a href="http://developer.android.com/guide/topics/ui/themes.html">http://developer.android.com/guide/topics/ui/themes.html</a> and the Android Styles and Themes XML files.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/idlesun.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/idlesun.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/idlesun.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/idlesun.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/idlesun.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/idlesun.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/idlesun.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/idlesun.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/idlesun.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/idlesun.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/idlesun.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/idlesun.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/idlesun.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/idlesun.wordpress.com/126/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=idlesun.wordpress.com&amp;blog=4833467&amp;post=126&amp;subd=idlesun&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://idlesun.wordpress.com/2010/06/05/android-fullscreen-app-with-no-title-bar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/58bacfd98c7a07de9a3419ef2321f99a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">idlesun</media:title>
		</media:content>
	</item>
	</channel>
</rss>
