<?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>Java &#8211; Wiebe Elsinga</title>
	<atom:link href="http://wiebe-elsinga.com/blog/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://wiebe-elsinga.com/blog</link>
	<description>Blog</description>
	<lastBuildDate>Fri, 21 Oct 2011 04:20:40 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.8.1</generator>
	<item>
		<title>How-To: Android Client – Server designs</title>
		<link>http://wiebe-elsinga.com/blog/android-client-%e2%80%93-server-designs/</link>
					<comments>http://wiebe-elsinga.com/blog/android-client-%e2%80%93-server-designs/#comments</comments>
		
		<dc:creator><![CDATA[W.Elsinga]]></dc:creator>
		<pubDate>Fri, 08 Oct 2010 06:15:18 +0000</pubDate>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Servlet]]></category>
		<category><![CDATA[SOAP]]></category>
		<guid isPermaLink="false">http://wiebe-elsinga.com/blog/?p=405</guid>

					<description><![CDATA[Applications are usually designed so that a Server provides a service to a Client. Choosing an implementation depends on the requirements. Inside this article I will be explaining three implementation types: SOAP Servlet JSON I will use the Android application which was developed inside my previous post. SOAP Simple Object Access Protocol is basically designed to provide a lightweight mechanism to exchange data in a XML format. Setting up a SOAP web service isn’t al that difficult. There is a disadvantage of using SOAP, and that’s overhead. Because there is no default SOAP support inside the Android library, I will be using kSOAP. So lets set-up an implementation. Create a server implementation &#160; &#160; &#160;public class Hello &#123; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; public String sayHello&#40;String name&#41; &#123; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;return &#34;Hello &#34; + name; &#160; &#160; &#160; &#160; &#160; &#125; &#160; &#160; &#160;&#125; Create an Android implementation Create a call to the server &#160; &#160; &#160;private void callService&#40;SoapSerializationEnvelope envelope&#41; &#123; &#160; &#160; &#160; &#160; &#160; HttpTransportSE androidHttpTransport = new HttpTransportSE&#40;URL&#41;; &#160; &#160; &#160; &#160; &#160; // Call the URL &#160; &#160; &#160; &#160; &#160; try &#123; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;androidHttpTransport.call&#40;SOAP_ACTION, envelope&#41;; &#160; &#160; &#160; &#160; &#160; &#125; catch &#40;IOException e&#41; &#123; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;display&#40;&#34;Error:&#34; + e.getClass&#40;&#41;.getName&#40;&#41; + &#34;: &#34; + e.getMessage&#40;&#41;&#41;; &#160; &#160; &#160; &#160; &#160; &#125; catch &#40;XmlPullParserException e&#41; &#123; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;display&#40;&#34;Error:&#34; + e.getClass&#40;&#41;.getName&#40;&#41; + &#34;: &#34; + e.getMessage&#40;&#41;&#41;; &#160; &#160; &#160; &#160; &#160; &#125; &#160; &#160; &#160;&#125; Handle the response &#160; &#160; &#160;private SoapPrimitive getResultFromService&#40;String text&#41; &#123; &#160; &#160; &#160; &#160; &#160; SoapObject request = new SoapObject&#40;NAMESPACE, METHOD_NAME&#41;; &#160; &#160; &#160; &#160; &#160; SoapSerializationEnvelope envelope = new SoapSerializationEnvelope&#40;SoapEnvelope.VER11&#41;; &#160; &#160; &#160; &#160; &#160; request.addProperty&#40;&#34;name&#34;, text&#41;; &#160; &#160; &#160; &#160; &#160; envelope.setOutputSoapObject&#40;request&#41;; &#160; &#160; &#160; &#160; &#160; callService&#40;envelope&#41;; &#160; &#160; &#160; &#160; &#160; SoapPrimitive result = null; &#160; &#160; &#160; &#160; &#160; try &#123; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;result = &#40;SoapPrimitive&#41; envelope.getResponse&#40;&#41;; &#160; &#160; &#160; &#160; &#160; &#125; catch &#40;SoapFault e&#41; &#123; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;display&#40;&#34;Error:&#34; + e.getClass&#40;&#41;.getName&#40;&#41; + &#34;: &#34; + e.getMessage&#40;&#41;&#41;; &#160; &#160; &#160; &#160; &#160; &#125; &#160; &#160; &#160; &#160; &#160; return result; &#160; &#160; &#160;&#125; Download source code BackEndWSDL [5kB] and FrondEndWSDL [114kB] Servlet The most simple form of exchanging data is by way of HTTP(s) with the use of Java Servlets. There’s no need to serialize to/from XML, so it can be a real time saver. So lets set-up an implementation. Create a server implementation &#160; &#160; &#160;protected void doPost&#40;HttpServletRequest request, HttpServletResponse response&#41; throws ServletException, IOException &#123; &#160; &#160; &#160; &#160; &#160; String text = &#34;&#34;; &#160; &#160; &#160; &#160; &#160; StringBuffer sb = new StringBuffer&#40;&#41;; &#160; &#160; &#160; &#160; &#160; try &#123; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;BufferedReader reader = new BufferedReader&#40;new InputStreamReader&#40;request.getInputStream&#40;&#41;&#41;&#41;; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;String line = reader.readLine&#40;&#41;; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;while &#40;line != null&#41; &#123; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; sb.append&#40;line&#41;; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; line = reader.readLine&#40;&#41;; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;&#125; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;if &#40;sb.length&#40;&#41; != 0&#41; &#123; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; text = sb.toString&#40;&#41;; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;&#125; &#160; &#160; &#160; &#160; &#160; &#125; catch &#40;Exception e&#41; &#123; &#160; &#160; &#160; &#160; &#160; &#125; &#160; &#160; &#160; &#160; &#160; response.setContentType&#40;&#34;text/plain&#34;&#41;; &#160; &#160; &#160; &#160; &#160; response.setHeader&#40;&#34;Cache-Control&#34;, &#34;no-cache&#34;&#41;; &#160; &#160; &#160; &#160; &#160; if &#40;StringUtils.isNotEmpty&#40;text&#41;&#41; &#123; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;response.getWriter&#40;&#41;.write&#40;HELLO_STRING + text&#41;; &#160; &#160; &#160; &#160; &#160; &#125; else &#123; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;response.getWriter&#40;&#41;.write&#40;HELLO_STRING&#41;; &#160; &#160; &#160; &#160; &#160; &#125; &#160; &#160; &#160;&#125; Create an Android implementation Create a call to the server &#160; &#160; &#160;private InputStream callService&#40;String text&#41; &#123; &#160; &#160; &#160; &#160; &#160; InputStream in = null; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; try &#123; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;URL url = new URL&#40;SERVLET_URL&#41;; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;URLConnection conn = url.openConnection&#40;&#41;; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;HttpURLConnection httpConn = &#40;HttpURLConnection&#41; conn; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;httpConn.setRequestMethod&#40;&#34;POST&#34;&#41;; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;httpConn.setDoInput&#40;true&#41;; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;httpConn.setDoOutput&#40;true&#41;; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;httpConn.connect&#40;&#41;; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;DataOutputStream dataStream = new DataOutputStream&#40;conn.getOutputStream&#40;&#41;&#41;; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;dataStream.writeBytes&#40;text&#41;; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;dataStream.flush&#40;&#41;; &#160; &#160; &#160; &#160; &#160; &#160; dataStream.close&#40;&#41;; &#160; &#160; &#160; &#160; &#160; &#160; int responseCode = httpConn.getResponseCode&#40;&#41;; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;if &#40;responseCode == HttpURLConnection.HTTP_OK&#41; &#123; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; in = httpConn.getInputStream&#40;&#41;; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;&#125; &#160; &#160; &#160; &#160; &#160; &#125; catch &#40;Exception ex&#41; &#123; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;display&#40;&#34;Error: Not not connect&#34;&#41;; &#160; &#160; &#160; &#160; &#160; &#125; &#160; &#160; &#160; &#160; &#160; return in; &#160; &#160; &#160;&#125; Handle the response &#160; &#160; &#160;private String getResultFromServlet&#40;String text&#41; &#123; &#160; &#160; &#160; &#160; &#160; String result = &#34;&#34;; &#160; &#160; &#160; &#160; &#160; InputStream in = callService&#40;text&#41;; &#160; &#160; &#160; &#160; &#160; if&#40;in!=null&#41; &#123; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;result= convertStreamToString&#40;in&#41;; &#160; &#160; &#160; &#160; &#160; &#125; else &#123; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;result = &#34;Error: Service not returning result&#34;; &#160; &#160; &#160; &#160; &#160; &#125; &#160; &#160; &#160; &#160; &#160; return result; &#160; &#160; &#160;&#125; &#160; &#160; &#160;private static String convertStreamToString&#40;InputStream is&#41; &#123; &#160; &#160; &#160; &#160; &#160; BufferedReader reader = new BufferedReader&#40;new InputStreamReader&#40;is&#41;&#41;; &#160; &#160; &#160; &#160; &#160; StringBuilder sb = new StringBuilder&#40;&#41;; &#160; &#160; [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a href="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android.jpg" rel="lightbox[405]" title="android"><img loading="lazy" class="alignleft size-thumbnail wp-image-170" style="padding-right: 10px;" title="android" src="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android-150x150.jpg" alt="" width="150" height="150" srcset="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android-150x150.jpg 150w, http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android-300x300.jpg 300w, http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android-200x200-cropped.jpg 200w, http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android.jpg 500w" sizes="(max-width: 150px) 100vw, 150px" /></a></p>
<p>Applications are usually designed so that a Server provides a service to a Client. Choosing an implementation depends on the requirements.  Inside this article I will be explaining three implementation types:</p>
<ul>
<li>SOAP</li>
<li>Servlet</li>
<li>JSON</li>
</ul>
<p>I will use the Android application which was developed inside my <a href="http://wiebe-elsinga.com/blog/?p=275">previous post</a>.<br />
<span id="more-405"></span></p>
<h2>SOAP</h2>
<p><b>S</b>imple <b>O</b>bject <b>A</b>ccess <b>P</b>rotocol is basically designed to provide a lightweight mechanism to exchange data in a <i>XML</i> format. Setting up a SOAP web service isn’t al that difficult. There is a disadvantage of using SOAP, and that’s overhead. Because there is no default SOAP support inside the Android library, I will be using <a href="http://ksoap2.sourceforge.net/">kSOAP</a>.<br />
<br />
So lets set-up an implementation.</p>
<ol>
<li>Create a server implementation</li>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Hello <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> sayHello<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> name<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;Hello &quot;</span> <span style="color: #339933;">+</span> name<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span></div></div>
<li>Create an Android implementation</li>
<li>Create a call to the server</li>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> callService<span style="color: #009900;">&#40;</span>SoapSerializationEnvelope envelope<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HttpTransportSE androidHttpTransport <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpTransportSE<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+url"><span style="color: #003399;">URL</span></a><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Call the URL</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;androidHttpTransport.<span style="color: #006633;">call</span><span style="color: #009900;">&#40;</span>SOAP_ACTION, envelope<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+ioexception"><span style="color: #003399;">IOException</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;display<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Error:&quot;</span> <span style="color: #339933;">+</span> e.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getName</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: #339933;">+</span> 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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>XmlPullParserException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;display<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Error:&quot;</span> <span style="color: #339933;">+</span> e.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getName</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: #339933;">+</span> 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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span></div></div>
<li>Handle the response</li>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">private</span> SoapPrimitive getResultFromService<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> text<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SoapObject request <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SoapObject<span style="color: #009900;">&#40;</span>NAMESPACE, METHOD_NAME<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SoapSerializationEnvelope envelope <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SoapSerializationEnvelope<span style="color: #009900;">&#40;</span>SoapEnvelope.<span style="color: #006633;">VER11</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; request.<span style="color: #006633;">addProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;name&quot;</span>, text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; envelope.<span style="color: #006633;">setOutputSoapObject</span><span style="color: #009900;">&#40;</span>request<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; callService<span style="color: #009900;">&#40;</span>envelope<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SoapPrimitive result <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>SoapPrimitive<span style="color: #009900;">&#41;</span> envelope.<span style="color: #006633;">getResponse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>SoapFault e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;display<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Error:&quot;</span> <span style="color: #339933;">+</span> e.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getName</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: #339933;">+</span> 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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> result<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span></div></div>
</ol>
<p>Download source code <a href='http://wiebe-elsinga.com/blog/wp-content/uploads/2010/10/BackEndWSDL.zip'>BackEndWSDL</a> [5kB] and <a href='http://wiebe-elsinga.com/blog/wp-content/uploads/2010/10/FrondEndWSDL.zip'>FrondEndWSDL</a> [114kB] </p>
<h2>Servlet</h2>
<p>The most simple form of exchanging data is by way of HTTP(s) with the use of Java Servlets. There’s no need to serialize to/from <i>XML</i>, so it can be a real time saver.</p>
<p>So lets set-up an implementation.</p>
<ol>
<li>Create a server implementation</li>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:100%;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> doPost<span style="color: #009900;">&#40;</span>HttpServletRequest request, HttpServletResponse response<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ServletException, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+ioexception"><span style="color: #003399;">IOException</span></a> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> text <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+stringbuffer"><span style="color: #003399;">StringBuffer</span></a> sb <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+stringbuffer"><span style="color: #003399;">StringBuffer</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+bufferedreader"><span style="color: #003399;">BufferedReader</span></a> reader <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+bufferedreader"><span style="color: #003399;">BufferedReader</span></a><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+inputstreamreader"><span style="color: #003399;">InputStreamReader</span></a><span style="color: #009900;">&#40;</span>request.<span style="color: #006633;">getInputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> line <span style="color: #339933;">=</span> reader.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>line <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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; line <span style="color: #339933;">=</span> reader.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>sb.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text <span style="color: #339933;">=</span> sb.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+exception"><span style="color: #003399;">Exception</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;text/plain&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Cache-Control&quot;</span>, <span style="color: #0000ff;">&quot;no-cache&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>StringUtils.<span style="color: #006633;">isNotEmpty</span><span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>HELLO_STRING <span style="color: #339933;">+</span> text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>HELLO_STRING<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span></div></div>
<li>Create an Android implementation</li>
<li>Create a call to the server</li>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:100%;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+inputstream"><span style="color: #003399;">InputStream</span></a> callService<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> text<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+inputstream"><span style="color: #003399;">InputStream</span></a> in <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+url"><span style="color: #003399;">URL</span></a> url <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+url"><span style="color: #003399;">URL</span></a><span style="color: #009900;">&#40;</span>SERVLET_URL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+urlconnection"><span style="color: #003399;">URLConnection</span></a> conn <span style="color: #339933;">=</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><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+httpurlconnection"><span style="color: #003399;">HttpURLConnection</span></a> httpConn <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+httpurlconnection"><span style="color: #003399;">HttpURLConnection</span></a><span style="color: #009900;">&#41;</span> conn<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;httpConn.<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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;httpConn.<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> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;httpConn.<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> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;httpConn.<span style="color: #006633;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+dataoutputstream"><span style="color: #003399;">DataOutputStream</span></a> dataStream <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+dataoutputstream"><span style="color: #003399;">DataOutputStream</span></a><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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dataStream.<span style="color: #006633;">writeBytes</span><span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dataStream.<span style="color: #006633;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dataStream.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> responseCode <span style="color: #339933;">=</span> httpConn.<span style="color: #006633;">getResponseCode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>responseCode <span style="color: #339933;">==</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+httpurlconnection"><span style="color: #003399;">HttpURLConnection</span></a>.<span style="color: #006633;">HTTP_OK</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; in <span style="color: #339933;">=</span> httpConn.<span style="color: #006633;">getInputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+exception"><span style="color: #003399;">Exception</span></a> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;display<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Error: Not not connect&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> in<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span></div></div>
<li>Handle the response</li>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> getResultFromServlet<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> text<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> result <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+inputstream"><span style="color: #003399;">InputStream</span></a> in <span style="color: #339933;">=</span> callService<span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>in<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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result<span style="color: #339933;">=</span> convertStreamToString<span style="color: #009900;">&#40;</span>in<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Error: Service not returning result&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> result<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span></div></div>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> convertStreamToString<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+inputstream"><span style="color: #003399;">InputStream</span></a> is<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+bufferedreader"><span style="color: #003399;">BufferedReader</span></a> reader <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+bufferedreader"><span style="color: #003399;">BufferedReader</span></a><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+inputstreamreader"><span style="color: #003399;">InputStreamReader</span></a><span style="color: #009900;">&#40;</span>is<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 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><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> line <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<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> reader.<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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>line <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+ioexception"><span style="color: #003399;">IOException</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">finally</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; is.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+ioexception"><span style="color: #003399;">IOException</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> sb.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span></div></div>
</ol>
<p>Download source code <a href='http://wiebe-elsinga.com/blog/wp-content/uploads/2010/10/BackEndServlet.zip'>BackEndServlet</a> [242kB] and <a href='http://wiebe-elsinga.com/blog/wp-content/uploads/2010/10/FrondEndServlet.zip'>FrondEndServlet</a> [16kB] </p>
<h2>JSON</h2>
<p>So SOAP has the advantage of using a model, and HTTP(s) has the advantage of being simple. There is an implementation that uses both. <b>J</b>ava<b>S</b>cript <b>O</b>bject <b>N</b>otation is a light-weight data-interchange format, think of it as XML on a diet</p>
<p>So lets set-up an implementation.</p>
<ol>
<li>Create a server implementation</li>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:100%;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> doPost<span style="color: #009900;">&#40;</span>HttpServletRequest request, HttpServletResponse response<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ServletException, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+ioexception"><span style="color: #003399;">IOException</span></a> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> text <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+stringbuffer"><span style="color: #003399;">StringBuffer</span></a> sb <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+stringbuffer"><span style="color: #003399;">StringBuffer</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+bufferedreader"><span style="color: #003399;">BufferedReader</span></a> reader <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+bufferedreader"><span style="color: #003399;">BufferedReader</span></a><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+inputstreamreader"><span style="color: #003399;">InputStreamReader</span></a><span style="color: #009900;">&#40;</span>request.<span style="color: #006633;">getInputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> line <span style="color: #339933;">=</span> reader.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>line <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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; line <span style="color: #339933;">=</span> reader.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>sb.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text <span style="color: #339933;">=</span> sb.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+exception"><span style="color: #003399;">Exception</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+system"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;text/plain&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Cache-Control&quot;</span>, <span style="color: #0000ff;">&quot;no-cache&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JsonObject jsonObj<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> JsonObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>StringUtils.<span style="color: #006633;">isNotEmpty</span><span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;jsonObj.<span style="color: #006633;">addProperty</span><span style="color: #009900;">&#40;</span>JSON_KEY, HELLO_STRING <span style="color: #339933;">+</span> text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;jsonObj.<span style="color: #006633;">addProperty</span><span style="color: #009900;">&#40;</span>JSON_KEY, HELLO_STRING<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+printwriter"><span style="color: #003399;">PrintWriter</span></a> out <span style="color: #339933;">=</span> response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>jsonObj<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span></div></div>
<li>Create an Android implementation</li>
<li>Create a call to the server</li>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:100%;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+inputstream"><span style="color: #003399;">InputStream</span></a> callService<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> text<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+inputstream"><span style="color: #003399;">InputStream</span></a> in <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+url"><span style="color: #003399;">URL</span></a> url <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+url"><span style="color: #003399;">URL</span></a><span style="color: #009900;">&#40;</span>SERVLET_URL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+urlconnection"><span style="color: #003399;">URLConnection</span></a> conn <span style="color: #339933;">=</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><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+httpurlconnection"><span style="color: #003399;">HttpURLConnection</span></a> httpConn <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+httpurlconnection"><span style="color: #003399;">HttpURLConnection</span></a><span style="color: #009900;">&#41;</span> conn<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;httpConn.<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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;httpConn.<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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;httpConn.<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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;httpConn.<span style="color: #006633;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+dataoutputstream"><span style="color: #003399;">DataOutputStream</span></a> dataStream <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+dataoutputstream"><span style="color: #003399;">DataOutputStream</span></a><span style="color: #009900;">&#40;</span>conn<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.<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><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dataStream.<span style="color: #006633;">writeBytes</span><span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dataStream.<span style="color: #006633;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dataStream.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">int</span> responseCode <span style="color: #339933;">=</span> httpConn.<span style="color: #006633;">getResponseCode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>responseCode <span style="color: #339933;">==</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+httpurlconnection"><span style="color: #003399;">HttpURLConnection</span></a>.<span style="color: #006633;">HTTP_OK</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; in <span style="color: #339933;">=</span> httpConn.<span style="color: #006633;">getInputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+exception"><span style="color: #003399;">Exception</span></a> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;display<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Error: Not not connect&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> in<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span></div></div>
<li>Handle the response</li>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> getResultFromServlet<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> text<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> result <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+inputstream"><span style="color: #003399;">InputStream</span></a> in <span style="color: #339933;">=</span> callService<span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>in <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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;JSONObject jsonResponse<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jsonResponse <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONObject<span style="color: #009900;">&#40;</span>convertStreamToString<span style="color: #009900;">&#40;</span>in<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result <span style="color: #339933;">=</span> jsonResponse.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;output&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>JSONException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Error: JSON Object couldn't be made&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Error: Service not returning result&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> result<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span></div></div>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> convertStreamToString<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+inputstream"><span style="color: #003399;">InputStream</span></a> is<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+bufferedreader"><span style="color: #003399;">BufferedReader</span></a> reader <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+bufferedreader"><span style="color: #003399;">BufferedReader</span></a><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+inputstreamreader"><span style="color: #003399;">InputStreamReader</span></a><span style="color: #009900;">&#40;</span>is<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 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><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> line <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<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> reader.<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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>line <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+ioexception"><span style="color: #003399;">IOException</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">finally</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; is.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+ioexception"><span style="color: #003399;">IOException</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> sb.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span></div></div>
</ol>
<p>Download source code <a href='http://wiebe-elsinga.com/blog/wp-content/uploads/2010/10/BackEndJSON.zip'>BackEndJSON</a> [399kB] and <a href='http://wiebe-elsinga.com/blog/wp-content/uploads/2010/10/FrondEndJSON.zip'>FrondEndJSON</a> [15kB] </p>
]]></content:encoded>
					
					<wfw:commentRss>http://wiebe-elsinga.com/blog/android-client-%e2%80%93-server-designs/feed/</wfw:commentRss>
			<slash:comments>13</slash:comments>
		
		
			</item>
		<item>
		<title>How-To: Automatic testing for Android Applications</title>
		<link>http://wiebe-elsinga.com/blog/automatic-testing-for-android-applications/</link>
					<comments>http://wiebe-elsinga.com/blog/automatic-testing-for-android-applications/#comments</comments>
		
		<dc:creator><![CDATA[W.Elsinga]]></dc:creator>
		<pubDate>Tue, 03 Aug 2010 03:30:50 +0000</pubDate>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Robotium]]></category>
		<category><![CDATA[Selenium]]></category>
		<guid isPermaLink="false">http://wiebe-elsinga.com/blog/?p=300</guid>

					<description><![CDATA[After setting up your Android development environment, and Developing an Android Application it’s time to set-up a automatic Android Test environment. The steps to achieve this are: Choose a test technique. Creating a test project. Make the test. Run the test. I will use the Android application which was developed inside my previous post. [Update 15-03-2011] Updated to Android 2.3.3. [Update 15-03-2011] Updated to Robotium 2.2. Choose a test technique There are different techniques you can use to test Android applications. The most commonly known is by way of JUnit. JUnit is used to test the technical quality of applications. But what about the testing the functional use of a application, like you would do it with Selenium for web application. For Android applications there is a similar tool for testing called Robotium. It is a UI testing tool which simulates touching, clicks, typing, and other users&#8217; actions relevant for Android applications. In this example I will be using Robotium. Creating a test project From within Eclipse select File menu, New and Other. Choose Android Test Project inside the Android folder. Provide the information about the Android Test project and click Next. Press Finish. You should see the following directory structure Because I will be creating a Robotium test, I must provide the robotium-solo-2.2.jar as library. Make the test From within Eclipse select File menu, New and JUnit Test Case. Provide the information about the Junit Test Case and click Finish. Change MainTest.java to the following package com.my; import java.util.ArrayList; import com.jayway.android.robotium.solo.Solo; import android.app.Activity; import android.test.ActivityInstrumentationTestCase2; import android.widget.TextView; public class MainTest extends ActivityInstrumentationTestCase2 &#123; private Solo solo; private Activity activity; public MainTest&#40;&#41; &#123; super&#40;&#34;com.my&#34;, Main.class&#41;; &#125; @Override protected void setUp&#40;&#41; throws Exception &#123; super.setUp&#40;&#41;; this.activity = this.getActivity&#40;&#41;; this.solo = new Solo&#40;getInstrumentation&#40;&#41;, this.activity&#41;; &#125; @Override public void tearDown&#40;&#41; throws Exception &#123; try &#123; this.solo.finalize&#40;&#41;; &#125; catch &#40;Throwable e&#41; &#123; e.printStackTrace&#40;&#41;; &#125; this.activity.finish&#40;&#41;; super.tearDown&#40;&#41;; &#125; /** * @throws Exception Exception */ public void testDisplay&#40;&#41; throws Exception &#123; String text = &#34;Congratulations&#34;; //Enter &#34;Congratulations&#34; inside the EditText field. this.solo.enterText&#40;&#40;EditText&#41; this.activity.findViewById&#40;R.id.EditText01&#41;, text&#41;; //Click on the button named &#34;Click&#34;. this.solo.clickOnButton&#40;&#34;Click&#34;&#41;; //Check to see if the given text is displayed. assertTrue&#40;this.solo.searchText&#40;text&#41;&#41;; TextView outputField = &#40;TextView&#41; this.activity.findViewById&#40;R.id.TextView01&#41;; ArrayList currentTextViews = this.solo.getCurrentTextViews&#40;outputField&#41;; assertFalse&#40;currentTextViews.isEmpty&#40;&#41;&#41;; TextView output = currentTextViews.get&#40;0&#41;; assertEquals&#40;text, output.getText&#40;&#41;.toString&#40;&#41;&#41;; &#125; &#125; Run the test Al that is left is running the test. Right click MyAndroidAppTestProject. Select Android Junit Test within the Run-As option. Be patient, the emulator starts up very slow. You should get the following result Appendix Download source code Android.zip [16kB] and AndroidTest.zip [16kB]]]></description>
										<content:encoded><![CDATA[<p>After setting up your <a href="http://wiebe-elsinga.com/blog/?p=259">Android development environment</a>, and <a href="http://wiebe-elsinga.com/blog/?p=275">Developing an Android Application</a> it’s time to set-up a automatic Android Test environment. The steps to achieve this are:</p>
<ul>
<li>Choose a test technique.</li>
<li>Creating a test project.</li>
<li>Make the test.</li>
<li>Run the test.</li>
</ul>
<p>I will use the Android application which was developed inside my <a href="http://wiebe-elsinga.com/blog/?p=275">previous post</a>.</p>
<p><strong>[Update 15-03-2011]</strong> Updated to Android 2.3.3.<br />
<strong>[Update 15-03-2011]</strong> Updated to Robotium 2.2.<br />
<span id="more-300"></span></p>
<h2>Choose a test technique</h2>
<p>There are different techniques you can use to test Android applications. The most commonly known is by way of JUnit. JUnit is used to test the technical quality of applications. But what about the testing the functional use of  a application, like you would do it with Selenium for web application. For Android applications there is a similar tool for testing called <a href="http://code.google.com/p/robotium/">Robotium</a>. It is a UI testing tool which simulates touching, clicks, typing, and other users&#8217; actions relevant for Android applications. In this example I will be using <a href="http://code.google.com/p/robotium/">Robotium</a>.</p>
<h2>Creating a test project<a href="http://wiebe-elsinga.com/blog/wp-content/uploads/2011/03/testProject.gif" rel="lightbox[300]" title="testProject"><img loading="lazy" class="alignright size-thumbnail wp-image-301" title="testProject" src="http://wiebe-elsinga.com/blog/wp-content/uploads/2011/03/testProject-150x150.gif" alt="" width="150" height="150" /></a></h2>
<ol>
<li>From within Eclipse select <strong>File</strong> menu, <strong>New</strong> and <strong>Other</strong>.</li>
<li>Choose <strong>Android Test Project</strong> inside the <strong>Android</strong> folder.</li>
<li>Provide the information about the Android Test project and click <strong>Next</strong>.</li>
<li>Press <strong>Finish</strong>. You should see the following directory structure</li>
</ol>
<p><a href="http://wiebe-elsinga.com/blog/wp-content/uploads/2011/03/testFiles.gif" rel="lightbox[300]" title="testFiles"><img loading="lazy" class="alignnone size-thumbnail wp-image-302" title="testFiles" src="http://wiebe-elsinga.com/blog/wp-content/uploads/2011/03/testFiles-150x150.gif" alt="" width="150" height="150" /></a></p>
<p>Because I will be creating a Robotium test, I must provide the <a href="http://code.google.com/p/robotium/downloads/detail?name=robotium-solo-2.2.jar&amp;can=2&amp;q=">robotium-solo-2.2.jar</a> as library.</p>
<h2>Make the test<a href="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/08/TestCase.gif" rel="lightbox[300]" title="TestCase"><img loading="lazy" class="alignright size-thumbnail wp-image-304" title="TestCase" src="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/08/TestCase-150x150.gif" alt="" width="150" height="150" /></a></h2>
<ol>
<li>From within Eclipse select <strong>File</strong> menu, <strong>New</strong> and <strong>JUnit Test Case</strong>.</li>
<li>Provide the information about the Junit Test Case and click <strong>Finish</strong>.</li>
<li>Change <em>MainTest.java</em> to the following</li>
</ol>
<p></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:100%;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.my</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.jayway.android.robotium.solo.Solo</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.app.Activity</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.test.ActivityInstrumentationTestCase2</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.TextView</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MainTest <span style="color: #000000; font-weight: bold;">extends</span> ActivityInstrumentationTestCase2 <span style="color: #009900;">&#123;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">private</span> Solo solo<span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">private</span> Activity activity<span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">public</span> MainTest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;com.my&quot;</span>, Main.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
@Override<br />
<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> setUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+exception"><span style="color: #003399;">Exception</span></a> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">setUp</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">activity</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getActivity</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">solo</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Solo<span style="color: #009900;">&#40;</span>getInstrumentation<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">activity</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
@Override<br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> tearDown<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+exception"><span style="color: #003399;">Exception</span></a> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">solo</span>.<span style="color: #006633;">finalize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+throwable"><span style="color: #003399;">Throwable</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">activity</span>.<span style="color: #006633;">finish</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">tearDown</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
* @throws Exception Exception<br />
*/</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testDisplay<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+exception"><span style="color: #003399;">Exception</span></a> <span style="color: #009900;">&#123;</span><br />
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> text <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Congratulations&quot;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//Enter &quot;Congratulations&quot; inside the EditText field.</span><br />
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">solo</span>.<span style="color: #006633;">enterText</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>EditText<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">activity</span>.<span style="color: #006633;">findViewById</span><span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">EditText01</span><span style="color: #009900;">&#41;</span>, text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//Click on the button named &quot;Click&quot;.</span><br />
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">solo</span>.<span style="color: #006633;">clickOnButton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Click&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//Check to see if the given text is displayed.</span><br />
assertTrue<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">solo</span>.<span style="color: #006633;">searchText</span><span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
TextView outputField <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>TextView<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">activity</span>.<span style="color: #006633;">findViewById</span><span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">TextView01</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+arraylist"><span style="color: #003399;">ArrayList</span></a> currentTextViews <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">solo</span>.<span style="color: #006633;">getCurrentTextViews</span><span style="color: #009900;">&#40;</span>outputField<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
assertFalse<span style="color: #009900;">&#40;</span>currentTextViews.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
TextView output <span style="color: #339933;">=</span> currentTextViews.<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: #339933;">;</span><br />
assertEquals<span style="color: #009900;">&#40;</span>text, output.<span style="color: #006633;">getText</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<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><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #009900;">&#125;</span></div></div>
<h2>Run the test</h2>
<p>Al that is left is running the test.</p>
<ol>
<li>Right click <em>MyAndroidAppTestProject</em>.</li>
<li>Select <strong>Android Junit Test</strong> within the <strong>Run-As</strong> option.</li>
<li>Be patient, the emulator starts up very slow. You should get the following result</li>
</ol>
<p><a href="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/08/testResult.gif" rel="lightbox[300]" title="testResult"><img loading="lazy" class="alignnone size-full wp-image-306" title="testResult" src="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/08/testResult.gif" alt="" width="348" height="236" srcset="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/08/testResult.gif 348w, http://wiebe-elsinga.com/blog/wp-content/uploads/2010/08/testResult-300x203.gif 300w, http://wiebe-elsinga.com/blog/wp-content/uploads/2010/08/testResult-160x110.gif 160w" sizes="(max-width: 348px) 100vw, 348px" /></a></p>
<h2>Appendix</h2>
<p>Download source code <a href='http://wiebe-elsinga.com/blog/wp-content/uploads/2011/03/Android.zip'>Android.zip</a> [16kB] and <a href='http://wiebe-elsinga.com/blog/wp-content/uploads/2011/03/AndroidTest.zip'>AndroidTest.zip</a> [16kB] </p>
]]></content:encoded>
					
					<wfw:commentRss>http://wiebe-elsinga.com/blog/automatic-testing-for-android-applications/feed/</wfw:commentRss>
			<slash:comments>36</slash:comments>
		
		
			</item>
		<item>
		<title>How-To: Developing an Android Application</title>
		<link>http://wiebe-elsinga.com/blog/developing-a-android-application/</link>
					<comments>http://wiebe-elsinga.com/blog/developing-a-android-application/#comments</comments>
		
		<dc:creator><![CDATA[W.Elsinga]]></dc:creator>
		<pubDate>Mon, 02 Aug 2010 02:13:28 +0000</pubDate>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>
		<guid isPermaLink="false">http://wiebe-elsinga.com/blog/?p=275</guid>

					<description><![CDATA[After setting up your Android development environment, it’s time you implement your first (simple) Android application. The steps to achieve this are: Creating a project. Create your user interface. Code the application. Run the application. I will make an Android application which will provide a field where a user can type in a word and, after clicking on a button, will display that word. [Update 15-03-2011] Updated to Android 2.3.3. Creating a project Before creating a project, you have to decide what the version of your Android Platform your application will be running on. You can view the current most used Android Platform on http://developer.android.com/resources/dashboard/platform-versions.html. In this example I will be using Android 2.3.3. From within Eclipse select File menu, New and Android Project. Provide the information about the Android project and click Next. You can optional create a test project, which I will not do. Press Finish. You should see the following directory structure. So what do I see?. The project name is MyAndroidAppProject. It is displayed under the Package Explorer on the left of the window. src: This contains the .java source files for your project. In this example, there are two files: Main.java and R.java. The Main.java file is the source file for your activity. The R.java file is a compiler-generated file that references all the resources found in your project. You should not modify this file. Android Library: Contains all the class libraries needed for an Android application. res: Contains all the resources used in your application. It contains three other sub-folders: drawable, layout, and values. You will see the use of the files contained in each sub folders shortly. AndroidManifest.xml: Is the manifest file for your Android application. You will specify the permissions needed by your application as well as other features needed by your application (such as intent-filters, receivers, etc). Create your user interface The Andoid SDK allows two ways of building the user interface: via a rich editor and XML files. The XML method is preferred as it allows you to declaratively define the UI of an application without needing to write lots of code. In addition, it allows a clean separation of logic and UI. Double-click on main.xml located under the res/layout folder. Add three UI elements (EditText, Button and TextView). Select the EditText element and change the property Layout Width to fill_parent. Select the Button element and also change the property Layout Width to fill_parent. Select the TextView element and also change the property Layout Width to fill_parent. The main.xml should look as follows: &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;LinearLayout xmlns:android=&#34;http://schemas.android.com/apk/res/android&#34; android:orientation=&#34;vertical&#34; android:layout_width=&#34;fill_parent&#34; android:layout_height=&#34;fill_parent&#34; &#62; &#60;TextView android:layout_width=&#34;fill_parent&#34; android:layout_height=&#34;wrap_content&#34; android:text=&#34;@string/hello&#34; /&#62; &#60;EditText android:id=&#34;@+id/EditText01&#34; android:layout_height=&#34;wrap_content&#34; android:layout_width=&#34;fill_parent&#34; android:inputType=&#34;text&#34; /&#62; &#60;Button android:text=&#34;@+id/Button01&#34; android:id=&#34;@+id/Button01&#34; android:layout_height=&#34;wrap_content&#34; android:layout_width=&#34;fill_parent&#34; /&#62; &#60;TextView android:id=&#34;@+id/TextView01&#34; android:layout_height=&#34;wrap_content&#34; android:layout_width=&#34;fill_parent&#34; /&#62; &#60;/LinearLayout&#62; Notice that in the element, the value of the android:text attribute is @string/hello. @string refers to the strings.xml. Double-click on strings.xml located under the res/values folder. Change the file as follows: &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;resources&#62; &#60;string name=&#34;hello&#34;&#62;Welcome to My Android App&#60;/string&#62; &#60;string name=&#34;app_name&#34;&#62;MyAndroidApp&#60;/string&#62; &#60;string name=&#34;btntxt&#34;&#62;Click&#60;/string&#62; &#60;/resources&#62; Finally assign the btntxt string attribute to the button property of the main.xml. The main.xml should look as follows: &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;LinearLayout xmlns:android=&#34;http://schemas.android.com/apk/res/android&#34; android:orientation=&#34;vertical&#34; android:layout_width=&#34;fill_parent&#34; android:layout_height=&#34;fill_parent&#34; &#62; &#60;TextView android:layout_width=&#34;fill_parent&#34; android:layout_height=&#34;wrap_content&#34; android:text=&#34;@string/hello&#34; /&#62; &#60;EditText android:id=&#34;@+id/EditText01&#34; android:layout_height=&#34;wrap_content&#34; android:layout_width=&#34;fill_parent&#34; android:inputType=&#34;text&#34; /&#62; &#60;Button android:text=&#34;@string/btntxt&#34; android:id=&#34;@+id/Button01&#34; android:layout_height=&#34;wrap_content&#34; android:layout_width=&#34;fill_parent&#34; /&#62; &#60;TextView android:id=&#34;@+id/TextView01&#34; android:layout_height=&#34;wrap_content&#34; android:layout_width=&#34;fill_parent&#34; /&#62; &#60;/LinearLayout&#62; Code the application Change Main.java to the following: package com.my; import android.app.Activity; import android.os.Bundle; import android.text.Editable; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class Main extends Activity &#123; EditText input; TextView output; Button buttonClick; / ** Called when the activity is first created. */ @Override public void onCreate&#40;Bundle savedInstanceState&#41; &#123; super.onCreate&#40;savedInstanceState&#41;; setContentView&#40;R.layout.main&#41;; input = &#40;EditText&#41; findViewById&#40;R.id.EditText01&#41;; output = &#40;TextView&#41; findViewById&#40;R.id.TextView01&#41;; buttonClick = &#40;Button&#41; findViewById&#40;R.id.Button01&#41;; buttonClick.setOnClickListener&#40;new View.OnClickListener&#40;&#41; &#123; public void onClick&#40;View v&#41; &#123; display&#40;input.getText&#40;&#41;&#41;; &#125; &#125;&#41;; &#125; protected void display&#40;Editable text&#41; &#123; output.setText&#40;text&#41;; &#125; &#125; Run the application Al that is left is running the application. Right click MyAndroidAppProject. Select Android Application within the Run-As option. Be patient, the emulator starts up very slow. You should get the following result: Selecting MyAndroidApp. Enter some text and press on Click… Appendix Download source code Android.zip [16kB]]]></description>
										<content:encoded><![CDATA[<p><a href="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android.jpg" rel="lightbox[275]" title="android"><img loading="lazy" class="alignleft size-thumbnail wp-image-170" style="padding-right: 10px;" title="android" src="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android-150x150.jpg" alt="" width="150" height="150" srcset="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android-150x150.jpg 150w, http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android-300x300.jpg 300w, http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android-200x200-cropped.jpg 200w, http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android.jpg 500w" sizes="(max-width: 150px) 100vw, 150px" /></a>After setting up your <a href="http://wiebe-elsinga.com/blog/?p=259">Android development environment</a>, it’s time you implement your first (simple) Android application. The steps to achieve this are:</p>
<ul>
<li>Creating a project.</li>
<li>Create your user interface.</li>
<li>Code the application.</li>
<li>Run the application.</li>
</ul>
<p>I will make an Android application which will provide a field where a user can type in a word and, after clicking on a button, will display that word.</p>
<p><strong>[Update 15-03-2011]</strong> Updated to Android 2.3.3.</p>
<p><span id="more-275"></span></p>
<h2>Creating a project</h2>
<p>Before creating a project, you have to decide what the version of your Android Platform your application will be running on.  You can view the current most used Android Platform on <a href="http://developer.android.com/resources/dashboard/platform-versions.html">http://developer.android.com/resources/dashboard/platform-versions.html</a>. In this example I will be using Android 2.3.3.</p>
<ol>
<li>From within Eclipse select <strong>File</strong> menu, <strong>New</strong> and <strong>Android Project</strong>.<a href="http://wiebe-elsinga.com/blog/wp-content/uploads/2011/03/NewProject.gif" rel="lightbox[275]" title="NewProject"><img loading="lazy" class="alignright size-thumbnail wp-image-279" title="NewProject" src="http://wiebe-elsinga.com/blog/wp-content/uploads/2011/03/NewProject-150x150.gif" alt="" width="128" height="128" /></a></li>
<li>Provide the information about the Android project and click <strong>Next</strong>.</li>
<li>You can optional create a test project, which I will not do.</li>
<li>Press <strong>Finish</strong>. You should see the following directory structure.</li>
</ol>
<p><a href="http://wiebe-elsinga.com/blog/wp-content/uploads/2011/03/Structure.gif" rel="lightbox[275]" title="Structure"><img loading="lazy" class="size-thumbnail wp-image-280" title="Structure" src="http://wiebe-elsinga.com/blog/wp-content/uploads/2011/03/Structure-150x150.gif" alt="" width="191" height="191" /></a></p>
<p>So what do I see?. The project name is <em>MyAndroidAppProject</em>. It is displayed under the Package Explorer on the left of the window.</p>
<blockquote>
<ul>
<li><em>src</em>: This contains the .java source files for your project. In this example, there are two files: <em>Main.java</em> and <em>R.java</em>. The <em>Main.java</em> file is the source file for your activity. The <em>R.java</em> file is a compiler-generated file that references all the resources found in your project. You should not modify this file.</li>
<li><em>Android Library</em>: Contains all the class libraries needed for an Android application.</li>
<li><em>res</em>: Contains all the resources used in your application. It contains three other sub-folders: <em>drawable</em>, <em>layout</em>, and <em>values</em>. You will see the use of the files contained in each sub folders shortly.</li>
<li><em>AndroidManifest.xml</em>: Is the manifest file for your Android application. You will specify the permissions needed by your application as well as other features needed by your application (such as intent-filters, receivers, etc).</li>
</ul>
</blockquote>
<h2>Create your user interface</h2>
<p>The Andoid SDK allows two ways of building the user interface: via a rich editor and XML files. The XML method is preferred as it allows you to declaratively define the UI of an application without needing to write lots of code. In addition, it allows a clean separation of logic and UI.</p>
<ol>
<li>Double-click on <em>main.xml</em> located under the res/layout folder.</li>
<li>Add three UI elements (EditText, Button and TextView).</li>
<li>Select the EditText element and change the property <em>Layout Width</em> to <em>fill_parent</em>.</li>
<li>Select the Button element and also change the property <em>Layout Width</em> to <em>fill_parent</em>.</li>
<li>Select the TextView element and also change the property <em>Layout Width</em> to <em>fill_parent</em>.</li>
</ol>
<p>The <em>main.xml</em> should look as follows:</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:100%;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;LinearLayout</span> <span style="color: #000066;">xmlns:android</span>=<span style="color: #ff0000;">&quot;http://schemas.android.com/apk/res/android&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000066;">android:orientation</span>=<span style="color: #ff0000;">&quot;vertical&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextView</span></span><br />
<span style="color: #009900;"><span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000066;">android:text</span>=<span style="color: #ff0000;">&quot;@string/hello&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;EditText</span></span><br />
<span style="color: #009900;"><span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/EditText01&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000066;">android:inputType</span>=<span style="color: #ff0000;">&quot;text&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Button</span></span><br />
<span style="color: #009900;"><span style="color: #000066;">android:text</span>=<span style="color: #ff0000;">&quot;@+id/Button01&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/Button01&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextView</span></span><br />
<span style="color: #009900;"><span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/TextView01&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/LinearLayout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p>Notice that in the element, the value of the android:text attribute is @string/hello. @string refers to the <em>strings.xml</em>.</p>
<ol>
<li>Double-click on <em>strings.xml</em> located under the res/values folder.</li>
<li>Change the file as follows:</li>
</ol>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span><br />
<span style="color: #000000; font-weight: bold;">&lt;resources<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #000000; font-weight: bold;">&lt;string</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;hello&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>Welcome to My Android App<span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #000000; font-weight: bold;">&lt;string</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;app_name&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>MyAndroidApp<span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #000000; font-weight: bold;">&lt;string</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;btntxt&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>Click<span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #000000; font-weight: bold;">&lt;/resources<span style="color: #000000; font-weight: bold;">&gt;</span></span></div></div>
<p>Finally assign the btntxt string attribute to the button property of the <em>main.xml</em>. The <em>main.xml</em> should look as follows:</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:100%;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span><br />
<span style="color: #000000; font-weight: bold;">&lt;LinearLayout</span> <span style="color: #000066;">xmlns:android</span>=<span style="color: #ff0000;">&quot;http://schemas.android.com/apk/res/android&quot;</span><br />
<span style="color: #000066;">android:orientation</span>=<span style="color: #ff0000;">&quot;vertical&quot;</span><br />
<span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span><br />
<span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span><br />
<span style="color: #000000; font-weight: bold;">&gt;</span><br />
<span style="color: #000000; font-weight: bold;">&lt;TextView</span><br />
<span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span><br />
<span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span><br />
<span style="color: #000066;">android:text</span>=<span style="color: #ff0000;">&quot;@string/hello&quot;</span><br />
<span style="color: #000000; font-weight: bold;">/&gt;</span><br />
<span style="color: #000000; font-weight: bold;">&lt;EditText</span><br />
<span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/EditText01&quot;</span><br />
<span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span><br />
<span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span><br />
<span style="color: #000066;">android:inputType</span>=<span style="color: #ff0000;">&quot;text&quot;</span><br />
<span style="color: #000000; font-weight: bold;">/&gt;</span><br />
<span style="color: #000000; font-weight: bold;">&lt;Button</span><br />
<span style="color: #000066;">android:text</span>=<span style="color: #ff0000;">&quot;@string/btntxt&quot;</span><br />
<span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/Button01&quot;</span><br />
<span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span><br />
<span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span><br />
<span style="color: #000000; font-weight: bold;">/&gt;</span><br />
<span style="color: #000000; font-weight: bold;">&lt;TextView</span><br />
<span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/TextView01&quot;</span><br />
<span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span><br />
<span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span><br />
<span style="color: #000000; font-weight: bold;">/&gt;</span><br />
<span style="color: #000000; font-weight: bold;">&lt;/LinearLayout<span style="color: #000000; font-weight: bold;">&gt;</span></span></div></div>
<h2>Code the application</h2>
<p>Change <em>Main.java </em>to the following:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:100%;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.my</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.app.Activity</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.os.Bundle</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.text.Editable</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.view.View</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.Button</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.EditText</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.TextView</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #000000; font-weight: bold;">extends</span> Activity <span style="color: #009900;">&#123;</span><br />
<br />
EditText input<span style="color: #339933;">;</span><br />
TextView output<span style="color: #339933;">;</span><br />
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+button"><span style="color: #003399;">Button</span></a> buttonClick<span style="color: #339933;">;</span><br />
<br />
<span style="color: #339933;">/</span> <span style="color: #339933;">**</span> Called when the activity is first created. <span style="color: #339933;">*/</span><br />
@Override<br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onCreate<span style="color: #009900;">&#40;</span>Bundle savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span><span style="color: #009900;">&#40;</span>savedInstanceState<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
setContentView<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">layout</span>.<span style="color: #006633;">main</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
input <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>EditText<span style="color: #009900;">&#41;</span> findViewById<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">EditText01</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
output <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>TextView<span style="color: #009900;">&#41;</span> findViewById<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">TextView01</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
buttonClick <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+button"><span style="color: #003399;">Button</span></a><span style="color: #009900;">&#41;</span> findViewById<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">Button01</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
buttonClick.<span style="color: #006633;">setOnClickListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+view"><span style="color: #003399;">View</span></a>.<span style="color: #006633;">OnClickListener</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onClick<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+view"><span style="color: #003399;">View</span></a> v<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
display<span style="color: #009900;">&#40;</span>input.<span style="color: #006633;">getText</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> display<span style="color: #009900;">&#40;</span>Editable text<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
output.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<h2>Run the application</h2>
<p>Al that is left is running the application.</p>
<ol>
<li>Right click <em>MyAndroidAppProject</em>.</li>
<li>Select <strong>Android Application</strong> within the <strong>Run-As</strong> option.</li>
<li>Be patient, the emulator starts up very slow. You should get the following result:</li>
</ol>
<p><a href="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/07/Emulator.gif" rel="lightbox[275]" title="Emulator"><img loading="lazy" class="alignnone size-thumbnail wp-image-269" title="Emulator" src="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/07/Emulator-150x150.gif" alt="" width="150" height="150" /></a></p>
<p>Selecting <em>MyAndroidApp.</em></p>
<p><a href="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/08/select.gif" rel="lightbox[275]" title="select"><img loading="lazy" class="alignnone size-thumbnail wp-image-281" title="select" src="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/08/select-150x150.gif" alt="" width="150" height="150" /></a></p>
<p><em> </em>Enter some text and press on <strong>Click</strong>…</p>
<p><a href="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/08/myFirstApp.gif" rel="lightbox[275]" title="myFirstApp"><img loading="lazy" class="alignnone size-thumbnail wp-image-294" title="myFirstApp" src="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/08/myFirstApp-150x150.gif" alt="" width="150" height="150" /></a></p>
<h2>Appendix</h2>
<p>Download source code <a href='http://wiebe-elsinga.com/blog/wp-content/uploads/2011/03/Android.zip'>Android.zip</a> [16kB]</p>
]]></content:encoded>
					
					<wfw:commentRss>http://wiebe-elsinga.com/blog/developing-a-android-application/feed/</wfw:commentRss>
			<slash:comments>9</slash:comments>
		
		
			</item>
		<item>
		<title>Android Continuous Integration</title>
		<link>http://wiebe-elsinga.com/blog/android-continuous-integration/</link>
					<comments>http://wiebe-elsinga.com/blog/android-continuous-integration/#respond</comments>
		
		<dc:creator><![CDATA[W.Elsinga]]></dc:creator>
		<pubDate>Mon, 26 Jul 2010 06:05:44 +0000</pubDate>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[CI]]></category>
		<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[Hudson]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Robotium]]></category>
		<category><![CDATA[Selenium]]></category>
		<guid isPermaLink="false">http://wiebe-elsinga.com/blog/?p=238</guid>

					<description><![CDATA[So I have been working on a Selenium RC solution with the use of Robotium. To guaranty stable implementation I have set up a Android Continuous Integration Environment. With the use of Maven and Hudson (as done here)  I have achieved this. Until next time&#8230; p.s. Interesting vid [qrcodetag/]]]></description>
										<content:encoded><![CDATA[<p><a href="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android.jpg" rel="lightbox[238]" title="android"><img loading="lazy" class="size-thumbnail wp-image-170 alignleft" style="padding-right: 10px;" title="android" src="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android-150x150.jpg" alt="Android" width="150" height="150" srcset="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android-150x150.jpg 150w, http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android-300x300.jpg 300w, http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android-200x200-cropped.jpg 200w, http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android.jpg 500w" sizes="(max-width: 150px) 100vw, 150px" /></a>So I have been working on a <a title="Relenium RC " href="http://seleniumhq.org/projects/remote-control/" target="_blank">Selenium RC</a> solution with the use of <a title="Robotium" href="http://code.google.com/p/robotium/" target="_blank">Robotium</a>. To guaranty stable implementation I have set up a Android Continuous Integration Environment. With the use of <a title="Maven" href="http://maven.apache.org/" target="_blank">Maven</a> and <a title="Hudson" href="http://hudson-ci.org/" target="_blank">Hudson</a> (as done <a title="Hudson and android" href="http://www.facebook.com/note.php?note_id=499519075367" target="_blank">here</a>)  I have achieved this.</p>
<p>Until next time&#8230;</p>
<p>p.s. Interesting <a title="Robotium Vid" href="http://www.youtube.com/watch?v=VYk1_kpSzQg&amp;feature=player_embedded" target="_blank">vid</a></p>
<p>[qrcodetag/]</p>
]]></content:encoded>
					
					<wfw:commentRss>http://wiebe-elsinga.com/blog/android-continuous-integration/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Functioneel Testen voor Android</title>
		<link>http://wiebe-elsinga.com/blog/functioneel-testen-voor-android/</link>
					<comments>http://wiebe-elsinga.com/blog/functioneel-testen-voor-android/#respond</comments>
		
		<dc:creator><![CDATA[W.Elsinga]]></dc:creator>
		<pubDate>Thu, 06 May 2010 03:49:40 +0000</pubDate>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Robotium]]></category>
		<category><![CDATA[Selenium]]></category>
		<guid isPermaLink="false">http://wiebe-elsinga.com/blog/?p=169</guid>

					<description><![CDATA[Zoals vele collega&#8217;s ben ook ik bezig met het ontwikkelen van een Android applicatie. Na 4 uurtjes was daar toch mijn eerste Android app. Ja en als goede software ontwikkelaar natuurlijk doet, unit-testen. Met JUnit de code getest. Maar ik wou ook de &#8220;frond-end&#8221; functionaliteit testen, en daar stookte het. Tijdens mijn dagelijkse ontwikkel werkzaamheden maak ik Web applicaties en lever ik middels Selenium ook functionele testen op. Helaas ben ik tot de conclusie gekomen dat dit nog ontbreekt bij het ontwikkelen van Android applicaties. Ik heb gekeken of Positron (een Google code project) iets is. Positron voorziet in het uitvoeren van Android Activiteiten om zodoende een test scenario na te spelen. Ik heb ook gekeken naar Robotium. Dit is nou precies wat ik zoek, dus ben nu bezig om dit te gebruiken om functionele test te maken. [qrcodetag/]]]></description>
										<content:encoded><![CDATA[<p><a href="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android.jpg" rel="lightbox[169]" title="android"><img loading="lazy" class="size-thumbnail wp-image-170 alignleft" style="padding-right: 10px;" title="android" src="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android-150x150.jpg" alt="Android" width="150" height="150" srcset="http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android-150x150.jpg 150w, http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android-300x300.jpg 300w, http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android-200x200-cropped.jpg 200w, http://wiebe-elsinga.com/blog/wp-content/uploads/2010/05/android.jpg 500w" sizes="(max-width: 150px) 100vw, 150px" /></a>Zoals vele collega&#8217;s ben ook ik bezig met het ontwikkelen van een <a title="Android" href="http://www.android.com/" target="_blank">Android </a>applicatie. Na 4 uurtjes was daar toch mijn eerste Android app.<br />
Ja en als goede software ontwikkelaar natuurlijk doet, unit-testen. Met <a title="JUnit" href="http://www.junit.org" target="_blank">JUnit</a> de code getest. Maar ik wou ook de &#8220;frond-end&#8221; functionaliteit testen, en daar stookte het.</p>
<p><span id="more-169"></span></p>
<p>Tijdens mijn dagelijkse ontwikkel werkzaamheden maak ik Web applicaties en lever ik middels <a title="Selenium" href="http://seleniumhq.org/" target="_blank">Selenium</a> ook functionele testen op. Helaas ben ik tot de conclusie gekomen dat dit nog ontbreekt bij het ontwikkelen van Android applicaties.</p>
<p>Ik heb gekeken of <a title="Positron" href="http://code.google.com/p/autoandroid/" target="_blank">Positron</a> (een Google code project) iets is. Positron voorziet in het uitvoeren van Android Activiteiten om zodoende een test scenario na te spelen.<br />
Ik heb ook gekeken naar <a title="Robotium" href="http://code.google.com/p/robotium/" target="_blank">Robotium</a>. Dit is nou precies wat ik zoek, dus ben nu bezig om dit te gebruiken om functionele test te maken.</p>
<p>[qrcodetag/]</p>
]]></content:encoded>
					
					<wfw:commentRss>http://wiebe-elsinga.com/blog/functioneel-testen-voor-android/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>JavaOne 2008 &#8211; Dag 3</title>
		<link>http://wiebe-elsinga.com/blog/javaone-2008-dag-3/</link>
					<comments>http://wiebe-elsinga.com/blog/javaone-2008-dag-3/#respond</comments>
		
		<dc:creator><![CDATA[W.Elsinga]]></dc:creator>
		<pubDate>Fri, 30 May 2008 00:51:59 +0000</pubDate>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaOne]]></category>
		<guid isPermaLink="false">http://wiebeelsinga.wordpress.com/?p=79</guid>

					<description><![CDATA[Wie ooit naar San Fransisco gaat moet uiteraard de Golden Gate Bridge gezien hebben, dus plichtsgetrouw werd de reis voortgezet naar dit stukje Amerikaanse cultuur. Al deden we dit wel op een oer Hollandse manier, juist de fiets. Helaas na dat we de brug waren overgestoken en we even ruste voor een drankje, kwam ik er achter dat ik mijn digitale camera was verloren. &#38;#$*$Q#&#38;. Had ik zoveel mooie foto&#8217;s gemaakt, het enige wat ik nog overhield was het hoesje. Maargoed. Na verder te hebben gefietst zijn we met de pont terug gevaren langs Alcatraz heen. Na al dat gefiets werd onze dag vervolgd met een reis naar het Moscone Center, waar we bijzonder gemakkelijk ons toegangsbewijs tot de JavaOne conference kregen (dat scheelt dinsdag weer een uur in de rij staan). Ook een complete tas gevuld met ICT overlevings-middelen ontbrak niet, alles was tot in de puntjes verzorgd!.]]></description>
										<content:encoded><![CDATA[<p><a href="http://java.sun.com/javaone/sf/index.jsp"><img loading="lazy" style="float:left;margin:5px;" src="http://blogs.sun.com/geertjan/resource/javaone-Header.jpg" alt="JavaOne 2008" width="148" height="65" /></a>Wie ooit naar San Fransisco gaat moet uiteraard de Golden Gate Bridge gezien hebben, dus plichtsgetrouw werd de reis voortgezet naar dit stukje Amerikaanse cultuur. Al deden we dit wel op een oer Hollandse manier, juist de fiets.</p>
<p>Helaas na dat we de brug waren overgestoken en we even ruste voor een drankje, kwam ik er achter dat ik mijn digitale camera was verloren. &amp;#$*$Q#&amp;. <img loading="lazy" style="margin:5px;" src="http://www.zurdogo.com/attractions/imagesfp/images/ggbridge2-28.jpg" alt="De brug" width="214" height="142" align="right" />Had ik zoveel mooie foto&#8217;s gemaakt, het enige wat ik nog overhield was het hoesje. Maargoed. Na verder te hebben gefietst zijn we met de pont terug gevaren langs Alcatraz heen.</p>
<p>Na al dat gefiets werd onze dag vervolgd met een reis naar het Moscone Center, waar we bijzonder gemakkelijk ons toegangsbewijs tot de JavaOne conference kregen (dat scheelt dinsdag weer een uur in de rij staan). Ook een complete tas gevuld met ICT overlevings-middelen ontbrak niet, alles was tot in de puntjes verzorgd!.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://wiebe-elsinga.com/blog/javaone-2008-dag-3/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>JavaOne 2008 &#8211; Dag 2</title>
		<link>http://wiebe-elsinga.com/blog/javaone-2008-dag-2/</link>
					<comments>http://wiebe-elsinga.com/blog/javaone-2008-dag-2/#respond</comments>
		
		<dc:creator><![CDATA[W.Elsinga]]></dc:creator>
		<pubDate>Fri, 30 May 2008 00:32:48 +0000</pubDate>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaOne]]></category>
		<guid isPermaLink="false">http://wiebeelsinga.wordpress.com/?p=78</guid>

					<description><![CDATA[Na het ontbijt toch maar even de manager van het hotel gesproken waar mijn collega&#8217;s zaten om te zorgen dat ze maar een kamer voor mij moesten regelen. En dat lukte. En daar sta je dan, down town San Francisco. Vandaag maar eens een stuk de stad gaan bekijken. Na een prachtige route langs de baai zijn we naar Fisherman&#8217;s Wharf. Mooi om daar de zeeleeuwen te zien liggen op Pier 39, maar verder allemaal erg toeristies. Toen zijn we weer via de buiten wijken terug naar het hotel gelopen. Dit was alleen erg afzien omdat de straten daar erg stijl omhoog en omlaag liepen, dus na het avond eten kon ik met zekerheid zeggen, slapen was wederom geen probleem enkel probleem.]]></description>
										<content:encoded><![CDATA[<p><a href="http://java.sun.com/javaone/sf/index.jsp"><img loading="lazy" style="float:left;margin:5px;" src="http://blogs.sun.com/geertjan/resource/javaone-Header.jpg" alt="JavaOne 2008" width="148" height="65" /></a>Na het ontbijt toch maar even de manager van het hotel gesproken waar mijn collega&#8217;s zaten om te zorgen dat ze maar een kamer voor mij moesten regelen. En dat lukte.</p>
<p>En daar sta je dan, down town San Francisco. Vandaag maar eens een stuk de stad gaan bekijken.</p>
<p><img loading="lazy" style="margin:5px;" src="http://www.zurdogo.com/attractions/imagesfw/images/sealions-26.jpg" alt="Zeeleeuwen bij Pier 39" width="91" height="136" align="right" />Na een prachtige route langs de baai zijn we naar <em>Fisherman&#8217;s Wharf</em>. Mooi om daar de zeeleeuwen te zien liggen op <em>Pier 39</em>, maar verder allemaal erg toeristies.</p>
<p>Toen zijn we weer via de buiten wijken terug naar het hotel gelopen. Dit was alleen erg afzien omdat de straten daar erg stijl omhoog en omlaag liepen, dus na het avond eten kon ik met zekerheid zeggen, slapen was wederom geen probleem enkel probleem.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://wiebe-elsinga.com/blog/javaone-2008-dag-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>JavaOne 2008 &#8211; Dag 1</title>
		<link>http://wiebe-elsinga.com/blog/javaone-2008-dag-1/</link>
					<comments>http://wiebe-elsinga.com/blog/javaone-2008-dag-1/#respond</comments>
		
		<dc:creator><![CDATA[W.Elsinga]]></dc:creator>
		<pubDate>Fri, 30 May 2008 00:06:00 +0000</pubDate>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaOne]]></category>
		<guid isPermaLink="false">http://wiebeelsinga.wordpress.com/?p=77</guid>

					<description><![CDATA[Heb ik alles bij me: Telefoon!, IPod (voor de zekerheid ook maar het aankoopsbewijs mee)!, Paspoort!. Ik ben er dan eindelijk klaar voor, de JavaOne in San Francisco. En daar gingen we dan, met 6 andere collega&#8217;s op weg naar de grootste Java conferentie die er is. De rit duurde iets meer dan 14 uur, tussenstop niet meegerekend, maar dankzij het tijdsverschil kwamen we om iets voor 17.00 aan in San Fransisco. Dat betekende s&#8217; even flink doorhalen, want we waren aan het begin van de avond al behoorlijk moe!. Ja en dan lekker je koffers kwijt in je hotel kamer om eens de stad te gaan verkennen. Nou dat ging bij mij tegelijk. Helaas was er iets niet goed gegaan met het boeken van de kamer bij het hotel, dus kreeg ik als enige een kamer in een ander hotel. Dus al &#8216;sightseeingde&#8217; naar mijn ander hotel toe. We zijn we nog even de stad in geweest om een hapje te eten, maar eigenlijk waren we te moe om ook nog maar iets verder te ondernemen; morgen hebben we een vrije dag, dus lekker op tijd naar bed was ook eigenlijk best een goede optie..]]></description>
										<content:encoded><![CDATA[<p><a href="http://java.sun.com/javaone/sf/index.jsp"><img loading="lazy" style="float:left;margin:5px;" src="http://blogs.sun.com/geertjan/resource/javaone-Header.jpg" alt="JavaOne 2008" width="148" height="65" /></a>Heb ik alles bij me: Telefoon!, IPod (voor de zekerheid ook maar het aankoopsbewijs mee)!, Paspoort!. Ik ben er dan eindelijk klaar voor, de JavaOne in San Francisco.</p>
<p>En daar gingen we dan, met 6 andere collega&#8217;s op weg naar de grootste Java conferentie die er is. De rit duurde iets meer dan 14 uur, tussenstop niet meegerekend, maar dankzij het tijdsverschil kwamen we om iets voor 17.00 aan in San Fransisco. Dat betekende s&#8217; even flink doorhalen, want we waren aan het begin van de avond al behoorlijk moe!.</p>
<p>Ja en dan lekker je koffers kwijt in je hotel kamer om eens de stad te gaan verkennen. Nou dat ging bij mij tegelijk. Helaas was er iets niet goed gegaan met het boeken van de kamer bij het hotel, dus kreeg ik als enige een kamer in een ander hotel. Dus al &#8216;sightseeingde&#8217; naar mijn ander hotel toe.</p>
<p>We zijn we nog even de stad in geweest om een hapje te eten, maar eigenlijk waren we te moe om ook nog maar iets verder te ondernemen; morgen hebben we een vrije dag, dus lekker op tijd naar bed was ook eigenlijk best een goede optie..</p>
]]></content:encoded>
					
					<wfw:commentRss>http://wiebe-elsinga.com/blog/javaone-2008-dag-1/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>JavaOne 2008</title>
		<link>http://wiebe-elsinga.com/blog/javaone-2008/</link>
					<comments>http://wiebe-elsinga.com/blog/javaone-2008/#respond</comments>
		
		<dc:creator><![CDATA[W.Elsinga]]></dc:creator>
		<pubDate>Tue, 12 Feb 2008 01:53:30 +0000</pubDate>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaOne]]></category>
		<guid isPermaLink="false">http://wiebeelsinga.wordpress.com/?p=72</guid>

					<description><![CDATA[Het is weer de tijd van het jaar om mijn kennis te delen met andere Java collega&#8217;s. En dit jaar ga ik dan eindlijk naar de JavaOne. JavaOne is het grootste Java congres ter wereld waar tussen de 14.000 en 20.000 bezoekers komen. In de week van 5 t/m 9 mei zal ik in San Francisco veel horen over uiteenlopende zaken die zich afspelen in mijn vakgebied, Java.]]></description>
										<content:encoded><![CDATA[<p><a href="http://java.sun.com/javaone/sf/index.jsp"><img loading="lazy" src="http://blogs.sun.com/geertjan/resource/javaone-Header.jpg" alt="JavaOne 2008" style="float:left;margin:5px;" height="65" width="148" /></a>Het is weer de tijd van het jaar om mijn kennis te delen met andere Java collega&#8217;s. En dit jaar ga ik dan eindlijk naar de JavaOne.</p>
<p>JavaOne is het grootste Java congres ter wereld waar tussen de 14.000 en 20.000 bezoekers komen. In de week van 5 t/m 9 mei zal ik in San Francisco veel horen over uiteenlopende zaken die zich afspelen in mijn vakgebied, Java.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://wiebe-elsinga.com/blog/javaone-2008/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Javapolis 2007 &#8211; RoundUp</title>
		<link>http://wiebe-elsinga.com/blog/javapolis-2007-roundup/</link>
					<comments>http://wiebe-elsinga.com/blog/javapolis-2007-roundup/#respond</comments>
		
		<dc:creator><![CDATA[W.Elsinga]]></dc:creator>
		<pubDate>Tue, 12 Feb 2008 01:27:49 +0000</pubDate>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaPolis]]></category>
		<guid isPermaLink="false">http://wiebeelsinga.wordpress.com/?p=71</guid>

					<description><![CDATA[Na en drukke periode prive en op het werk heb ik dan toch eindelijk de tijd om een verslag te geven van de JavaPolis 2007. Terwijl het thema van vorig jaar Meet your Idiols was, heb ik dit jaar meer van mijn idiols gezien. James Gosling, Joshua Blog, Bruce Eckel en Scott Ambler waren onder andere sprekers waarvan ik genoten heb. Hier een korte impressie van de onderwerpen die besproken werden. Flex en JavaFX. JavaFX werkt goed &#8216;verkocht&#8217; door James Golsing en Sun. Het zou de nieuwe generatie web technologie zijn. Dit betekend nog niet dat de ICT wereld hier meteen mee aan de haal moet gaan voor implementatie van hun software, de syntax van de taal is nog geeneens stabiel. Er werden leuke voorbeelden gegeven, maar deze lieten niet zien waarom JavaFX (en of Flex) gebruikt zouden moeten worden, namelijk voor het op een declaratief manier programmeren van gebruikers interfaces. Agile Scott Ambler, liet aan de hand van statastieken zien dat de meerderheid van de Amerikaanse software bedrijven wel een of meerdere projecten op de Agile manier uitvoerd. Dit betekend dat Agile toch erg volwassen begint te worden, en onderwerpen aanroept die nog niet waren aangekaart zoals modelering, testing en documenteren op een Agile manier. Wicket Het web framework Wicket wordt steeds pupulairder. Martijn Dashorts gaf een presenatie over dit web framework, en durfte het zelfs aan om tijdens zijn presenatie een web applicatie te maken. In mijn ogen is dit framework ideaal voor Agile software ontwikkelen. Additionele onderwepen &#8211; De product Bamboo van Atlassian geeft de mogelijkheid om telematry naar voren te halen van de software builds. &#8211; Eclipse heeft een Ajax Toolkit Framework uitgebracht, tijdens het ontwikkelen en testen van Ajax in Eclipse. Quotes Tot slot nog een aantal quotes van de JavaPolis 2007. The less predictable an event or task the larger the allowance for variation in a project plan Full alphabet soup compliance]]></description>
										<content:encoded><![CDATA[<p><a href="http://www.javapolis.com"><img style="float:left;margin:5px;" src="http://www.javapolis.com/confluence/download/attachments/22791/JP06-Logo2.png" alt="Javapolis 2006" /></a>Na en drukke periode prive en op het werk heb ik dan toch eindelijk de tijd om een verslag te geven van de JavaPolis 2007. Terwijl het thema van vorig jaar <em>Meet your Idiols</em> was, heb ik dit jaar meer van mijn idiols gezien. James Gosling, Joshua Blog, Bruce Eckel en Scott Ambler waren onder andere sprekers waarvan ik genoten heb.</p>
<p>Hier een korte impressie van de onderwerpen die besproken werden.<br />
<span id="more-71"></span><br />
<img loading="lazy" style="margin:5px;" src="http://www.itude.com/wp-content/uploads/12122007095.jpg" alt="Impressie JavaPolis" width="128" height="96" align="right" /><strong>Flex en JavaFX.</strong><br />
JavaFX werkt goed &#8216;verkocht&#8217; door James Golsing en Sun. Het zou de nieuwe generatie web technologie zijn. Dit betekend nog niet dat de ICT wereld hier meteen mee aan de haal moet gaan voor implementatie van hun software, de syntax van de taal is nog geeneens stabiel. Er werden leuke voorbeelden gegeven, maar deze lieten niet zien waarom JavaFX (en of Flex) gebruikt zouden moeten worden, namelijk voor het op een declaratief manier programmeren van gebruikers interfaces.</p>
<p><strong>Agile</strong><br />
Scott Ambler, liet aan de hand van statastieken zien dat de meerderheid van de Amerikaanse software bedrijven wel een of meerdere projecten op de Agile manier uitvoerd. Dit betekend dat Agile toch erg volwassen begint te worden, en onderwerpen aanroept die nog niet waren aangekaart zoals modelering, testing en documenteren op een Agile manier.<br />
<img loading="lazy" style="margin:5px;" src="http://www.itude.com/wp-content/uploads/12122007098.jpg" alt="Mijn Idols" width="128" height="96" align="right" /><br />
<strong>Wicket</strong><br />
Het web framework <a title="Wicket" href="http://wicket.apache.org/" target="_blank">Wicket</a> wordt steeds pupulairder. Martijn Dashorts gaf een presenatie over dit web framework, en durfte het zelfs aan om tijdens zijn presenatie een web applicatie te maken. In mijn ogen is dit framework ideaal voor Agile software ontwikkelen.</p>
<p><strong>Additionele onderwepen</strong><br />
&#8211; De product <a title="Bamboo" href="http://www.atlassian.com/software/bamboo/" target="_blank">Bamboo</a> van Atlassian geeft de mogelijkheid om telematry naar voren te halen van de software builds.<br />
&#8211; Eclipse heeft een Ajax Toolkit Framework uitgebracht, tijdens het ontwikkelen en testen van Ajax in Eclipse.</p>
<p><strong>Quotes</strong><br />
Tot slot nog een aantal quotes van de JavaPolis 2007.</p>
<blockquote><p>The less predictable an event or task the larger the allowance for variation in a project plan</p></blockquote>
<blockquote><p>Full alphabet soup compliance</p></blockquote>
]]></content:encoded>
					
					<wfw:commentRss>http://wiebe-elsinga.com/blog/javapolis-2007-roundup/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
