<?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>Code Library &#187; service</title>
	<atom:link href="http://www.ucosoft.com/tag/service/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ucosoft.com</link>
	<description>Free Source Code and Program Tips</description>
	<lastBuildDate>Thu, 22 Jul 2010 05:17:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Android HTTP Service</title>
		<link>http://www.ucosoft.com/android-http-service-2.html</link>
		<comments>http://www.ucosoft.com/android-http-service-2.html#comments</comments>
		<pubDate>Thu, 17 Dec 2009 04:20:56 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[service]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/uncategorized/android-http-service-2.html</guid>
		<description><![CDATA[Using the HTTP service: 1. Apache HttpClinet Http GET Http POST a. Create HttpClient b. The initial HTTP GET method or POST method. c. set the parameters of key pairs d. implementation of the HTTP call e. processing HTTP reply HTTP GET example: 1 public class TestHttpGetMethod &#40;public void get &#40;&#41; &#40;BufferedReader in = null; [...]]]></description>
			<content:encoded><![CDATA[<p>  Using the HTTP service: </p>
<p>  1. <br />  Apache HttpClinet <br />  Http GET <br />  Http POST </p>
<p>  a. Create HttpClient <br />  b. The initial HTTP GET method or POST method. <br />  c. set the parameters of key pairs <br />  d. implementation of the HTTP call <br />  e. processing HTTP reply </p>
<p>  HTTP GET example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TestHttpGetMethod <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> get <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">BufferedReader</span> in <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#40;</span>HttpClient client <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DefaultHttpClient <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> HttpGet request <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpGet <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> request.<span style="color: #006633;">setURI</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//w26.javaeye.com&amp;quot;); HttpResponse response = client.execute (request); in = new BufferedReader (new InputStreamReader (response.getEntity (). getContent ())); StringBuffer sb = new StringBuffer (&amp;quot;&amp;quot;); String line = &amp;quot;&amp;quot;; String NL = System . getProperty ( &amp;quot;line.separator&amp;quot;); while ((line = in.readLine ())! = null) (sb.append (line   NL);) in.close (); String page = sb.toString () ; Log.i (TAG, page);) catch (Exception e) (Log.e (TAG, e.toString ())) finally (if (in! = null) (try (in.close ();) catch (IOException ioe) (Log.e (TAG, ioe.toString ());)))))</span></pre></td></tr></table></div>

<p>  With parameters of HTTP GET:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  HttpGet request <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpGet <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.baidu.com/s?wd=amos_tl&amp;quot;); client.execute (request);</span></pre></td></tr></table></div>

<p>  HTTP POST Example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TestHttpPostMethod <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> post <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">BufferedReader</span> in <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#40;</span>HttpClient client <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DefaultHttpClient <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> HttpPost request <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpPost <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//localhost/upload.jsp&amp;quot;); List &amp;lt;NameValuePair&amp;gt; postParams = new ArrayList &amp;lt;NameValuePair&amp;gt; (); postParams.add (new BasicNameValuePair ( &amp;quot;filename&amp;quot;, &amp;quot;sex.mov&amp;quot;)); UrlEncodeFormEntity formEntity = new UrlEncodeFormEntity (postParams); request.setEntity (formEntity); HttpResponse response = client.execute ( request); in = new BufferedReader (new InputStreamReader (response.getEntity (). getContent ())); StringBuffer sb = new StringBuffer (&amp;quot;&amp;quot;); String line = &amp;quot;&amp;quot;; String NL = System.getProperty ( &amp;quot;line.separator &amp;quot;); while ((line = in.readLine ())! = null) (sb.append (line   NL);) in.close (); String result = sb.toString (); Log.i (TAG, result);) catch (Exception e) (Log.e (TAG, e.toString ())) finally (if (in! = null) (try (in.close ();) catch (IOException ioe) (Log. e (TAG, ioe.toString ());)))))</span></pre></td></tr></table></div>

<p>  multipart POST support: </p>
<p>  Requires the following support: <br />  Commons IO <br />  http://commons.apache.org/io/ </p>
<p>  Mime4j <br />  http://james.apache.org/mime4j/ </p>
<p>  HttpMime <br />  http://hc.apache.org/httpcomponents-client/httpmime/index.html </p>
<p>  Download all the JAR URL: <br />  http://www.sayedhashimi.com/downloads/android/multipart-android.zip </p>
<p>  multipart POST Example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TestHttpMultipartPost <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> mulPost <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#40;</span>InputStram in <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getAssets</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">open</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>data.<span style="color: #006633;">xml</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> HttpClient client <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpDefaultHttpClient <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> HttpPost request <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpPost <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//localhost / upload.jsp &amp;quot;); byte [] data = IOUtils.toByteArray (in); InputStreamBody isb = new InputStreamBody (new ByteArrayIntputStream (data),&amp;quot; uploadedFile &amp;quot;); StringBody sb1 = new StringBody (&amp;quot; some text &amp;quot;); StringBoyd sb2 = new StringBody ( &amp;quot;some text too&amp;quot;); MultipartEntity me = new MultipartEntity (); me.addPart ( &amp;quot;uploadedFile&amp;quot;, isb); me.addPart ( &amp;quot;one&amp;quot;, sb1); me.addPart ( &amp;quot;two&amp;quot;, sb2 ); request.setEntity (me); HttpRespones response = client.excute (request); res.getEntity (). getContent (). close ();) catch (Throwable e) (Log.e (TAG, e.toString ( ));)))</span></pre></td></tr></table></div>

<p>  Exception handling retry processing </p>
<p>  The use of multi-threading problem ClientConnectionManager, to create a thread-safe HttpClient.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ApplicationEx <span style="color: #000000; font-weight: bold;">extends</span> Application <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> TAG <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>amos_tl<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;;</span> <span style="color: #000000; font-weight: bold;">private</span> HttpClient client <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span> @ override <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><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> client <span style="color: #339933;">=</span> createHttpClient <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> @ override <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onLowMemory <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onLowMemory</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> shutdownHttpClient <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> @ override <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onTerminate <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onTerminate</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> shutdownHttpClient <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> shutdownHttpClient <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>client<span style="color: #339933;">!</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span> client.<span style="color: #006633;">getConnectionManager</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">!</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;">&#40;</span>client.<span style="color: #006633;">getConnectionManager</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">shutdown</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> client <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">private</span> HttpClient createHttpClient <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span>Log.<span style="color: #006633;">d</span> <span style="color: #009900;">&#40;</span>TAG, <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>create httpclient ...<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> HttpParams params <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> BasicHttpParams <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> HttpProtocolParams . <span style="color: #006633;">setVersion</span> <span style="color: #009900;">&#40;</span>params, HttpVersion.<span style="color: #006633;">HTTP_1_1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> HttpProtocolParams.<span style="color: #006633;">setContentCharset</span> <span style="color: #009900;">&#40;</span>params, HTTP.<span style="color: #006633;">DEFAULT_CONTENT_CHARSET</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> HttpProtocolParams.<span style="color: #006633;">setUseExpectContinue</span> <span style="color: #009900;">&#40;</span>params, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> SchemaRegistry sr <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SchemaRegistry <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> sr.<span style="color: #006633;">register</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Schema <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>http<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>, PlainSocketFactory . <span style="color: #006633;">getSocketFactory</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #cc66cc;">80</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> sr.<span style="color: #006633;">register</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Schema <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>https<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>, SLLSocketFactory.<span style="color: #006633;">getSocketFactory</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #cc66cc;">443</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> ClientConnectionManager cm <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ThreadSafeClientConnManager <span style="color: #009900;">&#40;</span>params, sr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> DefaultHttpClient <span style="color: #009900;">&#40;</span>cm, params<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">public</span> HttpClient getHttpClient <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">return</span> client<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>  HttpActivity.java</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HttpActivity <span style="color: #000000; font-weight: bold;">extends</span> Activity <span style="color: #009900;">&#40;</span>@ override <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;">&#40;</span><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> Log.<span style="color: #006633;">d</span> <span style="color: #009900;">&#40;</span>TAG, <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>httpactivity startup ...<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> getHttpContent <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> getHttpContent <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#40;</span>ApplicationEx app <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>ApplicationEx<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getApplication</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> HttpClient client <span style="color: #339933;">=</span> app.<span style="color: #006633;">getHttpClient</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> HttpGet request <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpGet <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> request.<span style="color: #006633;">setURI</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//w26.javaeye.com&amp;quot;); HttpResponse response = client.excute (resquest); String page = EntityUtils.toString (response.getEntity ()); Log.i (TAG, page);) catch (Exception e) (Log.e (TAG, e.toString ()); )))</span></pre></td></tr></table></div>

<p>  Configuration AndroidManifest.xml <br />  &lt;application android: icon = &quot;@ drawable / icon&quot; <br />  android: label = &quot;@ string / app_name&quot; <br />  <u>android: name = &quot;ApplictionEx&quot;</u> <br />  &quot; </p></p>

	Tags: <strong><a href="http://www.ucosoft.com/tag/android" title="android" rel="tag">android</a>, <a href="http://www.ucosoft.com/tag/http" title="http" rel="tag">http</a>, <a href="http://www.ucosoft.com/tag/service" title="service" rel="tag">service</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/android-http-service-2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android HTTP Service</title>
		<link>http://www.ucosoft.com/android-http-service.html</link>
		<comments>http://www.ucosoft.com/android-http-service.html#comments</comments>
		<pubDate>Sat, 21 Nov 2009 02:44:00 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[service]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/uncategorized/android-http-service.html</guid>
		<description><![CDATA[Using the HTTP service: 1. Apache HttpClinet Http GET Http POST a. Create HttpClient b. The initial HTTP GET method or POST method. c. set the parameters of key pairs d. implementation of the HTTP call e. processing HTTP reply HTTP GET example: 1 2 3 4 5 6 7 8 9 10 11 12 [...]]]></description>
			<content:encoded><![CDATA[<p>Using the HTTP service:</p>
<p>1. <br />
Apache HttpClinet <br />
Http GET <br />
Http POST</p>
<p>a. Create HttpClient <br />
b. The initial HTTP GET method or POST method. <br />
c. set the parameters of key pairs <br />
d. implementation of the HTTP call <br />
e. processing HTTP reply</p>
<p>HTTP GET example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TestHttpGetMethod
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> get<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">BufferedReader</span> in <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">try</span>
        <span style="color: #009900;">&#123;</span>
            HttpClient client <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DefaultHttpClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            HttpGet request <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpGet<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            request.<span style="color: #006633;">setURI</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://w26.javaeye.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            HttpResponse response <span style="color: #339933;">=</span> client.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>request<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> in <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">InputStreamReader</span><span style="color: #009900;">&#40;</span>response.<span style="color: #006633;">getEntity</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getContent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">StringBuffer</span> sb <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringBuffer</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">String</span> line <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">String</span> NL <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;line.separator&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>line <span style="color: #339933;">=</span> in .<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: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                sb.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>line NL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> in .<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">String</span> page <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>
            Log.<span style="color: #006633;">i</span><span style="color: #009900;">&#40;</span>TAG, page<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            Log.<span style="color: #006633;">e</span><span style="color: #009900;">&#40;</span>TAG, e.<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: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">finally</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> in <span style="color: #339933;">!</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>
                <span style="color: #000000; font-weight: bold;">try</span>
                <span style="color: #009900;">&#123;</span> in .<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> ioe<span style="color: #009900;">&#41;</span>
                <span style="color: #009900;">&#123;</span>
                    Log.<span style="color: #006633;">e</span><span style="color: #009900;">&#40;</span>TAG, ioe.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>With parameters of HTTP GET:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  HttpGet request <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpGet <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.baidu.com/s?wd=amos_tl&amp;quot;); client.execute (request);</span></pre></td></tr></table></div>

<p>HTTP POST Example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TestHttpPostMethod <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> post <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">BufferedReader</span> in <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#40;</span>HttpClient client <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DefaultHttpClient <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> HttpPost request <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpPost <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//localhost/upload.jsp&amp;quot;); List &amp;lt;NameValuePair&amp;gt; postParams = new ArrayList &amp;lt;NameValuePair&amp;gt; (); postParams.add (new BasicNameValuePair ( &amp;quot;filename&amp;quot;, &amp;quot;sex.mov&amp;quot;)); UrlEncodeFormEntity formEntity = new UrlEncodeFormEntity (postParams); request.setEntity (formEntity); HttpResponse response = client.execute ( request); in = new BufferedReader (new InputStreamReader (response.getEntity (). getContent ())); StringBuffer sb = new StringBuffer (&amp;quot;&amp;quot;); String line = &amp;quot;&amp;quot;; String NL = System.getProperty ( &amp;quot;line.separator &amp;quot;); while ((line = in.readLine ())! = null) (sb.append (line   NL);) in.close (); String result = sb.toString (); Log.i (TAG, result);) catch (Exception e) (Log.e (TAG, e.toString ())) finally (if (in! = null) (try (in.close ();) catch (IOException ioe) (Log. e (TAG, ioe.toString ());)))))</span></pre></td></tr></table></div>

<p>multipart POST support:</p>
<p>Requires the following support: <br />
Commons IO </p>
<p>http://commons.apache.org/io/</p>
<p>Mime4j </p>
<p>http://james.apache.org/mime4j/</p>
<p>HttpMime </p>
<p>http://hc.apache.org/httpcomponents-client/httpmime/index.html</p>
<p>Download all the JAR URL: </p>
<p>http://www.sayedhashimi.com/downloads/android/multipart-android.zip</p>
<p>multipart POST Example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TestHttpMultipartPost <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> mulPost <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#40;</span>InputStram in <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getAssets</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">open</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>data.<span style="color: #006633;">xml</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> HttpClient client <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpDefaultHttpClient <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> HttpPost request <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpPost <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//localhost / upload.jsp &amp;quot;); byte [] data = IOUtils.toByteArray (in); InputStreamBody isb = new InputStreamBody (new ByteArrayIntputStream (data),&amp;quot; uploadedFile &amp;quot;); StringBody sb1 = new StringBody (&amp;quot; some text &amp;quot;); StringBoyd sb2 = new StringBody ( &amp;quot;some text too&amp;quot;); MultipartEntity me = new MultipartEntity (); me.addPart ( &amp;quot;uploadedFile&amp;quot;, isb); me.addPart ( &amp;quot;one&amp;quot;, sb1); me.addPart ( &amp;quot;two&amp;quot;, sb2 ); request.setEntity (me); HttpRespones response = client.excute (request); res.getEntity (). getContent (). close ();) catch (Throwable e) (Log.e (TAG, e.toString ( ));)))</span></pre></td></tr></table></div>

<p>Exception handling retry processing</p>
<p>The use of multi-threading problem ClientConnectionManager, to create a thread-safe HttpClient.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ApplicationEx <span style="color: #000000; font-weight: bold;">extends</span> Application <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> TAG <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>amos_tl<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;;</span> <span style="color: #000000; font-weight: bold;">private</span> HttpClient client <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span> @ override <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><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> client <span style="color: #339933;">=</span> createHttpClient <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> @ override <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onLowMemory <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onLowMemory</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> shutdownHttpClient <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> @ override <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onTerminate <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onTerminate</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> shutdownHttpClient <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> shutdownHttpClient <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>client<span style="color: #339933;">!</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span> client.<span style="color: #006633;">getConnectionManager</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">!</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;">&#40;</span>client.<span style="color: #006633;">getConnectionManager</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">shutdown</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> client <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">private</span> HttpClient createHttpClient <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span>Log.<span style="color: #006633;">d</span> <span style="color: #009900;">&#40;</span>TAG, <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>create httpclient ...<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> HttpParams params <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> BasicHttpParams <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> HttpProtocolParams . <span style="color: #006633;">setVersion</span> <span style="color: #009900;">&#40;</span>params, HttpVersion.<span style="color: #006633;">HTTP_1_1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> HttpProtocolParams.<span style="color: #006633;">setContentCharset</span> <span style="color: #009900;">&#40;</span>params, HTTP.<span style="color: #006633;">DEFAULT_CONTENT_CHARSET</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> HttpProtocolParams.<span style="color: #006633;">setUseExpectContinue</span> <span style="color: #009900;">&#40;</span>params, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> SchemaRegistry sr <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SchemaRegistry <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> sr.<span style="color: #006633;">register</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Schema <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>http<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>, PlainSocketFactory . <span style="color: #006633;">getSocketFactory</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #cc66cc;">80</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> sr.<span style="color: #006633;">register</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Schema <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>https<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>, SLLSocketFactory.<span style="color: #006633;">getSocketFactory</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #cc66cc;">443</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> ClientConnectionManager cm <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ThreadSafeClientConnManager <span style="color: #009900;">&#40;</span>params, sr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> DefaultHttpClient <span style="color: #009900;">&#40;</span>cm, params<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">public</span> HttpClient getHttpClient <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">return</span> client<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>HttpActivity.java</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HttpActivity <span style="color: #000000; font-weight: bold;">extends</span> Activity <span style="color: #009900;">&#40;</span>@ override <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;">&#40;</span><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> Log.<span style="color: #006633;">d</span> <span style="color: #009900;">&#40;</span>TAG, <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>httpactivity startup ...<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> getHttpContent <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> getHttpContent <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#40;</span>ApplicationEx app <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>ApplicationEx<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getApplication</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> HttpClient client <span style="color: #339933;">=</span> app.<span style="color: #006633;">getHttpClient</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> HttpGet request <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpGet <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> request.<span style="color: #006633;">setURI</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//w26.javaeye.com&amp;quot;); HttpResponse response = client.excute (resquest); String page = EntityUtils.toString (response.getEntity ()); Log.i (TAG, page);) catch (Exception e) (Log.e (TAG, e.toString ()); )))</span></pre></td></tr></table></div>

<p>Configuration AndroidManifest.xml <br />
&lt;application android: icon = &quot;@ drawable / icon&quot; <br />
android: label = &quot;@ string / app_name&quot; <br />
<u>android: name = &quot;ApplictionEx&quot;</u> <br />
&quot;</p>
<p>&nbsp;</p>
<div style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 5px; height: 1px; cursor: w-resize; left: 0pt; top: 0pt; z-index: 2147483647;" id="resizeableTFgripH_0">&nbsp;</div>
<div style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 1px; height: 5px; cursor: n-resize; left: 0pt; top: 0pt; z-index: 2147483647;" id="resizeableTFgripV_0">&nbsp;</div>
<div style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 10px; height: 5px; cursor: se-resize; left: 0pt; top: 0pt; z-index: 2147483647;" id="resizeableTFgripX_0">&nbsp;</div>
<div style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 5px; height: 1px; cursor: w-resize; left: 0pt; top: 0pt; z-index: 2147483647;" id="resizeableTFgripH_1">&nbsp;</div>
<div style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 1px; height: 5px; cursor: n-resize; left: 0pt; top: 0pt; z-index: 2147483647;" id="resizeableTFgripV_1">&nbsp;</div>
<div style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 10px; height: 5px; cursor: se-resize; left: 0pt; top: 0pt; z-index: 2147483647;" id="resizeableTFgripX_1">&nbsp;</div>
<div style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 5px; height: 1px; cursor: w-resize; left: 0pt; top: 0pt; z-index: 2147483647;" id="resizeableTFgripH_2">&nbsp;</div>
<div style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 1px; height: 5px; cursor: n-resize; left: 0pt; top: 0pt; z-index: 2147483647;" id="resizeableTFgripV_2">&nbsp;</div>
<div style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 10px; height: 5px; cursor: se-resize; left: 0pt; top: 0pt; z-index: 2147483647;" id="resizeableTFgripX_2">&nbsp;</div>
<div style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 5px; height: 1px; cursor: w-resize; left: 0pt; top: 0pt; z-index: 2147483647;" id="resizeableTFgripH_3">&nbsp;</div>
<div style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 1px; height: 5px; cursor: n-resize; left: 0pt; top: 0pt; z-index: 2147483647;" id="resizeableTFgripV_3">&nbsp;</div>
<div style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 10px; height: 5px; cursor: se-resize; left: 0pt; top: 0pt; z-index: 2147483647;" id="resizeableTFgripX_3">&nbsp;</div>
<div style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 5px; height: 1px; cursor: w-resize; left: 0pt; top: 0pt; z-index: 2147483647;" id="resizeableTFgripH_4">&nbsp;</div>
<div style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 1px; height: 5px; cursor: n-resize; left: 0pt; top: 0pt; z-index: 2147483647;" id="resizeableTFgripV_4">&nbsp;</div>
<div style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 10px; height: 5px; cursor: se-resize; left: 0pt; top: 0pt; z-index: 2147483647;" id="resizeableTFgripX_4">&nbsp;</div>
<div style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 5px; height: 1px; cursor: w-resize; left: 0pt; top: 0pt; z-index: 2147483647;" id="resizeableTFgripH_5">&nbsp;</div>
<div style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 1px; height: 5px; cursor: n-resize; left: 0pt; top: 0pt; z-index: 2147483647;" id="resizeableTFgripV_5">&nbsp;</div>
<div style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 10px; height: 5px; cursor: se-resize; left: 0pt; top: 0pt; z-index: 2147483647;" id="resizeableTFgripX_5">&nbsp;</div>
<div style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 0px; height: 0px; cursor: w-resize; left: 0pt; top: 0pt; z-index: 2147483647;" id="resizeableTFshowCursor">&nbsp;</div>
<div id="resizeableTFgripH_0" style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 5px; height: 1px; cursor: w-resize; left: 0pt; top: 0pt; z-index: 2147483647;">&nbsp;</div>
<div id="resizeableTFgripV_0" style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 1px; height: 5px; cursor: n-resize; left: 0pt; top: 0pt; z-index: 2147483647;">&nbsp;</div>
<div id="resizeableTFgripX_0" style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 10px; height: 5px; cursor: se-resize; left: 0pt; top: 0pt; z-index: 2147483647;">&nbsp;</div>
<div id="resizeableTFgripH_1" style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 5px; height: 1px; cursor: w-resize; left: 0pt; top: 0pt; z-index: 2147483647;">&nbsp;</div>
<div id="resizeableTFgripV_1" style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 1px; height: 5px; cursor: n-resize; left: 0pt; top: 0pt; z-index: 2147483647;">&nbsp;</div>
<div id="resizeableTFgripX_1" style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 10px; height: 5px; cursor: se-resize; left: 0pt; top: 0pt; z-index: 2147483647;">&nbsp;</div>
<div id="resizeableTFgripH_2" style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 5px; height: 1px; cursor: w-resize; left: 0pt; top: 0pt; z-index: 2147483647;">&nbsp;</div>
<div id="resizeableTFgripV_2" style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 1px; height: 5px; cursor: n-resize; left: 0pt; top: 0pt; z-index: 2147483647;">&nbsp;</div>
<div id="resizeableTFgripX_2" style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 10px; height: 5px; cursor: se-resize; left: 0pt; top: 0pt; z-index: 2147483647;">&nbsp;</div>
<div id="resizeableTFgripH_3" style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 5px; height: 1px; cursor: w-resize; left: 0pt; top: 0pt; z-index: 2147483647;">&nbsp;</div>
<div id="resizeableTFgripV_3" style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 1px; height: 5px; cursor: n-resize; left: 0pt; top: 0pt; z-index: 2147483647;">&nbsp;</div>
<div id="resizeableTFgripX_3" style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 10px; height: 5px; cursor: se-resize; left: 0pt; top: 0pt; z-index: 2147483647;">&nbsp;</div>
<div id="resizeableTFgripH_4" style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 5px; height: 1px; cursor: w-resize; left: 0pt; top: 0pt; z-index: 2147483647;">&nbsp;</div>
<div id="resizeableTFgripV_4" style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 1px; height: 5px; cursor: n-resize; left: 0pt; top: 0pt; z-index: 2147483647;">&nbsp;</div>
<div id="resizeableTFgripX_4" style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 10px; height: 5px; cursor: se-resize; left: 0pt; top: 0pt; z-index: 2147483647;">&nbsp;</div>
<div id="resizeableTFgripH_5" style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 5px; height: 1px; cursor: w-resize; left: 0pt; top: 0pt; z-index: 2147483647;">&nbsp;</div>
<div id="resizeableTFgripV_5" style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 1px; height: 5px; cursor: n-resize; left: 0pt; top: 0pt; z-index: 2147483647;">&nbsp;</div>
<div id="resizeableTFgripX_5" style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 10px; height: 5px; cursor: se-resize; left: 0pt; top: 0pt; z-index: 2147483647;">&nbsp;</div>
<div id="resizeableTFshowCursor" style="display: none; border: medium none; font-size: 1px; line-height: 1px; margin: 0pt; padding: 0pt; position: fixed; width: 0px; height: 0px; cursor: w-resize; left: 0pt; top: 0pt; z-index: 2147483647;">&nbsp;</div>

	Tags: <strong><a href="http://www.ucosoft.com/tag/android" title="android" rel="tag">android</a>, <a href="http://www.ucosoft.com/tag/http" title="http" rel="tag">http</a>, <a href="http://www.ucosoft.com/tag/service" title="service" rel="tag">service</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/android-http-service.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Development Interactive Voice Response service using Mobicents and jBPM</title>
		<link>http://www.ucosoft.com/development-interactive-voice-response-service.html</link>
		<comments>http://www.ucosoft.com/development-interactive-voice-response-service.html#comments</comments>
		<pubDate>Fri, 16 Oct 2009 06:10:56 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[interactive]]></category>
		<category><![CDATA[response]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[voice]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/?p=158</guid>
		<description><![CDATA[This is my first blog message:) At the final end I am going to blog about Mobicents Media server and other components of Mobicents platform. How to use it for development of the telco applications. Let&#8217;s start from one of the widely used telco application IVR, or Interactive Voice Response, is one of the most [...]]]></description>
			<content:encoded><![CDATA[<p><span><span><span>
<div>This is my first blog message:)</div>
<div></div>
<div>At the final end I am going to blog about Mobicents Media server and other components of Mobicents platform. How to use it for development of the telco applications. Let&#8217;s start from one of the widely used telco application</div>
<div></div>
<p>IVR, or Interactive Voice </span></span></span><span><span><span>Response, is one of the most used types of telco application. It automates the interaction (retrieval and input of data) with a database, typically through the use of a touch-tone (DTMF) telephone. Most of us use some type of IVR application every day. Whether it&#8217;s to check bank balances or transfer funds, manage credit cards, order prescription medicine, verify flight information or check for store hours or locations. </span></span></span>
<div><span><span><span><br /></span></span></span></div>
<div><span><span>Media server which is responsible for voice and DTMF tone processing is one of the manadatory element of network infrastructure. The modern network suppose that the Media server is a dump thing and is under control from intelligent call controller application which is placed on the signaling way. In other words we can say that Media Server is doing a &#8220;black job&#8221; for call controller :) But media server still has to provide usefull interfaces for call controller. </span></span></div>
<div><span><span><br /></span></span></div>
<div><span><span>All media server work always will be joined with call controller application. Fortunately now the process of writting telco-grade applications is more simple then several years ago. But anyway the telco was traditionaly closed area and is new now for most of the mainstream developers. I think would be interested to start blogging about Mobicents Media server from paper which explains how to write telco application. </span></span></div>
<div><span><span><br /></span></span></div>
<div><span><span>So, it is started but not completed yet. Stay turned.</span></span></div>
<div><span><span>http://groups.google.com/group/mobicents-public/web/interactive-voice-response-by-jbpm</span></span></div>
<div><span><span><br /></span></span></div>
<div><span><span>  </span></span></div>

	Tags: <strong><a href="http://www.ucosoft.com/tag/development" title="development" rel="tag">development</a>, <a href="http://www.ucosoft.com/tag/interactive" title="interactive" rel="tag">interactive</a>, <a href="http://www.ucosoft.com/tag/response" title="response" rel="tag">response</a>, <a href="http://www.ucosoft.com/tag/service" title="service" rel="tag">service</a>, <a href="http://www.ucosoft.com/tag/voice" title="voice" rel="tag">voice</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/development-interactive-voice-response-service.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

