<?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>Anthony Dahanne's blog &#187; android</title>
	<atom:link href="http://blog.dahanne.net/category/android/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dahanne.net</link>
	<description>Open Source Software, Java, Ruby, Agility</description>
	<lastBuildDate>Tue, 20 Jul 2010 13:11:30 +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>G2Android 1.5.0 is available : major release !</title>
		<link>http://blog.dahanne.net/2010/07/20/g2android-1-5-0-is-available-major-release/</link>
		<comments>http://blog.dahanne.net/2010/07/20/g2android-1-5-0-is-available-major-release/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 13:09:29 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=368</guid>
		<description><![CDATA[Finally !
During a long period of calm, I finally rele [...]]]></description>
			<content:encoded><![CDATA[<p>Finally !<br />
During a long period of calm, I finally released a new version (with new features) of the Android client for remote galleries Gallery2 (your photos on your website), G2Android.<br />
If you have a look at the <a href="http://code.google.com/p/g2android/"> G2Android project homepage</a>, you will see that the following issues (bug and enhancements) have been closed :<br />
Version 1.5.0, 19th of July 2010 Major release</p>
<ul>
<li>issue #33  Enable uploaded photo title modification</li>
<li>issue #41  Malformed Gallery 2 URL leads to G2Android forced close</li>
<li>issue #37  Uploaded photo looses .jpg file extension</li>
<li>issue #42  Feature Suggestion: Provide automatic login when started</li>
<li> issue #20  Share via camera app?</li>
<li>issue #15  Enhancement: Add multiple photo uploading </li>
</ul>
<p>The major new feature is clearly the &laquo;&nbsp;add photo to gallery&nbsp;&raquo; feature : I created a new Activity, <a href="http://code.google.com/p/g2android/source/browse/trunk/g2android/src/net/dahanne/android/g2android/activity/UploadPhoto.java">UploadPhoto</a> , which can be called from 2 external intents : </p>
<p><a href="http://code.google.com/p/g2android/source/browse/trunk/g2android/AndroidManifest.xml">AndroidManifest.xml </a></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;activity</span> <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;.activity.UploadPhoto&quot;</span> <span style="color: #000066;">android:label</span>=<span style="color: #ff0000;">&quot;@string/upload_photo_title&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;intent</span> -filter<span style="color: #000000; font-weight: bold;">&gt;</span></span>
                                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;android.intent.action.SEND&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;android.intent.action.SEND_MULTIPLE&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;category</span> <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;android.intent.category.DEFAULT&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;data</span> <span style="color: #000066;">android:mimeType</span>=<span style="color: #ff0000;">&quot;image/*&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/intent<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/activity<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>So now the user can send a new photo or a batch of photos from another application, the android gallery app for example; the big work was then to decode the URIs of the photos to find the photo file on the phone, and then send it to the gallery; also I had to make sure that the user is still connected to the gallery, if not, he must login again.</p>
<p>Also, the user is now able to take a picture and send it to his gallery, without leaving g2android; this has been done adding the camera permission in the <a href="http://code.google.com/p/g2android/source/browse/trunk/g2android/AndroidManifest.xml">AndroidManifest.xml </a>:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;uses</span> -permission <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;android.permission.CAMERA&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/uses<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>This is the easy part <img src='http://blog.dahanne.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
Then, when your app receive a photo from the Camera, it does not receive an URI pointing to a photo file; nope, you get a Bitmap  object you have transform into a file, to be able to send it to the remote gallery : </p>
<p><a href="http://code.google.com/p/g2android/source/browse/trunk/g2android/src/net/dahanne/android/g2android/activity/UploadPhoto.java">UploadPhoto</a></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">                                                Bundle extras <span style="color: #339933;">=</span> intent.<span style="color: #006633;">getExtras</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                Bitmap bm <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
                                                <span style="color: #003399;">Object</span> o <span style="color: #339933;">=</span> extras.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;data&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>o <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> o <span style="color: #000000; font-weight: bold;">instanceof</span> Bitmap<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                                                        bm <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Bitmap<span style="color: #009900;">&#41;</span> o<span style="color: #339933;">;</span>
                                                        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                                                                StringBuilder stringBuilder <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> StringBuilder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                stringBuilder.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>Settings
                                                                                .<span style="color: #006633;">getG2AndroidPath</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                stringBuilder.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                StringBuilder stringBuilderFileName <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> StringBuilder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                stringBuilderFileName.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>fileName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                stringBuilderFileName
                                                                                .<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                stringBuilderFileName.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                stringBuilder.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>stringBuilderFileName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                imageFromCamera <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>
                                                                                stringBuilder.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                <span style="color: #003399;">FileOutputStream</span> fos <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">FileOutputStream</span><span style="color: #009900;">&#40;</span>
                                                                                imageFromCamera<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                bm.<span style="color: #006633;">compress</span><span style="color: #009900;">&#40;</span>CompressFormat.<span style="color: #006633;">JPEG</span>, <span style="color: #cc66cc;">100</span>, fos<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                fos.<span style="color: #006633;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                fos.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                                                                mImageUri<span style="color: #339933;">=</span>Uri.<span style="color: #006633;">fromFile</span><span style="color: #009900;">&#40;</span>imageFromCamera<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                fileName <span style="color: #339933;">=</span> stringBuilderFileName.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                                                        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">FileNotFoundException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                                                                ShowUtils.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">alertFileProblem</span><span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,<span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                                                                ShowUtils.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">alertFileProblem</span><span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,<span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                        <span style="color: #009900;">&#125;</span>
&nbsp;
                                                <span style="color: #009900;">&#125;</span></pre></div></div>

<p>I also optimized the application, issue #37 (Uploaded photo looses .jpg file extension) was in fact due to the fact that I re created the photo file before sending it; instead of using a projection of the URI to get its path on the phone :</p>
<p><a href="http://code.google.com/p/g2android/source/browse/trunk/g2android/src/net/dahanne/android/g2android/utils/UriUtils.java">UriUtils</a></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> getFileNameFromUri<span style="color: #009900;">&#40;</span>Uri uri, Activity activity<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> projection <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> MediaStore.<span style="color: #006633;">Images</span>.<span style="color: #006633;">ImageColumns</span>.<span style="color: #006633;">DISPLAY_NAME</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
                <span style="color: #003399;">String</span> fileName<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
                <span style="color: #003399;">Cursor</span> c <span style="color: #339933;">=</span> activity.<span style="color: #006633;">managedQuery</span><span style="color: #009900;">&#40;</span>uri, projection, <span style="color: #000066; font-weight: bold;">null</span>, <span style="color: #000066; font-weight: bold;">null</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> c.<span style="color: #006633;">moveToFirst</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        fileName <span style="color: #339933;">=</span> c.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #000000; font-weight: bold;">return</span> fileName<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Also shipping with this new version, <a href="http://goapk.com">Chinese i18n thanks to the chinese android market, GoAPK</a> and also new art from <a href="http://www.gdl3d.com/">Dan</a>, who just posted a comment to the blog proposing to add new art; thanks again to you both ! You make the application richer !</p>
<p>So now, what remains to be done ? well, the compatibility with Gallery3, as the G3 remote API is almost stable now, thanks to the work of Bharat, Tim, and many others; a java implementation is already under work, I will check if I can use it instead of&#8230; re inventing the wheel !<br />
More details to come, for sure !</p>
<p>You can download G2Android from the Android Market, SlideMe, Applibs, etc.. and also from the <a href="http://code.google.com/p/g2android/"> G2Android project homepage</a><br />
.<br />
Enjoy this app as much as I enjoy working on it, and if you like it, don&#8217;t forget to flattr me <img src='http://blog.dahanne.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2010/07/20/g2android-1-5-0-is-available-major-release/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>G2Android v. 1.4.2 : now it is really stable !</title>
		<link>http://blog.dahanne.net/2009/12/23/g2android-v-1-4-2-now-it-is-really-stable/</link>
		<comments>http://blog.dahanne.net/2009/12/23/g2android-v-1-4-2-now-it-is-really-stable/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 23:46:54 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=337</guid>
		<description><![CDATA[Sorry, no new features in this release :-(
But a lot o [...]]]></description>
			<content:encoded><![CDATA[<p>Sorry, no new features in this release <img src='http://blog.dahanne.net/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /><br />
But a lot of bug fixes <img src='http://blog.dahanne.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
These bugs specially appeared in CyanogenMod running Android phones, because, for some reason, CyanogenMod kills really rapidly applications loosing focus.<br />
For example, when trying to upload a photo, Android, under Cyanogenmod, would kill G2Android, as it lost focus, for letting the user choose his photo; or if you received a phone call while browsing a gallery, Android would also kill G2Android.<br />
That&#8217;s ok, it&#8217;s part of the Android lifecycle : this robot knows how to get his RAM back  !!!<br />
The thing is, until version 1.4.2, G2Android would not &laquo;&nbsp;remember&nbsp;&raquo; the Gallery cookies, the albums hierarchy, its position in the gallery, etc&#8230; so it forced close.<br />
Now, it uses a SQLite database, to save its context, so before leaving an activity, G2Android saves its context (onPause) and when entering an activity (onResume) it gets the context back.<br />
Next year, some new features will appear, like using the camera directly to send photo, or maybe analyse EXIF metadata ?<br />
If you have some ideas, or if you encounter bugs, <a href="http://code.google.com/p/g2android/issues/list">please feel free to submit an issue in G2Android bugtracker</a> !<br />
And, as we say in such periods, merry Xmas and happy new year ! Using G2Android <img src='http://blog.dahanne.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<h3><a href="http://code.google.com/p/g2android/">Go to G2Android project page</a></h3>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/12/23/g2android-v-1-4-2-now-it-is-really-stable/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>G2Android version 1.3.0 : cache and full screen navigation</title>
		<link>http://blog.dahanne.net/2009/10/27/g2android-version-1-3-0-cache-and-full-screen-navigatio/</link>
		<comments>http://blog.dahanne.net/2009/10/27/g2android-version-1-3-0-cache-and-full-screen-navigatio/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 15:22:35 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=267</guid>
		<description><![CDATA[Here is the new stable release of G2Android, your favor [...]]]></description>
			<content:encoded><![CDATA[<p>Here is the new stable release of<a href="http://code.google.com/p/g2android/"> G2Android, your favorite Gallery2 application for Android</a>, and great new features are now available :</p>
<ul>
<li>new cache feature </li>
<li>fullscreen navigation with gestures </li>
<li>download full res. picture to sdcard</li>
</ul>
<p>As always, you can get more info going to the project web page : <a href="http://code.google.com/p/g2android/">http://code.google.com/p/g2android/</a>, and <a href="http://code.google.com/p/g2android/downloads/list">even download the new version</a><br />
So what&#8217;s next ? tweeting and sending email with photo url, shortcuts for full screen navigation, synchronization between views&#8230; well, expect a new version by the end of November !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/10/27/g2android-version-1-3-0-cache-and-full-screen-navigatio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>G2Android version 1.2.1 : bug fixes</title>
		<link>http://blog.dahanne.net/2009/10/15/g2android-version-1-2-1-bug-fixes/</link>
		<comments>http://blog.dahanne.net/2009/10/15/g2android-version-1-2-1-bug-fixes/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 20:51:09 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=262</guid>
		<description><![CDATA[You can now download the last G2Android update, version [...]]]></description>
			<content:encoded><![CDATA[<p>You can now download the last <a title="G2Android download page" href="http://code.google.com/p/g2android/downloads/list">G2Android update, version 1.2.1</a>.<br />
What&#8217;s new ?</p>
<ul>
<li> No more automatic connection at startup, the user has to push a button to connect to the gallery</li>
</ul>
<ul>
<li> Galleries with port different than 80 now work</li>
</ul>
<ul>
<li> I18n : the app now provide new languages, today only <a title="G2Android english strings file" href="http://code.google.com/p/g2android/source/browse/trunk/g2android/res/values/strings.xml">english</a> and <a title="G2Android french strings file" href="http://code.google.com/p/g2android/source/browse/trunk/g2android/res/values-fr/strings.xml">french</a> are supported, I&#8217;m expecting the community to provide new translations</li>
</ul>
<p>That&#8217;s all folks, expect better UIs and possibility to download pictures from the gallery to the phone soon.<br />
Have fun browsing your galleries !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/10/15/g2android-version-1-2-1-bug-fixes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>G2Android version 1.2.0 : photos upload and albums creation !</title>
		<link>http://blog.dahanne.net/2009/08/29/g2android-version-1-2-0-photos-upload-and-albums-creation/</link>
		<comments>http://blog.dahanne.net/2009/08/29/g2android-version-1-2-0-photos-upload-and-albums-creation/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 01:33:12 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=241</guid>
		<description><![CDATA[I'm writing this small post just to indicate that the n [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m writing this small post just to indicate that the new version of the open source <a href="http://gallery2.menalto.com">Gallery2</a> client for the android platform, <a href="http://code.google.com/p/g2android/">G2Android</a>, is out !</p>
<p>Now, you can still see your albums and pictures, but you can also :</p>
<ul>
<li>upload photos</li>
<li>create new albums</li>
</ul>
<p>The ergonomy is not yet perfect, as you may have already noticed, even though almost everything is multi threaded (using AsyncTask), meaning the ui won&#8217;t freeze anymore; the next features will probably will allow the user to insert a photo to his gallery from every picture context on the android platform (declaring a &laquo;&nbsp;share image&nbsp;&raquo; intent)</p>
<p>Stay tuned !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/08/29/g2android-version-1-2-0-photos-upload-and-albums-creation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>G2Android : a gallery2 client for the android platform</title>
		<link>http://blog.dahanne.net/2009/08/16/g2android-a-gallery2-client-for-the-android-platform/</link>
		<comments>http://blog.dahanne.net/2009/08/16/g2android-a-gallery2-client-for-the-android-platform/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 14:58:31 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=225</guid>
		<description><![CDATA[I recently started a new open source project : G2Androi [...]]]></description>
			<content:encoded><![CDATA[<p>I recently started a new open source project : <a title="G2android : a gallery2 client for Android" href="http://code.google.com/p/g2android">G2Android</a>, for the android platform, and mainly for 3 reasons :</p>
<ul>
<li>The main reason I Started this project was because there isn&#8217;t yet any <a title="Gallery2 project page" href="http://gallery2.menalto.com" target="_blank">gallery2</a> clients for the android platform and I needed one to access my galleries where I share photos with my family and friends</li>
</ul>
<p>Gallery2 is an open source project to easily share your photos with your friends and family : you can install it on Php/MySql enabled server : be it a shared server or dedicates server; Gallery2 is maybe the most popular project in this category ! (I know, Picasa and FlickR exist but&#8230; I&#8217;m not the kind of guy to upload 7 Gb of photos to companies I don&#8217;t know and I don&#8217;t trust&#8230;)</p>
<p>Well, there&#8217;s a client for uploading photos to a gallery2, picpush, but it&#8217;s not open source and it&#8217;s loaded with ads&#8230; And you can&#8217;t browse photos&#8230;</p>
<ul>
<li>I wanted to start a new Android project, to know better this platform !</li>
<li>Iwanted to compete on the <a title="ADC" href="http://code.google.com/android/adc/" target="_blank">ADC (Android Developer Challenge) 2009</a> : given the current features, I&#8217;m not sure I have a chance to win the competition, but, hey, the important is to particpate as we isay !</li>
</ul>
<p>As of version 1.0, G2Android can browse albums and pictures, for more details, you can check out the <a title="G2Android Features" href="http://code.google.com/p/g2android/wiki/SupportedFeatures" target="_blank">Features page of G2Android</a></p>
<p>Version 1.1, which will be out soon, will allow you to browse private galleries, ie gallery2 installations which need a password.</p>
<p>The project is open source, GPL v.2, so you want to join in, feel free to contact me !</p>
<p>Finally, you can download G2Android from the Android Market : just type &laquo;&nbsp;G2Android&nbsp;&raquo; in your search or <a title="G2Android on the Android market" href="market://search?q=pname:net.dahanne.android.g2android">simply click on this link if you&#8217;re browsing this page with an Android device</a> .</p>
<p>You can also <a title="Download G2Android" href="http://code.google.com/p/g2android/downloads/list" target="_blank">download it directly from the G2Android Google code site.</a></p>
<p>Have fun with it, and feel free to <a title="G2Android bug tracker" href="http://code.google.com/p/g2android/issues/list" target="_blank">submit new issues on the bugtracker</a> if you encounter a bug !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/08/16/g2android-a-gallery2-client-for-the-android-platform/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Different ways to access HTTP resources from Android</title>
		<link>http://blog.dahanne.net/2009/08/16/how-to-access-http-resources-from-android/</link>
		<comments>http://blog.dahanne.net/2009/08/16/how-to-access-http-resources-from-android/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 14:35:05 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=227</guid>
		<description><![CDATA[In this article, I invite the reader to discover the di [...]]]></description>
			<content:encoded><![CDATA[<p>In this article, I invite the reader to discover the different methods to access http resources from the Android platform.<br />
These methods can be adapted to access web services (using REST) or simply to download files !</p>
<h3>First Method : getting an input stream given a simple url from Android using HttpURLConnection</h3>
<p>This method is the most basic one : it allows you, using the basic HttpUrlConnection, ( contained in java.net) to get an InputStream from an Url :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">InputStream</span> downloadUrl<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> url<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">HttpURLConnection</span> con <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">URL</span> url<span style="color: #339933;">;</span>
		<span style="color: #003399;">InputStream</span> is<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			url <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">URL</span><span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			con <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">HttpURLConnection</span><span style="color: #009900;">&#41;</span> url.<span style="color: #006633;">openConnection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			con.<span style="color: #006633;">setReadTimeout</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10000</span> <span style="color: #666666; font-style: italic;">/* milliseconds */</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			con.<span style="color: #006633;">setConnectTimeout</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">15000</span> <span style="color: #666666; font-style: italic;">/* milliseconds */</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			con.<span style="color: #006633;">setRequestMethod</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;GET&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			con.<span style="color: #006633;">setDoInput</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			con.<span style="color: #006633;">addRequestProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Referer&quot;</span>, <span style="color: #0000ff;">&quot;http://blog.dahanne.net&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">// Start the query</span>
			con.<span style="color: #006633;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			is <span style="color: #339933;">=</span> con.<span style="color: #006633;">getInputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #666666; font-style: italic;">//handle the exception !</span>
			e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">return</span> is<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>You can also use the Post method, sending data in the HTTP POST payload :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">InputStream</span> downloadUrl<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> url<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003399;">InputStream</span> myInputStream <span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		StringBuilder sb <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> StringBuilder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">//adding some data to send along with the request to the server</span>
		sb.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;name=Anthony&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">URL</span> url<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			url <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">URL</span><span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">HttpURLConnection</span> conn <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">HttpURLConnection</span><span style="color: #009900;">&#41;</span> url.<span style="color: #006633;">openConnection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			conn.<span style="color: #006633;">setDoOutput</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			conn.<span style="color: #006633;">setRequestMethod</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;POST&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">OutputStreamWriter</span> wr <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">OutputStreamWriter</span><span style="color: #009900;">&#40;</span>conn
					.<span style="color: #006633;">getOutputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #666666; font-style: italic;">// this is were we're adding post data to the request</span>
                        wr.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>sb.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			wr.<span style="color: #006633;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			myInputStream <span style="color: #339933;">=</span> conn.<span style="color: #006633;">getInputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			wr.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #666666; font-style: italic;">//handle the exception !</span>
			Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
                <span style="color: #000000; font-weight: bold;">return</span> myInputStream<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>But there are better ways to achieve that, using Apache HttpClient, included in android.jar (no need to add another jar, it&#8217;s included in android core)</p>
<h3>Second Method : getting an input stream given a simple url from Android using HttpClient</h3>
<p>Why is it a better to do it ? because the simpler, the better ! See by yourself :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">InputStream</span> getInputStreamFromUrl<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> url<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">InputStream</span> content <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			HttpGet httpGet <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpGet<span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			HttpClient httpclient <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DefaultHttpClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">// Execute HTTP Get Request</span>
			HttpResponse response <span style="color: #339933;">=</span> httpclient.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>httpGet<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			content <span style="color: #339933;">=</span> response.<span style="color: #006633;">getEntity</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getContent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">//handle the exception !</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">return</span> content<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>But you maybe wondering if it&#8217;s still easy with HTTP Post method ? You won&#8217;t be deceived !</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">InputStream</span> getInputStreamFromUrl<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> url<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">InputStream</span> content <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
          		HttpClient httpclient <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DefaultHttpClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			HttpPost httpPost <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpPost<span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">List</span> nameValuePairs <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ArrayList</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #666666; font-style: italic;">//this is where you add your data to the post method</span>
                        nameValuePairs.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> BasicNameValuePair<span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">&quot;name&quot;</span>, <span style="color: #0000ff;">&quot;anthony&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			httpPost.<span style="color: #006633;">setEntity</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> UrlEncodedFormEntity<span style="color: #009900;">&#40;</span>nameValuePairs<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">// Execute HTTP Post Request</span>
			HttpResponse response <span style="color: #339933;">=</span> httpclient.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>httpPost<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			content <span style="color: #339933;">=</span> response.<span style="color: #006633;">getEntity</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getContent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		        <span style="color: #000000; font-weight: bold;">return</span> content<span style="color: #339933;">;</span>
	        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>But what if you want to read a cookie from the response ? And how can you send a cookie back to the server for the next request ?</p>
<h3>Reading / Sending a cookie along with the requests</h3>
<p>Using Apache HttpClient, it&#8217;s easy to retrieve cookies ! Everything is in the headers after all !</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #009900;">&#91;</span>...<span style="color: #009900;">&#93;</span>
Cookie sessionCookie <span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
HttpResponse response <span style="color: #339933;">=</span> httpclient.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>httpPost<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Header<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> allHeaders <span style="color: #339933;">=</span> response.<span style="color: #006633;">getAllHeaders</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
CookieOrigin origin <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> CookieOrigin<span style="color: #009900;">&#40;</span>host, port,path, <span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>Header header <span style="color: #339933;">:</span> allHeaders<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">List</span> parse <span style="color: #339933;">=</span> cookieSpecBase.<span style="color: #006633;">parse</span><span style="color: #009900;">&#40;</span>header, origin<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>Cookie cookie <span style="color: #339933;">:</span> parse<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">// THE cookie</span>
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>cookie.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>COOKIE_I_WAS_LOOKING_FOR<span style="color: #009900;">&#41;</span>
						<span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> cookie.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> cookie.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					sessionCookie <span style="color: #339933;">=</span> cookie<span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>To send a cookie along with your request, keep it simple :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">HttpPost httpPost <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpPost<span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
CookieSpecBase cookieSpecBase <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> BrowserCompatSpec<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">List</span> cookies <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ArrayList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
cookies.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>sessionCookie<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">List</span> cookieHeader <span style="color: #339933;">=</span> cookieSpecBase.<span style="color: #006633;">formatCookies</span><span style="color: #009900;">&#40;</span>cookies<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Setting the cookie</span>
httpPost.<span style="color: #006633;">setHeader</span><span style="color: #009900;">&#40;</span>cookieHeader.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>What about the resulting InputStream ? You definitely want to transform it into a String or an Drawable (to set it to an ImageView for example !) don&#8217;t you ?</p>
<h3>Converting the InputStream into a Drawable in Android</h3>
<p>The Drawable class already handles that for you :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">Drawable d <span style="color: #339933;">=</span> Drawable.<span style="color: #006633;">createFromStream</span><span style="color: #009900;">&#40;</span>myInputStream, <span style="color: #0000ff;">&quot;nameOfMyResource&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Converting the InputStream into a String in Android</h3>
<p>This is some classic java stuff (don&#8217;t tell about how easier it is in Ruby.. I know <img src='http://blog.dahanne.net/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' />  &#8230; but hey ! Java SE7 at the rescue with NIO !!! maybe one day in 2010 ! )</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">BufferedReader</span> rd <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">InputStreamReader</span><span style="color: #009900;">&#40;</span>myInputStreamToReadIntoAString<span style="color: #009900;">&#41;</span>, <span style="color: #cc66cc;">4096</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> line<span style="color: #339933;">;</span>
StringBuilder sb <span style="color: #339933;">=</span>  <span style="color: #000000; font-weight: bold;">new</span> StringBuilder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>line <span style="color: #339933;">=</span> rd.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		sb.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>line<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
rd.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> contentOfMyInputStream <span style="color: #339933;">=</span> sb.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
&nbsp;
That<span style="color: #0000ff;">'s it folks ! If you have any other methods to achieve these goals, feel free to share them sending a comment !</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/08/16/how-to-access-http-resources-from-android/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Jazoon 09 : third and last day, Thursday 25th of June</title>
		<link>http://blog.dahanne.net/2009/06/25/jazoon-09-third-and-last-day-thursday-25th-of-june/</link>
		<comments>http://blog.dahanne.net/2009/06/25/jazoon-09-third-and-last-day-thursday-25th-of-june/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 20:35:15 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jazoon 09]]></category>
		<category><![CDATA[meeting]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=170</guid>
		<description><![CDATA[Vous pouvez lire cet article en français sur le blog d [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.valtech.fr/wordpress/2009/06/25/jazoon-3eme-et-dernier-jour-jeudi-25-juin/">Vous pouvez lire cet article en français sur le blog de valtech.</a></p>
<h3>The Changing Nature of Enterprise Java Application Development, 9:00 &#8211; 9:45 by Adrian Colyer</h3>
<p>During his talk, the speaker described the audience the future of a Java platform, because it is actually going to be there for a long time now.<br />
He mentioned the dynamic languages compatible with the JVM : Groovy, JRuby, Scala, and Clojure.<br />
He mainly focused on Groovy (which belongs to SpringSource by the way), even if he was not sure if whether JRuby or Groovy would win the &laquo;&nbsp;war of dynamic languages&nbsp;&raquo;.<br />
For the web platform, he mentioned Grails, built on top of Groovy, Rails running on top of Ruby, and Lift built on top of Scala.<br />
He finished his talk introducing OSGi and Spring DM; the future of enterpise is application may be in the cloud : easily to deploy and scale applications are to come.</p>
<h3>The android runtime environment, 10:30 &#8211; 11:20, by Joerg Pleumann</h3>
<p>The speaker first made an introduction to the Android system, as a platform competing windows mobile and palm.<br />
More technically speaking, it is based on a Linux kernel (along with necessary drivers : display, camera, sound, etc&#8230;).<br />
On top of it come the Android Runtime and libraries; the talk is about the Android Runtime and its Dalvik VM.<br />
Dalvik VM : CPU between 250 and 500 MHz, RAM >=64 (equivalent to a 1999 PC), but low power consumption is critical.<br />
The Dalvik VM is really efficient, using explicit registers to keep temporary values: the immediate benefit is the number of lines of the bytecode resulting from the DalvikVM compilation : nearly 30% less than a standard VM compilation.<br />
A dex file (Dalvik Executable) contains several files, and is not compressed.<br />
JNI is ready, a sdk for using JNI is about to come out in the next days; also an Android Debug Bridge is available from the beginning.<br />
The core libraries<br />
dalvik vm specific libraries : dalvik.*<br />
java compatibility libraries : java.* and javax.*<br />
and some apache libraries(mainly for http) : org.apache.*<br />
The core libraries are partly taken from Apache Harmony (a JDK implementation by Apache), partly written from scratch; and some of them have been optimized (using JNI)<br />
The core libraries are mostly compatible to a subset of J2SE 5.0.<br />
JDBC 2.0 is supported, but the SQLite driver is limited., but one can use the alternative in android.database.sqlite which are better integrated.<br />
To conclude with, with Android you can reuse your java knowledge and tools.</p>
<h3>Android Application Model, 11:30 &#8211; 12:20, by Dominik Gruntz</h3>
<p>4 main components :activities, services, content providers and broadcast receivers.<br />
A single class, uses intents to communicate with the other activities; when you launch an activity, you can (or not) expect a result; if this is the case, the method onIntentResult will be called.<br />
You can also define intent filters to describe the intents an activity can handle.<br />
An intent specification is on its way : http://www.openintents.org<br />
An application is packaged using an APK (Android package).<br />
Every activity has a lifecycle containing 4 steps : new, running, paused,  stopped, killed and the corresponding methods (onCreate, onStop etc..)<br />
For each activity a new process (with a single thread) is created.<br />
The Looper.loop() dispathes the actions to a queue.<br />
If an activity does not conume events in 5sec, the system issue a warning message.<br />
A service is running background and can communicate with an activity (in process if it&#8217;s the same application (APK)) or via AIDL.<br />
Finally, a content provider is the only way to share date between  Android applications; it can using SQLite, a file, or a remote storage. </p>
<h3>Scalable Agile Web Development: REST meets JCR meets OSGI, by Michael Marth</h3>
<p>JCR : JSR 270 for accessing content repository : located on a file or database; can be versioned; node ahave read/write group properties, etc&#8230;<br />
Apache Sling is a web framework, on top of REST/Scripting (Ruby, Groovy, etc&#8230;)/OSGi(in this case Apache Felix Container, to switch on/off part of the frameework live)/JCR.<br />
So basically Apache Sling allows the user to create/edit/read/update content in a restful manner (http methods), the data being created is then stored on the JCR repository, organized in a very similar WebUrlFriendly way (and then you can manipulate the data through rest or webdav and so on, thanks to JCR)<br />
The demo was really smooth and interesting !</p>
<h3>The charm of Mockito: Test Spies in action, 14:30 &#8211; 15:20, by Szczepan Faber</h3>
<p>The speaker begins asking who uses JMock : 2 or 3 people among an audience of 60 people, half of the audience using EasyMock.<br />
So let&#8217;s start with EasyMock : coding in TDD a dictionnary, (and its history) depending on a translator : the translator is mocked.<br />
With easymock the speaker keeps it old fadhioned : createMock/expect/replay/assert/verify , (his test extends Assert) and then refactor a bit in the @Before and @After test methods, nothing special here.<br />
Then Mockito : mock/when/assert/verify : it&#8217;s a lighter syntax indeeed!<br />
Szczepan insisted on the fact that usually developers using easymock create replayAll and verifyAll methods called in the @After method; which make Easymok fail when many behaviours are attached.<br />
The speaker uses BDD style template (given/when/then) in eclipse, when creating a test.<br />
Mockito eases the use of a given/when/then syntax when writing a test.<br />
Has good point of failure ?<br />
The failure trace in mockito is linked to the source code and more explicit about the error, it does not whow internal classes exceptions<br />
Mockito or mockito-like for python, flex, javascript, C++; there are mockito extensions<br />
He concluded with : &laquo;&nbsp;Do TDD and write great tests with whatever tools that work for you&nbsp;&raquo;<br />
May the force be with you !</p>
<h3>Eclipse Galileo and JBoss Tools, 16:30 &#8211; 16:50, by Max Andersen</h3>
<p>Galileo (3.5) is a huge release.<br />
Must-sees : Eclipse Memory Analyser (to see which plugin consumes all the memory for example), using jmap<br />
XML and XSL editor is really better.<br />
P2 (eclipse update manager) works for real; you shouldn&#8217;t use dropins anymore (single zip files to unpackage in /plugins and /features), for offline installation plugins providers should suggest copies of the update site, then you may use P2 to explore these files, as if you were online).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/06/25/jazoon-09-third-and-last-day-thursday-25th-of-june/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jazoon 09, second day : 24th of June 2009</title>
		<link>http://blog.dahanne.net/2009/06/24/jazoon-09-second-day-24th-of-june-2009/</link>
		<comments>http://blog.dahanne.net/2009/06/24/jazoon-09-second-day-24th-of-june-2009/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 16:34:57 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[jazoon 09]]></category>
		<category><![CDATA[meeting]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=167</guid>
		<description><![CDATA[The following sessions were given during Jazoon 09, on  [...]]]></description>
			<content:encoded><![CDATA[<p>The following sessions were given during Jazoon 09, on Wednesdaythe 24th of Ju ne 2009, <a href="http://blog.valtech.fr/wordpress/2009/06/24/jazoon-09-sessions-du-mercredi-24-juin/">vous pouvez lire la traduction en français sur le blog de Valtech</a></p>
<h3>Danny Coward Keynote, 9:00 &#8211; 10:00</h3>
<h4>Java 7</h4>
<p>Description of the new features in Java SE 7  : modularity, ?. operator, new API for java.io (Path, Asynchronous FileVisitor), http://openjdk.java.net/projects/jdk7</p>
<h4>Java FX</h4>
<p>The new version is 1.2, running on all OSes (even Linux and Solaris, a TV, some phones to come out), more UI components (skinnable with CSS) , new layouts, better performance; then Danny showed the audience some JavaFX applications : a pacman application, a video player, with some nice visual effects &#8230; </p>
<h3>OSGi and Java Modularity, 10:30 &#8211; 11:20, by Peter Kriens</h3>
<p>If you think your application is modular only by using the VM, well, think again&#8230;<br />
You can&#8217;t hide interfaces in the classsloader, and if there are no enforcements of rules at runtime, it&#8217;s uselesse to try to make these interfaces secrets&#8230;<br />
In OSGi, you can set secret interfaces (not exported) and also use MANIFESTs to explicitely specify exports.<br />
With an OSGi bundle (a jar actually, with its MANIFEST), you can dynamically specify which others bundles it can depend on, if one of the bundle you depend on is no more available, OSGi will remove the dependency; then it will put it back when the bundle is available again.<br />
The problem is : many implementations of modularity exist and JSR 294 do not specify a particular one &#8230; From a programmer point of view, you will have to choose between OSGi, Jigsaw, guice, the modularity implementation you want to use &#8230; </p>
<h3>Next generation Wikis: Mixing Content-Oriented Applications with Wikis, 11:30 &#8211; 12:20, by Vincent Massol</h3>
<p>Wiki 1.0 : just used for text<br />
Wiki 2.0 : you can add everything : images, videos, comments, notes, etc.., the datas can be structured, unstructured or mashups (datas coming from everywhere) the wiki 2.0 is the excell&#8230; of the web !<br />
After presenting a demo showing us the possibility in Xwiki to define in 10 minutes (knowing velocity or groovy syntax) an application hosted on the wiki, Vincent listed the Xwiki features and the new features to come : real time collaboration, mobile skin, social features and &#8230; merge of CMS and wikis.</p>
<h3>JavaFX Rich Internet Applications connected to GlassFish Java EE 5 services, 16:00-16:20, by Ludovic Champenois – Sun Microsystems</h3>
<p>First of all, Ludovic showed us the GlassFish v3 admin console (looks good !) and reminded us with REST (standard HTTP methods, resources, etc&#8230;), and the REST annotations in Java EE6.<br />
Why ? because the example given during his demonstration is communicating with a JAX-RS Java EE6 application, hosted by Glassfish V3.<br />
To test the REST application, you can simply use  : curl -HAccept:application/xml http://localhost/domain, or use your browser or use Glassfish v3 Admin Backend Tester.<br />
And then, down to the JavaFx application code, using Netbeans, only 15 lines of code are necessary to consume the REST service.<br />
TO finish with, Ludovic showed us some other JavaFX demo applications.</p>
<h3>JavaFX / Android: Competing technologies or the ideal partnership? , 16:30 &#8211; 16:50 by Mike Mannion and Andreas Hölzl</h3>
<p>Presented as a theater play : 2 guys talking about phone technologies around a coffee : one is a JavaFX supporter, the other is an Android supporter.<br />
They then compared a similar application (using Flickr, Lastfm, youtube web services): developed both for JavaFx and the Android Platform.<br />
*UI : JavaFX needs UI designed by designers, Android defines it in an extermal layout XML file<br />
*UI (2) : Android provides a richer API, providing a photo gallery for example, JavaFX does not&#8230;<br />
*language : you have to learn JavaFX script for JavaFX, Android uses Java 5 API (with some restrictions&#8230;, for example it does not use AWT or Swing for graphics)<br />
They also told us that Sun is not clearly decided about supporting Android  : they said that they were thinking about it&#8230; but since then (a year ago) nothing came out !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/06/24/jazoon-09-second-day-24th-of-june-2009/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Soumission du projet WikiPlacesAndroid pour le concours SFR JTD</title>
		<link>http://blog.dahanne.net/2009/04/26/soumission-du-projet-wikiplacesandroid-pour-le-concours-sfr-jtd/</link>
		<comments>http://blog.dahanne.net/2009/04/26/soumission-du-projet-wikiplacesandroid-pour-le-concours-sfr-jtd/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 21:52:59 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=137</guid>
		<description><![CDATA[Cà y est, aujourd'hui, comme le veut la tradition des  [...]]]></description>
			<content:encoded><![CDATA[<p>Cà y est, aujourd&#8217;hui, comme le veut la tradition des deadlines, tout s&#8217;est mis à planter, à ne plus marcher dans l&#8217;application que j&#8217;ai développé conjointement avec Romain, pour le concours <a href="http://www.sfrjtd.fr/content/wikiplacesandroid">SFR JTD, WikiPlacesAndroid</a>.<br />
Faut dire que j&#8217;ai voulu rajouter plein de fonctionnalités (upload d&#8217;images, redimensionnement d&#8217;images sur le téléphone) et là, des catastrophes à répétition : memory leaks sur le téléphone android qui vit très mal le redimensionnement d&#8217;images de 2MegaPixels, l&#8217;appli serveur Rails qui elle vit très mal la lecture des blobs en base de données MySQL, bref, un %*$ de Dimanche, comme on s&#8217;en passerait bien.<br />
Enfin, j&#8217;ai posté l&#8217;application pour le concours, avec du coup moins de fonctionnalités que prévu, en tout cas elle fonctionne et bug (presque) plus.<br />
Vous avez un téléphone Android ? Essayez donc notre application, ci jointe à ce billet !<br />
\!/ le serveur de l&#8217;application correspondant étant offline, vous ne pourrez pas&#8230; faire grand chose avec l&#8217;appli <img src='http://blog.dahanne.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  !<br />
<a href="http://blog.dahanne.net/wp-content/uploads/wikiplacesandroid.apk">Télécharger WikiPlacesAndroid</a> (développée avec le SDK 1.1)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/04/26/soumission-du-projet-wikiplacesandroid-pour-le-concours-sfr-jtd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jazoon 09 : le programme officiel de la conférence</title>
		<link>http://blog.dahanne.net/2009/04/05/jazoon-09-le-programme-officiel-de-la-conference/</link>
		<comments>http://blog.dahanne.net/2009/04/05/jazoon-09-le-programme-officiel-de-la-conference/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 13:25:28 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[agile]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jazoon 09]]></category>
		<category><![CDATA[meeting]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=127</guid>
		<description><![CDATA[çà y est, il est en ligne !
Vous pouvez jeter un cou [...]]]></description>
			<content:encoded><![CDATA[<p>çà y est, il est en ligne !<br />
Vous pouvez jeter un coup d&#8217;oeil au programme de Jazoon 2009 (qui aura lieu fin Juin) en cliquant sur ce lien :<br />
<a href="http://jazoon.com/en/conference/schedule.html">http://jazoon.com/en/conference/schedule.html</a><br />
Je commence à élaborer mon planning pour cette semaine (bien que j&#8217;ai énormément de mal à faire mon choix, beaucoup de sujets sont très intéressants)</p>
<ul>
<li>Lundi (si j&#8217;y suis):  Glassfish</li>
<li>Mardi : Java EE6, groovy, Spring 3.0, GWT, iphone, maven , mobile java</li>
<li>Mercredi : hudson, securing ajax,jsf 2,mule, android</li>
<li>Jeudi : android, rest, mockito, openjdk</li>
</ul>
<p>çà va être épuisant je sens !<br />
Trop hâte d&#8217;y être !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/04/05/jazoon-09-le-programme-officiel-de-la-conference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Premiere application android déployée sur mon HTC Dream (G1)</title>
		<link>http://blog.dahanne.net/2009/03/22/premiere-application-android-deployee-sur-mon-htc-dream-g1/</link>
		<comments>http://blog.dahanne.net/2009/03/22/premiere-application-android-deployee-sur-mon-htc-dream-g1/#comments</comments>
		<pubDate>Sun, 22 Mar 2009 16:02:04 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=120</guid>
		<description><![CDATA[Depuis le temps que je l'attendais !
Sorti le jour de  [...]]]></description>
			<content:encoded><![CDATA[<p>Depuis le temps que je l&#8217;attendais !<br />
Sorti le jour de mon anniversaire (12 Mars) chez Orange France, le HTC Dream (ou G1) est motorisé par l&#8217;OS open source Android, démarré par Google il y a presque 3 ans.<br />
Et oui, il y a désormais une alternative aux mondes cloisonnés sur portable comme Iphone ou Windows Mobile, une alternative aussi aux limitations de J2ME : Android est arrivé !</p>
<h3>Ecriture de ma première application Android</h3>
<h4>Ce qu&#8217;il faut sur le poste de développement : </h4>
<p>De retour de vacances, je me dirige sur http://developer.android.com/sdk/1.1_r1/installing.html où je découvre que dans eclipse je peux installer le plugin de développement ADT, qui, une fois connectée au SDK installée sur ma machine (sous windows pour commencer <img src='http://blog.dahanne.net/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' />  ) me permet d&#8217;intéragir plus facilement avec ce SDK.<br />
En résumé il vous faut :</p>
<ul>
<li>Eclipse 3.4 avec une JRE 6</li>
<li>Le plugin ADT téléchargé via le &laquo;&nbsp;Software updates&nbsp;&raquo; d&#8217;Eclipse</li>
<li>Le SDK Android</li>
</ul>
<h4>Ecriture du Hello Android : première application Android</h4>
<p>Google fournit un tutorial très bien fait qui permet de se familiariser avec le concept d&#8217;activité et de création de vues via des fichiers XML (çà me rappelle une mission çà &#8230;), à l&#8217;adresse : http://developer.android.com/guide/tutorials/hello-world.html<br />
Oups !  quand on (contrôle) clique sur du code Android (comme Activity.class par exemple), on se rend compte que les source sne sont pas fournies ! Plutôt dur à digérer quand on a l&#8217;habitude d&#8217;avoir les sources des frameworks que l&#8217;on utilise et que l&#8217;on sait qu&#8217;Android est un produit Open Source ! Heureusement, <a href="http://code.google.com/p/android/issues/detail?id=979">le &laquo;&nbsp;bug&nbsp;&raquo; est signalé</a> et en supprimant la librairie Android (android.jar) dans le projet Eclipse et en la ré important en précisant le chemin du code source  (<a href="http://drupalmodules.com/sources.zip ">téléchargeable ici</a>), on a accès au code source du framework !<br />
On lance un &laquo;&nbsp;Run&nbsp;&raquo; et on a le plaisir de voir l&#8217;application se lancer dans l&#8217;émulateur d&#8217;Android !</p>
<h4>Déploiement de l&#8217;application Android sur le HTC Dream</h4>
<p>Il faut tout d&#8217;abord <a href="http://dl.google.com/android/android_usb_windows.zip">télécharger et installer les drivers USB sur votre poste de développement</a>.<br />
Pour installer les pilotes, dézippez les dans le répertoire de votre choix, et connectez en USB votre téléphone (en ayant pris soin au préalable de le mettre en mode Debug USB dans Parametres -> Applications -> Développement); Windows va détecter votre téléphone et vous demandez d&#8217;installer les pilotes.<br />
On y est presque !<br />
Il n&#8217;y a plus qu&#8217;à déployer l&#8217;application, pour cela, retournez dans Eclipse, dans votre &laquo;&nbsp;Run Configuration&#8230;&nbsp;&raquo; qui lance votre application Android dans l&#8217;émulateur, sélectionner dans &laquo;&nbsp;Target&nbsp;&raquo; Selection &laquo;&nbsp;Manual&nbsp;&raquo;, cliquez sur &laquo;&nbsp;Run&nbsp;&raquo; un dialogue apparaît, sélectionnez votre téléphone, et regardez votre application se lancer sur votre téléphone portable toujours connecté en USB bien sûr !<br />
Maintenant, laissez place à votre imagination et codez !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/03/22/premiere-application-android-deployee-sur-mon-htc-dream-g1/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
