<?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>blog.elsdoerfer.name &#187; Android</title>
	<atom:link href="http://blog.elsdoerfer.name/category/android/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.elsdoerfer.name</link>
	<description>Contributing back to the Google Index.</description>
	<lastBuildDate>Sat, 10 Dec 2011 00:04:42 +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>Installing su/Superuser.apk in ICS/Android 4.0 emulator</title>
		<link>http://blog.elsdoerfer.name/2011/12/10/installing-susuperuser-apk-in-icsandroid-4-0-emulator/</link>
		<comments>http://blog.elsdoerfer.name/2011/12/10/installing-susuperuser-apk-in-icsandroid-4-0-emulator/#comments</comments>
		<pubDate>Sat, 10 Dec 2011 00:04:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://blog.elsdoerfer.name/?p=409</guid>
		<description><![CDATA[To avoid the Out of memory error when trying to copy the su-executable to /system/bin, you need to start the emulator manually with a large &#8211;partion-size argument: $ emulator -avd MYNAME -partition-size 300 Then: $ adb remount $ adb push ~/Desktop/rootfiles/su /system/bin/su $ adb shell chmod 06755 /system/bin/su]]></description>
			<content:encoded><![CDATA[<p>To avoid the <em>Out of memory</em> error when trying to copy the su-executable to <em>/system/bin</em>, you need to start the emulator manually with a large &#8211;partion-size argument:</p>
<p><code>
<pre>
$ emulator -avd MYNAME -partition-size 300
</pre>
<p></code></p>
<p>Then:</p>
<p><code>
<pre>
$ adb remount
$ adb push ~/Desktop/rootfiles/su /system/bin/su
$ adb shell chmod 06755 /system/bin/su
</pre>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.elsdoerfer.name/2011/12/10/installing-susuperuser-apk-in-icsandroid-4-0-emulator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>android2po: Managing Android translations</title>
		<link>http://blog.elsdoerfer.name/2010/04/08/android2po-managing-android-translations/</link>
		<comments>http://blog.elsdoerfer.name/2010/04/08/android2po-managing-android-translations/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 23:52:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://blog.elsdoerfer.name/?p=163</guid>
		<description><![CDATA[I&#8217;ve always liked gettext a lot. Rather than asking you to maintain a database of strings, assigning an id to each, it simply uses the original strings itself as the string id. To me, it&#8217;s a classical example of choosing practicality over purity. The Android localization system, of course, uses the former approach. Each string [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always liked <a href="http://en.wikipedia.org/wiki/GNU_gettext">gettext</a> a lot. Rather than asking you to maintain a database of strings, assigning an id to each, it simply uses the original strings itself as the string id. To me, it&#8217;s a classical example of choosing practicality over purity.</p>
<p>The Android localization system, of course, uses the former approach. Each string is a resource with an id, each each language, essentially, has one or more XML files with the proper localized string mapped to each id.</p>
<p>For my apps, I initially used to have only the original English version, and a German translation, those being the only languages I speak, more or less anyway. Now, whenever I added a new English string, or changed an existing one, I immediately updated the German version as well &#8211; simply enough. </p>
<p>For <a href="http://elsdoerfer.name/=photoworld">A World Of Photo</a>, I decided to ask the community for help with translations into more languages. Clearly, things were not so simple anymore.</p>
<p>See, with gettext, when the set of strings an app uses changes as part of a new version, you can simply &#8220;merge&#8221; the new string catalog into each of the translations. Strings that have been removed from the app are removed from the translations files, new strings are added, and strings that have been changed are flagged as &#8220;fuzzy&#8221;, at least to the extend that the merge tool detects it as a change, rather than a completely new string. That last part is possible because each translation file contains contains not only the translations, but also the original string that was translated. Remember, it&#8217;s the string that is the database key.</p>
<p>As a result, translators simply have to go through the list of new or fuzzy, update those, and they&#8217;re done.</p>
<p>Now, Android&#8217;s system has no equivalent tools. Frankly, I wonder how other people do this. I mean, you surely don&#8217;t want have your localization team go through the full list of strings every time you release a new version. Even if you decide you don&#8217;t need to ability to detect strings that have changed (you could simply have a policy of using a new id when such a change is necessary), you still need tools to merge changes in your main <em>strings.xml</em> file into each language&#8217;s XML resource with new/removed strings (do any such tools exist?).</p>
<p>I suppose you could also ask have your translators work off a diff, but that seems inconvenient. There&#8217;s this huge ecosystem around gettext with all kinds of desktop and web apps that could be utilized.</p>
<p>Google seems to use <em>something</em> internally, because Android&#8217;s own string resources are marked with <em>msgid=</em> attributes.</p>
<p>So, I decided the best way for me to deal with this would be to simply convert Android&#8217;s XML resources to gettext, do the translations, then import the result back to Android. I found out that the OpenIntents project was <a href="http://code.google.com/p/openintents/source/browse/tools/Androidxml2po/androidxml2po.bash">doing the same</a>, essentially using a generic <em>xml2po</em> tool found somewhere in the depths of <a href="http://live.gnome.org/GnomeDocUtils">gnome-doc-utils</a>. I kinda got it to work, but ran into a lot of little issues; in the end it felt just too hacky.<br />
The final thing that convinced me that writing a special purpose tool might be worth my while was the fact that Android&#8217;s XML resource format has a bunch of different escaping rules and peculiarities (which I plan to write a separate post on), with which translators shouldn&#8217;t really have to deal with.</p>
<p>So, have a look at <a href="http://github.com/miracle2k/android2po">android2po</a>. You can install via <a href="http://pypi.python.org/pypi/android2po">PyPi</a>: </p>
<p><strong>easy_install android2po</strong></p>
<p>There&#8217;s also a <a href="http://github.com/miracle2k/android2po">README</a> file which explains the basic usage; which is really just <em>a2po init</em>, <em>a2po export</em> and <em>a2po import</em> calls, though at this point there&#8217;s also various <a href="http://github.com/miracle2k/android2po/blob/master/example.config">configuration options</a> that should make it really quite flexible.</p>
<p>The biggest thing it doesn&#8217;t support yet are the <em>&lt;plurals&gt;</em> tags, mainly because I didn&#8217;t need them myself yet. Apart from that, I do believe it should work just fine for most projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.elsdoerfer.name/2010/04/08/android2po-managing-android-translations/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Clickable URLs in Android TextViews</title>
		<link>http://blog.elsdoerfer.name/2009/10/29/clickable-urls-in-android-textviews/</link>
		<comments>http://blog.elsdoerfer.name/2009/10/29/clickable-urls-in-android-textviews/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 04:28:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://blog.elsdoerfer.name/?p=120</guid>
		<description><![CDATA[Android&#8217;s TextView widget can contain clickable URLs. It can easily make web addresses open in the browser, or connect phone numbers with the dialer. All that is amazing compared to the last GUI framework I used, Delphi&#8217;s once great VCL). Unfortunately, both TextView and the Linkify utility it uses basically hardcode URL click handling to [...]]]></description>
			<content:encoded><![CDATA[<p>Android&#8217;s <a href="http://developer.android.com/reference/android/widget/TextView.html">TextView</a> widget can contain clickable URLs. It can easily make web addresses open in the browser, or connect phone numbers with the dialer. All that is amazing compared to the last GUI framework I used, Delphi&#8217;s once great <a href="http://en.wikipedia.org/wiki/Visual_Component_Library">VCL</a>).</p>
<p>Unfortunately, both <em>TextView</em> and the <a href="http://developer.android.com/reference/android/text/util/Linkify.html">Linkify</a> utility it uses basically hardcode URL click handling to Intents, by way of the <a href="http://developer.android.com/reference/android/text/style/URLSpan.html">URLSpan</a>s they create. What if we want the link to affect something within your own Activity, say, display a dialog, or enable a filter? </p>
<p>For example, in <a href="http://elsdoerfer.name/=android-autostarts">Autostarts</a>, if the user&#8217;s filters cause the application list to be empty, I wanted to display an explanatory message, and provide a quick and easy way for the user to rectify the situation, i.e. lead him towards the filter selection dialog. Making the whole text clickable is hard to get right visually, and I didn&#8217;t like the idea of a button too much. A link within the text seemed perfect.</p>
<p>Now, we could just use a custom URL scheme of course, and register our Activity to handle Intents for that scheme, but that seemed much too heavy, if not hacky. Why shouldn&#8217;t we be able to just hook up an onClick handler?</p>
<p>As mentioned, <em>URLSpan</em> doesn&#8217;t allow us to change the way it handles clicks (it always sends off an Intent), but we can create a subclass:</p>
<pre name="code" class="java">
static class InternalURLSpan extends ClickableSpan {
	OnClickListener mListener;

	public InternalURLSpan(OnClickListener listener) {
		mListener = listener;
	}

	@Override
	public void onClick(View widget) {
		mListener.onClick(widget);
	}
}
</pre>
<p>That looks pretty decent. Actually using that class it is tougher. There is no way to tell <em>TextView</em> or <em>Linkify</em> to use our custom span. In fact, <em>Linkify</em> actually has <a href="http://www.google.com/codesearch/p?hl=en&#038;sa=N&#038;cd=1&#038;ct=rc#uX1GffpyOZk/core/java/android/text/util/Linkify.java&#038;q=class:Linkify%20android&#038;l=378">a method (<em>applyLink</em>)</a> that would be nearly perfect to override, but declares it final.</p>
<p>So, we end up having to generate the spans manually; note nice, but hey, it works.</p>
<pre name="code" class="java">
SpannableString f = new SpannableString("....")
f.setSpan(new InternalURLSpan(new OnClickListener() {
        public void onClick(View v) {
            showDialog(DIALOG_VIEW_OPTIONS);
        }
    }), x, y, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
</pre>
<p>We probably also want the user to jump to your link my moving the focus (e.g. using the trackball), which we can do by setting the proper movement method:</p>
<pre name="code" class="java">
MovementMethod m = emptyText.getMovementMethod();
if ((m == null) || !(m instanceof LinkMovementMethod)) {
    if (textView.getLinksClickable()) {
        textView.setMovementMethod(LinkMovementMethod.getInstance());
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.elsdoerfer.name/2009/10/29/clickable-urls-in-android-textviews/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Android: Determine if running in emulator</title>
		<link>http://blog.elsdoerfer.name/2009/07/24/android-determine-if-running-in-emulator/</link>
		<comments>http://blog.elsdoerfer.name/2009/07/24/android-determine-if-running-in-emulator/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 14:39:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://blog.elsdoerfer.name/?p=108</guid>
		<description><![CDATA[if ("1".equals(SystemProperties.get("ro.kernel.qemu")) { // Emulator } [via]]]></description>
			<content:encoded><![CDATA[<pre name="code" class="java">
if ("1".equals(SystemProperties.get("ro.kernel.qemu")) {
    // Emulator
}
</pre>
<p>[<a href="http://www.google.com/codesearch?hl=en&#038;lr=&#038;q=ro.kernel.qemu">via</a>]</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.elsdoerfer.name/2009/07/24/android-determine-if-running-in-emulator/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Writing an Android Widget: What the docs don&#8217;t tell you</title>
		<link>http://blog.elsdoerfer.name/2009/06/03/writing-an-android-widget-what-the-docs-dont-tell-you/</link>
		<comments>http://blog.elsdoerfer.name/2009/06/03/writing-an-android-widget-what-the-docs-dont-tell-you/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 17:40:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://blog.elsdoerfer.name/2009/06/03/writing-an-android-widget-what-the-docs-dont-tell-you/</guid>
		<description><![CDATA[Having recently written my first Widget for Android, here are some of the things I learned in the process. Use a thread, not just a service In the blog post introducing the AppWidget framework, you are encouraged to use a service to perform your widget updates if you are doing anything that might take a [...]]]></description>
			<content:encoded><![CDATA[<p>Having recently written my first <a href="http://elsdoerfer.name/=beautifulpictures">Widget for Android</a>, here are some of the things I learned in the process.</p>
<p><strong>Use a thread, not just a service</strong></p>
<p>In the <a href="http://android-developers.blogspot.com/2009/04/introducing-home-screen-widgets-and.html">blog post</a> introducing the AppWidget framework, you are encouraged to use a service to perform your widget updates if you are doing anything that might take a little longer, in order to avoid <em>Application Not Responding</em> (ANR) timeouts. <strong>However, this will usually not be enough. </strong>Since your service callbacks <em>also</em> run in your application&#8217;s main thread, you&#8217;ll still be in danger of triggering ANR as soon as your process is asked to do other things while still being busy with your first widget update. For example, your widget&#8217;s broadcast receiver might be triggered again for another instance of your widget, or the user might start interacting.</p>
<p>The solution is to have your service start a separate thread. For an example, see Jeffrey Sharkey&#8217;s <a href="http://code.google.com/p/android-sky/">android-sky Widget</a>.</p>
<p><strong>Stop your service when you&#8217;re done</strong></p>
<p>When your done with updating (if your using a thread, it&#8217;ll be when your thread has finished), make sure you <strong>stop your service</strong>. Nobody seems to be doing this, including the <a href="http://groups.google.com/group/android-developers">example code in the official blog post</a>, nor <a href="http://code.google.com/p/android-sky/">sample projects by Android team member</a><a href="http://code.google.com/p/android-sky/">s</a>. As a result, so many widgets have their process run in the background <em>all the time</em>, not allowing Android to kill it to reclaim memory. Considering that RAM isn&#8217;t exactly a plentiful resource on devices like the G1, I would have thought this were especially important. Unless your updating multiple times an hour, I would strongly suggest that stopping your service and letting Android free up your process when necessary is the right thing to do.</p>
<p><strong>Try to work around the bugs in Android 1.5 and the Launcher&#8217;s Widget implementation</strong></p>
<p>It turns out there are <a href="http://groups.google.com/group/android-developers/browse_thread/thread/365d1ed3aac30916">quite a few of them</a>, and they all seem to revolve around issues with deleting a widget. In particular:</p>
<ul>
<li><em>AppWidgetProvider</em> fails to handle delete intents correctly. As a result, if you are subclassing it, your <em>onDelete() </em>method will not be called. The solution is to override <em>onReceive()</em> and handling delete intents yourself. Here&#8217;s a <a href="http://groups.google.com/group/android-developers/browse_thread/thread/365d1ed3aac30916">code snippet</a>.</li>
<li>In any case, if a user deletes an instance of your widget, the 1.5 default home screen will still keep sending update requests for the already deleted widget&#8217;s id, until the user adds <em>a new</em> instance of your widget<em> </em>(apparently, some internal bundle of widget ids is not reset on delete). This seems like this could result in a considerable waste of resources, or even impact your functionality, with you sending out widget updates that nobody is going to see. Note: I&#8217;m not sure if those obsolete widget ids are cleared out on reboot (probably). You might also not have this problem if you&#8217;re using custom scheduling instead of the default update facility.<br />
The best one can do here appears to be keeping an internal list of deleted widgets (widgets for which you &#8211; hopefully &#8211; received a delete intent), and then just skipping those updates.</li>
<li>Finally, there seems to be another issue with phantom widgets when a configure activity is used and the user cancels it. In this case also, you&#8217;ll continue to receive updates for the widget (which won&#8217;t be shown anywhere), except it seems even worse, because apparently this time around, widget will <em>really</em> exist internally, rather than just some internal state not being update correctly (so even a reboot won&#8217;t help here).<br />
The work around seems similar: keep information around that indicates whether a widget as been configured successfully, and don&#8217;t bother updating widgets that haven&#8217;t.</li>
</ul>
<p>2009-07-18: It appears there is <em>another</em> <a href="http://groups.google.com/group/android-developers/browse_thread/thread/869afdb312fc1e76/cb49f5e728430e75">widget bug</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.elsdoerfer.name/2009/06/03/writing-an-android-widget-what-the-docs-dont-tell-you/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Layout Editor in 1.5 SDK</title>
		<link>http://blog.elsdoerfer.name/2009/05/26/layout-editor-in-15-sdk/</link>
		<comments>http://blog.elsdoerfer.name/2009/05/26/layout-editor-in-15-sdk/#comments</comments>
		<pubDate>Tue, 26 May 2009 09:04:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://blog.elsdoerfer.name/2009/05/26/layout-editor-in-15-sdk/</guid>
		<description><![CDATA[Android&#8217;s layout editor  for Eclipse is much improved in the 1.5 SDK vs. the old 1.0/1.1 versions. Unfortunately, I didn&#8217;t realize that until yesterday, because the new controls didn&#8217;t show up for me. Instead, Eclipse just said: Eclipse is loading framework information and the Layout library from the SDK folder.  file.xml will refresh automatically once [...]]]></description>
			<content:encoded><![CDATA[<p>Android&#8217;s layout editor  for Eclipse is much improved in the 1.5 SDK vs. the old 1.0/1.1 versions. Unfortunately, I didn&#8217;t realize that until yesterday, because the new controls didn&#8217;t show up for me. Instead, Eclipse just said:</p>
<p><em>Eclipse is loading framework information and the Layout library from the SDK folder.  file.xml will refresh automatically once the process is finished.</em></p>
<p>Of course, the process never finished. Because I never had any use for the old version, at first I didn&#8217;t even know something was wrong.</p>
<p>There seem to be a <a href="http://groups.google.com/group/android-developers/browse_thread/thread/065b4e55f0189873 ">handful of people</a> out there with the same problem, although none of the suggested solutions worked for me. Until I found this <a href="http://translate.google.com/translate?hl=en&amp;sl=es&amp;u=http://www.android-spa.com/viewtopic.php?t=2129">Spanish site.</a> It turns I should have uninstalled the old Eclipse plugin before installing the 1.5 SDK one. In my plugin directory (<em>~/.eclipse/plugins</em>), there were still .jar files from the old version around (named 0.8, apparently). Simple removing those files and restarting Eclipse did the trick for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.elsdoerfer.name/2009/05/26/layout-editor-in-15-sdk/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Android: Fix package uid mismatches</title>
		<link>http://blog.elsdoerfer.name/2009/05/25/android-fix-package-uid-mismatches/</link>
		<comments>http://blog.elsdoerfer.name/2009/05/25/android-fix-package-uid-mismatches/#comments</comments>
		<pubDate>Mon, 25 May 2009 15:17:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://blog.elsdoerfer.name/2009/05/25/android-fix-package-uid-mismatches/</guid>
		<description><![CDATA[A while ago, I set up Apps2SD on my ADP, and while I am not sure what, I must have done something wrong, because afterwards, Android refused to boot properly, claiming that the file system permissions of pretty much all installed packages didn&#8217;t match up: Package x.y.z has mismatched uid: 10089 on disk, 10079 in [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago, I set up <a href="http://forum.xda-developers.com/showthread.php?t=512743">Apps2SD</a> on my ADP, and while I am not sure what, I must have done <em>something</em> wrong, because afterwards, Android refused to boot properly, claiming that the file system permissions of pretty much all installed packages didn&#8217;t match up:</p>
<p><em>Package x.y.z has mismatched uid: 10089 on disk, 10079 in settings</em></p>
<p>Here&#8217;s the Python script I used to apply the file system permissions that Android expected. It iterates over the packages defined in your devices <em>/data/system/packages.xml</em>. Use at your own risk.</p>
<pre name="code" class="python">
"""Parse Android's /data/system/packages.xml file and spits out
shell code to fix UIDs.

This helps you fix "Package x.y.z has mismatched uid: 10089 on disk, 10079
in settings" errors.
"""

from xml.dom import minidom

xmldoc = minidom.parse('packages.xml')

packages = xmldoc.getElementsByTagName('package')
ignored = []
for package in packages:
    try:
        userId = package.attributes['userId'].value
        is_shared = False
    except KeyError:
        userId = package.attributes['sharedUserId'].value
        is_shared = True

    # do not touch permissions of shared apks (they userid always seems to be 1000)
    if not is_shared:
        print "busybox chown %s:%s %s" % (userId, userId, package.attributes['codePath'].value) 

    for subdir in ('', 'databases', 'shared_prefs'):  # note we don't touch lib/
        print "busybox chown %s %s:%s /data/data/%s/%s" % (
            '-R' if subdir else '', userId, userId, package.attributes['name'].value, subdir)</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.elsdoerfer.name/2009/05/25/android-fix-package-uid-mismatches/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Android: System hangs on reboot after upgrade?</title>
		<link>http://blog.elsdoerfer.name/2009/05/13/android-system-hangs-on-reboot-after-upgrade/</link>
		<comments>http://blog.elsdoerfer.name/2009/05/13/android-system-hangs-on-reboot-after-upgrade/#comments</comments>
		<pubDate>Wed, 13 May 2009 21:49:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://blog.elsdoerfer.name/2009/05/13/android-system-hangs-on-reboot-after-upgrade/</guid>
		<description><![CDATA[While upgrading my G1 to the new 1.5 JF image, the system wouldn&#8217;t come back up after applying the update.zip file (yes, it&#8217;s normal that the first reboot takes a while, but this was too long). adb logcat was usuable at that point, and kept looping messages like: D/AndroidRuntime(   66): &#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62; AndroidRuntime START &#60;&#60;&#60;&#60;&#60;&#60;&#60;&#60;&#60;&#60;&#60;&#60;&#60;&#60; D/AndroidRuntime(   [...]]]></description>
			<content:encoded><![CDATA[<p>While upgrading my G1 to the new <a href="http://jf.andblogs.net/2009/05/01/when-is-your-15-coming-out/">1.5 JF image</a>, the system wouldn&#8217;t come back up after applying the update.zip file (yes, it&#8217;s normal that the first reboot takes a while, but this was too long).</p>
<p><em>adb logcat </em>was usuable at that point, and kept looping messages like:</p>
<p><em>D/AndroidRuntime(   66): &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; AndroidRuntime START &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;<br />
D/AndroidRuntime(   66): CheckJNI is OFF<br />
D/dalvikvm(   66): DexOpt: incorrect opt magic number (0xff ff ff ff)<br />
D/dalvikvm(   66): Stale deps in cache file; removing and retrying<br />
W/dalvikvm(   66): partial write in inflate (8152 vs 32768)<br />
E/dalvikvm(   66): <strong>Unable to extract</strong>+optimize DEX from &#8216;/system/framework/framework.jar&#8217;<br />
D/dalvikvm(   66): Failed on &#8216;/system/framework/framework.jar&#8217; (boot=1)<br />
D/dalvikvm(   66): VM cleaning up<br />
D/dalvikvm(   66): LinearAlloc 0&#215;0 used 4100 of 4194304 (0%)<br />
W/dalvikvm(   66): JNI_CreateJavaVM failed<br />
E/AndroidRuntime(   66): JNI_CreateJavaVM failed</em></p>
<p>Turns out that the 8MB free space I had on my data partition were not enough for the update. Removing a couple larger apps through the shell let the boot process continue (though in the end, I used a backup to start a new, &#8220;clean&#8221; update).  All in all, the update needed an additional 22 MB on my phone. I&#8217;m not sure if this is JF specific and the actual 1.5 image is smaller, but, if you run into trouble, this might be the reason.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.elsdoerfer.name/2009/05/13/android-system-hangs-on-reboot-after-upgrade/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Android: Using metric units from within code</title>
		<link>http://blog.elsdoerfer.name/2009/01/17/android-using-metric-units-from-within-code/</link>
		<comments>http://blog.elsdoerfer.name/2009/01/17/android-using-metric-units-from-within-code/#comments</comments>
		<pubDate>Sat, 17 Jan 2009 22:32:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://blog.elsdoerfer.name/2009/01/17/android-using-metric-units-from-within-code/</guid>
		<description><![CDATA[When designing a layout in XML, Android supports a number of different metrics. From your Java code though, methods like setPadding or setTextSize only take absolute pixel values. It took me a while to find a solution, but apparently the (slightly too cumbersome, I feel) way to to this is through defining a Dimension Resource. [...]]]></description>
			<content:encoded><![CDATA[<p>When designing a layout in XML, Android supports <a href="http://code.google.com/android/devel/ui/xml.html">a number of different metrics</a>. From your Java code though, methods like <a href="http://code.google.com/android/reference/android/view/View.html#setPadding(int,%20int,%20int,%20int)">setPadding</a> or <a href="http://code.google.com/android/reference/android/widget/TextView.html#setTextSize(float)">setTextSize</a> only take absolute pixel values. It took me a while to find a solution, but apparently the (slightly too cumbersome, I feel) way to to this is through defining a <a href="http://code.google.com/android/reference/available-resources.html#dimension">Dimension Resource</a>.</p>
<p>For example, create a resource file in <em>./res/values/dimens.xml</em> and add this item:</p>
<pre name="code" class="xml">&lt;dimen name=table_padding&gt;10dp&lt;/dimen&gt;</pre>
<p>Then, from within your activity you would do:</p>
<pre name="code" class="java">int tablePadding = getResources().getDimensionPixelSize(R.dimen.table_padding);</pre>
<p>I wonder whether the conversion code used by <em>getDimension/getDimensionPixelSize</em> is exposed somewhere.</p>
<p><em>Edit April 2010</em>: There&#8217;s actually a snippet in this <a href="http://developer.android.com/intl/de/guide/practices/screens_support.html">document about screen sizes</a>, which is essentially this function:</p>
<pre name="code" class="java">
private int dipToPixels(float dipValue) {
     return (int) (dipValue * getResources().getDisplayMetrics().density + 0.5f);
}
</pre>
<p>As far as I can tell, the <em>+0.5</em> part is intended to ensure that the result is  at least 1 pixel always.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.elsdoerfer.name/2009/01/17/android-using-metric-units-from-within-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

