<?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>dimitar.me</title>
	<atom:link href="http://dimitar.me/feed/" rel="self" type="application/rss+xml" />
	<link>http://dimitar.me</link>
	<description>Dimitar Darazhanski&#039;s blog.</description>
	<lastBuildDate>Wed, 01 Feb 2012 03:17:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Remove vim color coding in Ubuntu</title>
		<link>http://dimitar.me/remove-vim-color-coding-in-ubuntu/</link>
		<comments>http://dimitar.me/remove-vim-color-coding-in-ubuntu/#comments</comments>
		<pubDate>Mon, 07 Nov 2011 21:53:59 +0000</pubDate>
		<dc:creator>dimitar</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://dimitar.me/?p=1187</guid>
		<description><![CDATA[By default Ubuntu&#8217;s vim utility is configured to color code certain keywords, comments, extensions, etc. I personally do not like this. So I just disable that feature. And while I am at it, I also enable the ruler, which displays the line number and the character position of the cursor. To do that for all [...]]]></description>
			<content:encoded><![CDATA[<p>By default Ubuntu&#8217;s vim utility is configured to color code certain keywords, comments, extensions, etc.</p>
<p>I personally do not like this. So I just disable that feature. And while I am at it, I also enable the ruler, which displays the line number and the character position of the cursor.</p>
<p>To do that for all users, edit the /etc/vim/vimrc file add the following lines to it:</p>
<pre><code>syntax off		" Clear any font/color/hilighting
set ruler		" Enable the ruler</code></pre>
<p>If you want to do that just for a particular user, create a .vimrc file in that user&#8217;s home directory (if it does not already exist) and add the same lines to it.</p>
]]></content:encoded>
			<wfw:commentRss>http://dimitar.me/remove-vim-color-coding-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Switch your Google Checkout Account in the Android Market Application</title>
		<link>http://dimitar.me/how-to-switch-your-google-checkout-account-in-the-android-market-application/</link>
		<comments>http://dimitar.me/how-to-switch-your-google-checkout-account-in-the-android-market-application/#comments</comments>
		<pubDate>Mon, 15 Aug 2011 18:38:16 +0000</pubDate>
		<dc:creator>dimitar</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://dimitar.me/?p=1163</guid>
		<description><![CDATA[With Google&#8217;s last update of the Market application on the Android devices, it became a lot easier to now switch your Google Checkout account associated with all your application purchases. Just fire up the Market application on your device and press the Menu button. That gives you the &#8220;Accounts&#8221; option, which allows you to switch [...]]]></description>
			<content:encoded><![CDATA[<p>With Google&#8217;s last update of the Market application on the Android devices, it became a lot easier to now switch your Google Checkout account associated with all your application purchases.</p>
<p>Just fire up the Market application on your device and press the Menu button. That gives you the &#8220;Accounts&#8221; option, which allows you to switch the Google Checkout account associated with your Market application:</p>
<p><a href="http://dimitar.me/wp-content/uploads/2011/08/AndroidMarketApplication_2011_08_15.png"><img src="http://dimitar.me/wp-content/uploads/2011/08/AndroidMarketApplication_2011_08_15-180x300.png" alt="" title="AndroidMarketApplication_2011_08_15" width="180" height="300" class="aligncenter size-medium wp-image-1167" /></a></p>
<p>Of course you have to have added your new Google account to the available accounts on the phone before you can do the above switch. To do this, go to:</p>
<p>Menu -> Settings -> Accounts &#038; sync</p>
<p>and add your account (new Gmail email) here. Then you can go to the Market application and switch to this new account.</p>
<p>In the past this used to require a factory reset of the device or a root access.</p>
<p>Although this is a great feature for the consumer, it might also turn out to be an issue in the long run. All downloaded/purchased applications are associated with the Google Checkout account used at the time of acquiring them from the Market. So if you switch your account in the Market application, you will no longer have access to the applications you purchases or downloaded with the previous account. For example, when you go to &#8220;My Apps&#8221; in the Market application, you will not be able to see the application you downloaded with your old account. </p>
<p>Furthermore (unless Google is doing something new that I am not aware of) all the licensed application you purchased from the Market with the old account will begin to complain that they are not licensed for your new account. </p>
]]></content:encoded>
			<wfw:commentRss>http://dimitar.me/how-to-switch-your-google-checkout-account-in-the-android-market-application/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to sign an unsigned Android package (.apk file)</title>
		<link>http://dimitar.me/how-to-sign-an-unsigned-android-package-apk-file/</link>
		<comments>http://dimitar.me/how-to-sign-an-unsigned-android-package-apk-file/#comments</comments>
		<pubDate>Fri, 29 Apr 2011 18:49:27 +0000</pubDate>
		<dc:creator>dimitar</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://dimitar.me/?p=1143</guid>
		<description><![CDATA[If you develop with Eclipse, you most likely use the built in Export Wizard to export and sign your Android applications. There are some cases though, when this method will not do. For example, if you decide to publish your applications on the new Amazon App Store, you will find out that they require you [...]]]></description>
			<content:encoded><![CDATA[<p>If you develop with Eclipse, you most likely use the built in Export Wizard to export and sign your Android applications.</p>
<p>There are some cases though, when this method will not do. For example, if you decide to publish your applications on the new Amazon App Store, you will find out that they require you to submit an unsigned apk first. They do some optimizations and DRM (if you chose to use it) processing of it, and then they allow you to download the new package and sign and re-upload the final .apk file.</p>
<p>Amazon provides an option to sign the package for you, but in a lot of cases that will not work. For example, if you use some Google API&#8217;s (like Google Maps, etc.) you must sign it yourself! Otherwise the application will not work!</p>
<p>Steps to sign your application:</p>
<p>1. Export the unsigned package:</p>
<p>Right click on the project in Eclipse -&gt; Android Tools -&gt; Export Unsigned Application Package</p>
<p>2. Sign the application using your keystore and the jarsigner tool (comes with the JDK):</p>
<p>Change directory to where your unsigned .apk file is. Then run:</p>
<pre><code>jarsigner -verbose -keystore /path_to_keystore/mykeystore.keystore my_application.apk my_keystore_alias</code></pre>
<p>It will ask you to provide your password:</p>
<p>Enter Passphrase for keystore:</p>
<p>Once you enter the password it will sign your apk. To verify that the signing is successful you can run:</p>
<pre><code>jarsigner -verify my_application.apk</code></pre>
<p>It should come back with:</p>
<p>jar verified.</p>
<p>Just an FYI: The jarsigner tool should be in your /usr/bin directory by default.</p>
<p>Here is a detailed documentation on signing your Android applications: <a href="http://developer.android.com/guide/publishing/app-signing.html" onclick="pageTracker._trackPageview('/outgoing/developer.android.com/guide/publishing/app-signing.html?referer=');">http://developer.android.com/guide/publishing/app-signing.html</a></p>
<p>3. Do not forget to zipalign the .apk at the very end!</p>
<p>Even though this is not absolutely necessary, it is highly recommended. The zipalign tool optimizes the .apk file and makes it a lot faster to execute.</p>
<p>To zipalign your application:</p>
<pre><code>zipalign -f -v 4 my_application.apk my_zipaligned_application.apk</code></pre>
<p>As you can see, zipalign expects you to provide the input .apk file and specify what you want the output file to be named.</p>
<p><a href="http://developer.android.com/resources/articles/zipalign.html" onclick="pageTracker._trackPageview('/outgoing/developer.android.com/resources/articles/zipalign.html?referer=');">Zipalign tool documentation.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dimitar.me/how-to-sign-an-unsigned-android-package-apk-file/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Eclipse Project is Flagged with an &#8220;Android Packaging Problem&#8221; Error</title>
		<link>http://dimitar.me/eclipse-project-is-flagged-with-an-android-packaging-problem-error/</link>
		<comments>http://dimitar.me/eclipse-project-is-flagged-with-an-android-packaging-problem-error/#comments</comments>
		<pubDate>Sat, 29 Jan 2011 03:37:31 +0000</pubDate>
		<dc:creator>dimitar</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://dimitar.me/?p=1137</guid>
		<description><![CDATA[Sometimes while developing in Eclipse you will notice that the Android Project will be flagged with the red &#8220;x&#8221; but none of your source files or resources will have errors. If you look in the &#8220;Problems&#8221; tab you will notice that the project is flagged with an &#8220;Android Package Problem&#8221; type and the &#8220;Location&#8221; will [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes while developing in Eclipse you will notice that the Android Project will be flagged with the red &#8220;x&#8221; but none of your source files or resources will have errors. If you look in the &#8220;Problems&#8221; tab you will notice that the project is flagged with an &#8220;Android Package Problem&#8221; type and the &#8220;Location&#8221; will be Unknown.</p>
<p>To fix this, just do:</p>
<p>Project->Clean</p>
<p>This will rebuild the project from scratch.</p>
]]></content:encoded>
			<wfw:commentRss>http://dimitar.me/eclipse-project-is-flagged-with-an-android-packaging-problem-error/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Android Version 2.2.2 Prevents Applications with Copy Protection Turned on from Displaying in the Market</title>
		<link>http://dimitar.me/android-version-2-2-2-prevents-applications-with-copy-protection-turned-on-from-displaying-in-the-market/</link>
		<comments>http://dimitar.me/android-version-2-2-2-prevents-applications-with-copy-protection-turned-on-from-displaying-in-the-market/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 04:07:11 +0000</pubDate>
		<dc:creator>dimitar</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://dimitar.me/?p=1126</guid>
		<description><![CDATA[Today I got the Over the Air update of my Nexus One phone to version 2.2.2. To my surprise I could not see some of my applications that were published in the Android Market. Neither could I see a big chunk of the total applications in the Android Market. After some tests and digging it [...]]]></description>
			<content:encoded><![CDATA[<p>Today I got the Over the Air update of my Nexus One phone to version 2.2.2. To my surprise I could not see some of my applications that were published in the Android Market. Neither could I see a big chunk of the total applications in the Android Market.</p>
<p>After some tests and digging it turned out that applications that have the &#8220;Copy Protection&#8221; turned on in the &#8220;Developer Console&#8221; would not be displayed in the Android Market on devices running version 2.2.2.</p>
<p>I have not tested this on devices with ver. 2.3 and 3.0, but I would suspect that the result would be the same.</p>
<p>For a long while the &#8220;Copy Protection&#8221; feature has been marked as &#8220;will be deprecated soon&#8221; by Google. No date or any other pointer has been published by Google as to when that will be. I guess we got the answer with this last OS update.</p>
<p>If you want your application to be available to all the devices running the latest OS versions, you will have to turn off the copy protection feature. Of course if your application is paid you would still want to make sure that only people that have purchased it will be able to run it. To do that, just implement the <a href="http://developer.android.com/guide/publishing/licensing.html" onclick="pageTracker._trackPageview('/outgoing/developer.android.com/guide/publishing/licensing.html?referer=');">licensing service</a> in your application.</p>
]]></content:encoded>
			<wfw:commentRss>http://dimitar.me/android-version-2-2-2-prevents-applications-with-copy-protection-turned-on-from-displaying-in-the-market/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to enable the ath9k wireless driver on Ubuntu Lucid (10.04)</title>
		<link>http://dimitar.me/how-to-enable-the-ath9k-wireless-driver-on-ubuntu-lucid-10-04/</link>
		<comments>http://dimitar.me/how-to-enable-the-ath9k-wireless-driver-on-ubuntu-lucid-10-04/#comments</comments>
		<pubDate>Fri, 17 Sep 2010 23:06:20 +0000</pubDate>
		<dc:creator>dimitar</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://dimitar.me/?p=1043</guid>
		<description><![CDATA[Ath9k is the latest wireless driver for the newer Atheros chipsets and just like the MadWifi driver could be used to put your NIC in a promiscuous mode, do packet injection, etc. in order to crack WEP. Check the compatibility of your wireless NIC first. To find out what kind of chipset you have, run: [...]]]></description>
			<content:encoded><![CDATA[<p>Ath9k is the latest wireless driver for the newer Atheros chipsets and just like the MadWifi driver could be used to put your NIC in a promiscuous mode, do packet injection, etc. in order to crack WEP. </p>
<p><a href="http://linuxwireless.org/en/users/Drivers/ath9k#supported_chipsets" onclick="pageTracker._trackPageview('/outgoing/linuxwireless.org/en/users/Drivers/ath9k_supported_chipsets?referer=');">Check the compatibility of your wireless NIC</a> first.<br />
To find out what kind of chipset you have, run:</p>
<pre><code>lspci | grep -i wireless</code></pre>
<p>The ath9k driver is present in any kernel starting with version 2.6.27. The oldest supported ath9k version comes with kernel 2.6.32. That means most likely you already have the driver and there is no need to download it, all you have to do is enable it.</p>
<p>The general steps in order to enable ath9k are:</p>
<ol>
<li>Get the kernel source and some necessary packages</li>
<li>Configure the kernel</li>
<li>Compile and install the kernel</li>
<li>Configure grub to boot from the new kernel image</li>
</ol>
<p>Some steps might sound a bit intimidating, but actually they are very easy to do. </p>
<p>Since you will be running a lot of commands as root, it would be more convenient to open a bash shell as root instead of preceding all commands with <em>sudo</em>. The easiest way to do this is to run the following command it terminal:</p>
<pre><code>$ sudo bash</code></pre>
<p><strong>Note</strong>: The above command has nothing to do with enabling the root login. I strongly recommend to never enable the root login due to serious security risks! Some blogs might ask you to do that, but there is hardly ever any reason to do this. </p>
<p><strong>1. Get the kernel source and some necessary packages</strong></p>
<pre><code># aptitude install git-core build-essential kernel-package qt3-dev-tools libqt3-mt-dev fakeroot
# apt-get install linux-source </code></pre>
<p>The above command downloaded the kernel source tarball in /usr/src.<br />
In my case the kernel version I am working with is 2.6.32 (patch level 15). Replace these numbers with the version of your kernel source.<br />
Now lets cd to the place we downloaded the kernel source:</p>
<pre><code># cd /usr/src</code></pre>
<p>Uncompress and extract the kernel source:</p>
<pre><code># tar xjvf linux-source-2.6.32.tar.bz2
# cd linux-source-2.6.32</code></pre>
<p><strong>2. Configure the kernel</strong></p>
<p>Before configuring the kernel, lets import the configuration of the currently running kernel. This way we do not miss to enable something we currently have and need:</p>
<pre><code># cp -vi /boot/config-`uname -r` .config</code></pre>
<p>Now we are ready to add a few configurations to the kernel:</p>
<pre><code># make xconfig</code></pre>
<p>This opens up an xwindow with a hierarchical structure representing the kernel settings:</p>
<div id="attachment_1087" class="wp-caption aligncenter" style="width: 530px"><a href="http://dimitar.me/wp-content/uploads/2010/09/Screenshot-Linux-Kernel-Configuration.png"><img src="http://dimitar.me/wp-content/uploads/2010/09/Screenshot-Linux-Kernel-Configuration.png" alt="Linux Kernel Configuration" title="Linux Kernel Configuration" width="520" height="402" class="size-full wp-image-1087" /></a><p class="wp-caption-text">Linux Kernel Configuration</p></div>
<p>First enable mac80211:</p>
<pre><code>Networking  --->
  Wireless  --->
    <M> Improved wireless configuration API
    <M> Generic IEEE 802.11 Networking Stack (mac80211)</code></pre>
<p>You can then enable ath9k in the kernel configuration under:</p>
<pre><code>Device Drivers  --->
  [*] Network device support  --->
        Wireless LAN  --->
          <M>   Atheros 802.11n wireless cards support</code></pre>
<p>If you re-used the existing configuration, note that Ubuntu kernels build with debugging information on, which makes the resulting kernel modules (*.ko files) much larger than they would otherwise be. To turn this off, go into &#8220;Kernel hacking&#8221;; then, under &#8220;Kernel debugging&#8221;, turn OFF &#8220;Compile the kernel with debug info&#8221;.</p>
<p>Save changes and exit.</p>
<p><strong>3. Compile and install the kernel</strong></p>
<p>First, let&#8217;s ensure a &#8220;clean&#8221; build:</p>
<pre><code># make-kpkg clean</code></pre>
<p>Since the kernel compilation might take some time, it is best to set the CONCURRENCY_LEVEL variable, so that it can take a full advantage of the multiple processors or mulitple CPU cores on the machine. The CONCURRENCY_LEVEL variable is equal to the number of processors on the machine plus one. So if your machine has a dual core processor the variable will be equal to 3. To find out how many processors or cores your computer has run:</p>
<pre><code># lshw -C CPU</code></pre>
<p>In my case I get <em>cpu:0</em> and <em>cpu:1</em>, which means that I have a dual core processor.<br />
Besides the CONCURRENCY_LEVEL, the only other thing we need to pay attention to here is the &#8220;&#8211;append-to-version&#8221; option. It basically adds that string to the end of the kernel name and could be set to anything. That gives you the opportunity to put there something meaningful to distingush the kernel from the other ones. In this case I called it &#8220;-mykernel&#8221;. </p>
<p>Now you are ready to compile:</p>
<pre><code># CONCURRENCY_LEVEL=3 fakeroot make-kpkg --initrd --append-to-version=-mykernel kernel-image kernel-headers</code></pre>
<p>If you want to see the ubuntu splash screen (or use text mode) before you get to X instead of just a black screen, you&#8217;ll want to make sure the framebuffer driver loads:</p>
<pre><code># echo vesafb >> /etc/initramfs-tools/modules
# echo fbcon >> /etc/initramfs-tools/modules</code></pre>
<p>Now install the kernel and the headers from the created Debian packages:</p>
<pre><code># dpkg -i linux-image-2.6.32.15+drm33.5-mykernel_2.6.32.15+drm33.5-mykernel-10.00.Custom_i386.deb
# dpkg -i linux-headers-2.6.32.15+drm33.5-mykernel_2.6.32.15+drm33.5-mykernel-10.00.Custom_i386.deb</code></pre>
<p>Now let&#8217;s generate an initramfs (initrd) image, that will be loaded up by grub on boot:</p>
<pre><code># cd /boot</code></pre>
<p>To avoid confusion with the next command, here is what my <em>/boot</em> directory contains before I run the mkinitramfs command:</p>
<pre><code># ls -altr
total 27700
-rw-r--r--  1 root root  160280 2010-03-23 05:37 memtest86+.bin
-rw-r--r--  1 root root 4034976 2010-08-20 14:22 vmlinuz-2.6.32-24-generic
-rw-r--r--  1 root root 1689036 2010-08-20 14:22 System.map-2.6.32-24-generic
-rw-r--r--  1 root root  115905 2010-08-20 14:22 config-2.6.32-24-generic
-rw-r--r--  1 root root  651618 2010-08-20 14:22 abi-2.6.32-24-generic
-rw-r--r--  1 root root    1196 2010-08-20 14:24 vmcoreinfo-2.6.32-24-generic
drwxr-xr-x 22 root root    4096 2010-09-04 15:27 ..
-rw-r--r--  1 root root       0 2010-09-07 22:11 initrd.img-2.6.31-wl
-rw-r--r--  1 root root 7977082 2010-09-07 22:49 initrd.img-2.6.32-24-generic
-rw-r--r--  1 root root  115845 2010-09-08 02:13 config-2.6.32.15+drm33.5-mykernel
-rw-r--r--  1 root root 3999488 2010-09-08 07:38 vmlinuz-2.6.32.15+drm33.5-mykernel
-rw-r--r--  1 root root 1644782 2010-09-08 07:38 System.map-2.6.32.15+drm33.5-mykernel
drwxr-xr-x  3 root root    4096 2010-09-08 16:01 .</code></pre>
<p>Run the mkinitramfs to generate the initrd:</p>
<pre><code># mkinitramfs -k -o initrd.img-2.6.32.15+drm33.5-mykernel 2.6.32.15+drm33.5-mykernel</code></pre>
<p><strong>4. Configure grub to boot from the new kernel image</strong></p>
<pre><code># update-grub2</code></pre>
<p>The last thing to do is to ensure that the ath9k module loads on boot. That will avoid running modprobe ath9k after each reboot.<br />
So lets add the line ath9k to the end of the /etc/modules file:</p>
<pre><code># echo ath9k >> /etc/modules</code></pre>
<p>Now reboot your computer and chose the new kernel to boot into from the grub menu.</p>
<p>Your wireless NIC should be working now using the ath9k driver.</p>
<hr />
<em>Credits:</em></p>
<ul>
<li>I&#8217;d like to thank Jeff Rall for letting me work with him on this on his computer!</li>
<li><a href="http://linuxwireless.org/en/users/Drivers/ath9k" onclick="pageTracker._trackPageview('/outgoing/linuxwireless.org/en/users/Drivers/ath9k?referer=');">The Linux Wireless Community</a></li>
<li><a href="https://help.ubuntu.com/community/Kernel/Compile" onclick="pageTracker._trackPageview('/outgoing/help.ubuntu.com/community/Kernel/Compile?referer=');">Ubuntu Kernel Compile</a></li>
<li><a href="http://www.thinkwiki.org/wiki/How_to_install_the_development_version_of_atk9k" onclick="pageTracker._trackPageview('/outgoing/www.thinkwiki.org/wiki/How_to_install_the_development_version_of_atk9k?referer=');">How to install the development version of atk9k</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://dimitar.me/how-to-enable-the-ath9k-wireless-driver-on-ubuntu-lucid-10-04/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Android &#8211; Displaying Dialogs From Background Threads</title>
		<link>http://dimitar.me/android-displaying-dialogs-from-background-threads/</link>
		<comments>http://dimitar.me/android-displaying-dialogs-from-background-threads/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 04:39:01 +0000</pubDate>
		<dc:creator>dimitar</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://dimitar.me/?p=1009</guid>
		<description><![CDATA[Having threads to do some heavy lifting and long processing in the background is pretty standard stuff. Very often you would want to notify or prompt the user after the background task has finished by displaying a Dialog. The displaying of the Dialog has to happen on the UI thread, so you would do that [...]]]></description>
			<content:encoded><![CDATA[<p>Having threads to do some heavy lifting and long processing in the background is pretty standard stuff. Very often you would want to notify or prompt the user after the background task has finished by displaying a Dialog.</p>
<p>The displaying of the Dialog has to happen on the UI thread, so you would do that either in the <em>Handler</em> object for the thread or in the <em>onPostExecute</em> method of an <em>AsyncTask</em> (which is a thread as well, just an easier way of implementing it). That is a textbook way of doing this and you would think that pretty much nothing wrong could go with this.</p>
<p>Surprisingly I found out that something CAN actually go wrong with this. After Google updated the Android Market and started giving crash reports to the developers I received the following exception:</p>
<p><em>android.view.WindowManager$BadTokenException: Unable to add window &#8212; token android.os.BinderProxy@447a6748 is not valid; is your activity running?<br />
at android.view.ViewRoot.setView(ViewRoot.java:468)<br />
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)<br />
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)<br />
at android.view.Window$LocalWindowManager.addView(Window.java:424)<br />
at android.app.Dialog.show(Dialog.java:239)<br />
at android.app.Activity.showDialog(Activity.java:2488)<br />
&#8230;<br />
at android.os.Handler.dispatchMessage(Handler.java:99)<br />
&#8230;</em></p>
<p>I only got a couple of these exceptions from thousands of installs, so I knew that was not anything that happens regularly or that it was easy to replicate.</p>
<p>Looking at the stack trace above it gives us a pretty good idea why it failed. It started in the <em>Handler</em> object, which naturally was called by a background thread after it finished its processing. The <em>Handler</em> instance tried to show a Dialog and before it could show it, it tried to set the <em>View</em> for it and then it failed with:</p>
<p><em>android.view.WindowManager$BadTokenException: Unable to add window &#8212; token android.os.BinderProxy@447a6748 is not valid; is your activity running?</em></p>
<p>The <em>447a6748</em> number is just a memory address of an object that no longer exists.</p>
<p>Note- do not get hung up on the exact number. It would be different with every execution.</p>
<p>Now we know why the application crashed, the only thing left is to figure out what caused it?</p>
<p>We know that background threads execute independently of the main UI thread. That means that the user could be interacting with the application during the time that the thread is doing its work under the covers. Well, what happens if the user hits the <em>&#8220;Back&#8221;</em> button on the device while the background thread is running and what happens to the Dialog that this thread is supposed to show? Well, if the timing is right the application will most likely crash with the above described error.</p>
<p>In other words what happens is that the <em>Activity</em> will be going through its destruction when the background thread finishes its work and tries to show a Dialog.</p>
<p>In this case it is almost certain that this should have been handled by the <em>Virtual Machine</em>. It should have recognized the fact that the <em>Activity</em> is in the process of finishing and not even attempted to show the Dialog. This is an oversight of the Google developers and it will probably be fixed some time in the future, but in the meantime the burden is on us to take care of this.</p>
<p>The fix to this is pretty simple. Just test if the <em>Activity</em> is going through its finishing phase before displaying the Dialog:</p>
<pre><code>private Handler myHandler = new Handler() {
  @Override
  public void handleMessage(Message msg) {
    switch (msg.what) {
      case DISPLAY_DLG:
        if (!isFinishing()) {
        showDialog(MY_DIALOG);
        }
      break;
    }
  }
};</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://dimitar.me/android-displaying-dialogs-from-background-threads/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Change the date and time (or any other EXIF image meta-data) of pictures with Ubuntu</title>
		<link>http://dimitar.me/change-the-date-and-time-or-any-other-exif-image-meta-data-of-pictures-with-ubuntu/</link>
		<comments>http://dimitar.me/change-the-date-and-time-or-any-other-exif-image-meta-data-of-pictures-with-ubuntu/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 20:04:06 +0000</pubDate>
		<dc:creator>dimitar</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://dimitar.me/?p=984</guid>
		<description><![CDATA[There is a very flexible and easy Linux tool that helps you change the EXIF meta-data of images. It allows you to change individual files or whole bunch of them with one command. You can also put different rules about what files and how you want to change them if you need to. The program [...]]]></description>
			<content:encoded><![CDATA[<p>There is a very flexible and easy Linux tool that helps you change the EXIF meta-data of images. It allows you to change individual files or whole bunch of them with one command. You can also put different rules about what files and how you want to change them if you need to.</p>
<p>The program is called <em>exiftool</em>. So let&#8217;s install it first. </p>
<p>In terminal execute:</p>
<pre><code>sudo apt-get install libimage-exiftool-perl</code></pre>
<p>Now you are ready to start changing the meta-data of the images.</p>
<p>For example, if I wanted to change all the dates and times (DateTimeOriginal, CreateDate and ModifyDate) of the IMG_01.jpg file to the 8th of August 2010 at 3:35:33 PM I would do:</p>
<pre><code>exiftool -AllDates='2010:08:08 15:35:33' -overwrite_original IMG_01.jpg</code></pre>
<p>If I wanted to change the dates on all the files in the <em>&#8220;images&#8221;</em> directory, I would do:</p>
<pre><code>exiftool -AllDates='2010:08:08 15:35:33' -overwrite_original images</code></pre>
<p>The<em> &#8220;-overwrite_original&#8221;</em> option is necessary if you want to change the meta-data of the original images. If you omit that option, then exiftool will back-up the originals by making a copy of them and adding <em>&#8220;_original&#8221;</em> to the end of the file names.</p>
<p>If you want to change the dates to all the files in the &#8220;images&#8221; directory that were taken by a Cannon camera (and not touch the rest) I would do:</p>
<pre><code>exiftool -AllDates='2010:08:08 15:35:33' -if '$make eq "Canon"' -overwrite_original images</code></pre>
<p>As far as changing dates and times, there is another option of exiftool that lets you do time calculation. </p>
<p>For example, the other day I found out that my camera&#8217;s time was correct but the date was ahead by 30 days. That meant that all the photos I had taken lately had dates that were off by exactly 30 days. If I were to use the above examples I could set the dates individually (which would be a long and tedious process) or set all the images to the same date and time (which would be wrong). In this case I used the date calculating option and just executed:</p>
<pre><code>exiftool -AllDates-=720:00 -overwrite_original images</code></pre>
<p>That command subtracts 720 hours (30 days) off the dates of each image file in the images directory. Now every image has the exact date and time it was taken.</p>
<p>I have only scratched the surface of what this tool is capable of. For more information look at the man pages of the exiftool command.</p>
]]></content:encoded>
			<wfw:commentRss>http://dimitar.me/change-the-date-and-time-or-any-other-exif-image-meta-data-of-pictures-with-ubuntu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Android applications that use the MyLocationOverlay class crash on the new Droid X</title>
		<link>http://dimitar.me/applications-that-use-the-mylocationoverlay-class-crash-on-the-new-droid-x/</link>
		<comments>http://dimitar.me/applications-that-use-the-mylocationoverlay-class-crash-on-the-new-droid-x/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 18:44:20 +0000</pubDate>
		<dc:creator>dimitar</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://dimitar.me/?p=959</guid>
		<description><![CDATA[Update: August 29, 2010 Tested this myself on a friend&#8217;s phone and this bug is definitively not fixed yet despite the recent Motorola updates! The burden is on you (the developer) to fix this if you want your applications to run on a Droid X. Update: August 23, 2010 Still getting reports that the update [...]]]></description>
			<content:encoded><![CDATA[<hr />
<em>Update: August 29, 2010</em><br />
Tested this myself on a friend&#8217;s phone and this bug is definitively not fixed yet despite the recent Motorola updates! The burden is on you (<em>the developer</em>) to fix this if you want your applications to run on a Droid X.<br />
<em>Update: August 23, 2010</em><br />
Still getting reports that the update issued by Motorola last month did not fix this issue!</p>
<hr />
<p>As soon as the new Motorola Droid X came out I started getting reports that my applications would crash on it.</p>
<p>The description I was getting from people was that the application would start, then it would show the Google map and start moving the map and zooming in on to their current location and then all of a sudden the app would crash. By crash I mean they get taken back to the phone&#8217;s home screen. No &#8220;Force Close&#8221; dialog pops up&#8230; nothing&#8230; just gets back to the home screen.</p>
<p>If both the GPS and the Wireless Networks are turned off from the Locations settings then the applications would work fine, but of course that means that the current location of the device would be impossible to find.</p>
<p>At this point I knew that the problem had to do with either the LocationManagers or the LocationOverlays but I had no way of finding out exactly what the problem was until I could get my hands on a Droid X phone and connect it to my computer to look at the execution stack.</p>
<p>Well it turns out the problem is with the default MyLocationOverlay class. The Droid X phones throw an exception when they try to draw the dot showing the location of the device:</p>
<pre><code>E/AndroidRuntime(10458): Uncaught handler: thread main exiting due to  uncaught exception
E/AndroidRuntime(10458): java.lang.ClassCastException:  android.graphics.drawable.BitmapDrawable
E/AndroidRuntime(10458): 	at com.google.android.maps.MyLocationOverlay.getLocationDot(MyLocationOverlay.java:180)
E/AndroidRuntime(10458): 	at com.google.android.maps.MyLocationOverlay.drawMyLocation(MyLocationOverlay.java:561)</code></pre>
<p>Another developer (<a href="http://www.droidforums.net/forum/droid-x-general-discussions/59840-does-my-app-crash-droid-x.html" onclick="pageTracker._trackPageview('/outgoing/www.droidforums.net/forum/droid-x-general-discussions/59840-does-my-app-crash-droid-x.html?referer=');">rgfind</a>l) who had the same problem like I did and who had already made the trip to the Verizon store gave me the above stack trace.</p>
<p>Several possible solutions popped into my head:</p>
<p>1. Stop using the MyLocationOverlay class and start relying only on the LocationManager classes and draw/redraw my current location onLocationChanged.<br />
2. Extend from MyLocationOverlay class and override the draw method.<br />
3. Stop supporting the Droid X.</p>
<p>None of these solutions are ideal with the last one being almost unacceptable.</p>
<p>Luckily the same developer also gave me a link to a solution implementing the 2nd option above, so I did not even have to code it myself. Apparently that is not the first time Motorola phones (Motorola Cliq and Motorola Dext) have a problem with this class. Most likely their builds are missing the drawable resource.</p>
<p>Anyway, the solution consists of the <a href="http://www.spectrekking.com/download/FixedMyLocationOverlay.java" onclick="pageTracker._trackPageview('/outgoing/www.spectrekking.com/download/FixedMyLocationOverlay.java?referer=');">.java file that implements the FixedMyLocationOverlay class</a>, which inherits from the default MyLocationOverlay class and overrides the drawMyLocation method. And a <a href="http://www.spectrekking.com/download/mylocation.png" onclick="pageTracker._trackPageview('/outgoing/www.spectrekking.com/download/mylocation.png?referer=');">.png file</a> with a dot that will be representing the current location on the map.</p>
<p>Just use this derived class FixedMyLocationOverlay instead of the default MyLocationOverlay. If you look at the implementation of the drawMyLocation method, you will see that if the phone has no problem it will use the default implementation of the parent class, but if it throws an exception it will use the custom code to draw the location.</p>
<p>I would think that there are a lot of applications in the Android Market right now that use the default MyLocationOverlay class and all of them will be crashing on the new Droid X until either Motorola gets their act together or the developers realize the issue and work around it.</p>
]]></content:encoded>
			<wfw:commentRss>http://dimitar.me/applications-that-use-the-mylocationoverlay-class-crash-on-the-new-droid-x/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Just Upgraded my Nexus One from Android 2.1 to Android 2.2</title>
		<link>http://dimitar.me/just-upgraded-my-nexus-one-from-android-2-1-to-android-2-2/</link>
		<comments>http://dimitar.me/just-upgraded-my-nexus-one-from-android-2-1-to-android-2-2/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 19:52:05 +0000</pubDate>
		<dc:creator>dimitar</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://dimitar.me/?p=937</guid>
		<description><![CDATA[The latest Android OS version 2.2 (&#8220;Froyo&#8221;) was announced at the Google I/O conference on the 11th of May. As you already probably know it adds multiple enhancements like tethering, wifi hotspot functionality, full support for Flash, etc. Since I use my Nexus One phone for Android development, I did not want to download the [...]]]></description>
			<content:encoded><![CDATA[<p>The latest Android OS version 2.2 (&#8220;Froyo&#8221;) was announced at the Google I/O conference on the 11th of May. As you already probably know it adds multiple enhancements like tethering, wifi hotspot functionality, full support for Flash, etc. Since I use my Nexus One phone for Android development, I did not want to download the update from Google and then install it with adb. I just wanted to wait for the over the air update.</p>
<p>And to my surprise, the first time I looked at my phone this morning, I had this message on the screen:</p>
<div id="attachment_935" class="wp-caption aligncenter" style="width: 310px"><a href="http://dimitar.me/wp-content/uploads/2010/07/Android_2.2_Upgrade_Message.png"><img src="http://dimitar.me/wp-content/uploads/2010/07/Android_2.2_Upgrade_Message-300x225.png" alt="Android 2.2 Upgrade Message" title="Android_2.2_Upgrade_Message" width="300" height="225" class="size-medium wp-image-935" /></a><p class="wp-caption-text">Android 2.2 Upgrade Message</p></div>
<p>I was not sure how long it would take, so I just hit &#8220;Install Later&#8221;. Then a couple of hours later, when I was ready, I just went to Settings -> About Phone -> Software Update and hit &#8220;Restart &#038; Install&#8221;:</p>
<div id="attachment_936" class="wp-caption aligncenter" style="width: 235px"><a href="http://dimitar.me/wp-content/uploads/2010/07/Android_2.2_Settings_SystemUpdates.png"><img src="http://dimitar.me/wp-content/uploads/2010/07/Android_2.2_Settings_SystemUpdates-225x300.png" alt="Android 2.2 Settings -&gt; About Phone -&gt; System Updates" title="Android_2.2_Settings_SystemUpdates" width="225" height="300" class="size-medium wp-image-936" /></a><p class="wp-caption-text">Android 2.2 Settings -> About Phone -> System Updates</p></div>
<p>The phone rebooted and started the upgrade. The whole process with the installation took less than 5 minutes.</p>
<p>I am not going to go into details what the features of Android 2.2 are. There are so many announcements and blog posts on this matter already out there&#8230;</p>
<p>But what I am going to say is that Android is the leading OS in the mobile phone market right now. I can say this definitively, since I have been using iPhones for the past 2 years. I have a 3G and a 3GS phones. I encourage any iPhone user to go and check out an Android device. Please do not look at the low end hardware that runs Android (like the Cliq, the old G1, etc.). Check out the HTC Evo, the HTC Incredible, the Nexus One etc. See for yourselves before you make your decision to get another phone and lock into a 2 year contract. I will mention only a few things you will discover on the Android device that your phone probably does not have right now:</p>
<ol>
<li>Turn by turn voice navigation</li>
<li>Built in tethering</li>
<li>Built in WiFi hotspot capability supporting multiple devices</li>
<li>Full support for Flash</li>
<li>Full blown multitasking on the OS level (no need for the programmer to do anything special)</li>
<li>Integrated speech recognition across the board. Voice input could be used anywhere in place of the text input.</li>
<li>Over the air updates and syncing. That means no iTunes or the like!</li>
</ol>
<p>And many other features that I do not want to get into details right now. I am sure you can fill in the gaps for yourselves&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://dimitar.me/just-upgraded-my-nexus-one-from-android-2-1-to-android-2-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

