<?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>ObjectGraph Blog</title>
	<atom:link href="http://blog.objectgraph.com/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.objectgraph.com</link>
	<description>News and Info about projects and experiments @ objectgraph.com</description>
	<lastBuildDate>Thu, 10 May 2012 02:30:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Was my twitter account compromised?</title>
		<link>http://blog.objectgraph.com/index.php/2012/05/09/was-m-twitter-account-compromised/</link>
		<comments>http://blog.objectgraph.com/index.php/2012/05/09/was-m-twitter-account-compromised/#comments</comments>
		<pubDate>Wed, 09 May 2012 21:32:05 +0000</pubDate>
		<dc:creator>kiichi</dc:creator>
				<category><![CDATA[misc]]></category>
		<category><![CDATA[webapps]]></category>
		<category><![CDATA[account]]></category>
		<category><![CDATA[leak]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://blog.objectgraph.com/?p=2600</guid>
		<description><![CDATA[Today, hackers posted 55K+ twitter username and password on a public website. We created a website where you can quickly check your username. Enter your username and hit check button. Click here to go to the website.]]></description>
			<content:encoded><![CDATA[<p>Today, hackers posted 55K+ twitter username and password on a public website. We created a website where you can quickly check your username. Enter your username and hit check button. <a href="http://blog.objectgraph.com/twitter/">Click here to go to the website</a>.</p>
<p><a href="http://blog.objectgraph.com/twitter/"><img class="alignnone size-large wp-image-2601" title="Twitter Account Check" src="http://blog.objectgraph.com/wp-content/uploads/2012/05/Screen-Shot-2012-05-09-at-5.29.38-PM-550x463.png" alt="" width="550" height="463" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectgraph.com/index.php/2012/05/09/was-m-twitter-account-compromised/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Geo Elevation for Android Released</title>
		<link>http://blog.objectgraph.com/index.php/2012/04/28/geo-elevation-for-android-released/</link>
		<comments>http://blog.objectgraph.com/index.php/2012/04/28/geo-elevation-for-android-released/#comments</comments>
		<pubDate>Sat, 28 Apr 2012 03:56:25 +0000</pubDate>
		<dc:creator>kiichi</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[Geo]]></category>

		<guid isPermaLink="false">http://blog.objectgraph.com/?p=2589</guid>
		<description><![CDATA[We just released Geo Elevation App for Android! This app let you draw a path by touching screen, and you can generate a &#8220;Cross-Section&#8221; elevation chart. This is some sort of side-view when you cut through the object. For example, if you are wondering how Mt. Fuji looks like from the side, draw the pass [...]]]></description>
			<content:encoded><![CDATA[<p>We just released <a href="https://play.google.com/store/apps/details?id=com.objectgraph.GeoElevation">Geo Elevation App for Android</a>! This app let you draw a path by touching screen, and you can generate a &#8220;Cross-Section&#8221; elevation chart. This is some sort of side-view when you cut through the object. For example, if you are wondering how Mt. Fuji looks like from the side, draw the pass across the peak, then simply hit &#8220;Get Elevation&#8221; button. Not only for study usage, but also this is useful for biking or jogging. Draw a path through your favorite training routes, then the app will tell you the hilly areas v.s. flat area in the comprehensive chart.</p>
<p><a href="http://blog.objectgraph.com/wp-content/uploads/2012/04/Feature_sm1.png"><img class="alignnone size-full wp-image-2595" title="Feature_sm" src="http://blog.objectgraph.com/wp-content/uploads/2012/04/Feature_sm1.png" alt="" width="550" height="269" /></a></p>
<p>Unlikely other elevation app, you can drop the pin anywhere you want, then find out the elevation right away. The app also allows you to export the data in various formats, such as KML, CSV, summary text, image, and so on.</p>
<p>Get this app while it is promotional price.</p>
<p><iframe width="560" height="315" src="http://www.youtube.com/embed/gGOXyb2nUXY" frameborder="0" allowfullscreen></iframe></p>
<p><a href="https://play.google.com/store/apps/details?id=com.objectgraph.GeoElevation"><img class="alignnone size-full wp-image-2584" title="googleplaylogo" src="http://blog.objectgraph.com/wp-content/uploads/2012/04/googleplaylogo.gif" alt="" width="258" height="76" />Download Geo Elevation for Android NOW!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectgraph.com/index.php/2012/04/28/geo-elevation-for-android-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Geo Measure for Android Released</title>
		<link>http://blog.objectgraph.com/index.php/2012/04/26/geo-measure-for-android-released/</link>
		<comments>http://blog.objectgraph.com/index.php/2012/04/26/geo-measure-for-android-released/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 04:16:00 +0000</pubDate>
		<dc:creator>kiichi</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[Geo]]></category>
		<category><![CDATA[app]]></category>
		<category><![CDATA[area]]></category>
		<category><![CDATA[calculation]]></category>
		<category><![CDATA[distance]]></category>
		<category><![CDATA[gis]]></category>
		<category><![CDATA[gps]]></category>
		<category><![CDATA[measure]]></category>

		<guid isPermaLink="false">http://blog.objectgraph.com/?p=2576</guid>
		<description><![CDATA[Need to measure your land? How long is your jogging path? What is the area size of New York State? Geo Measure app in Android will give you the answer right away. Check out the intuitive drag &#38; drop interface to measure the area and distance in a few clicks away. If you find interesting [...]]]></description>
			<content:encoded><![CDATA[<p>Need to measure your land? How long is your jogging path? What is the area size of New York State? <a href="http://bit.ly/HGEvhQ">Geo Measure app in Android</a> will give you the answer right away. Check out the intuitive drag &amp; drop interface to measure the area and distance in a few clicks away. If you find interesting / useful way to use the app, please leave your feedback in the comment area.</p>
<p><a href="http://blog.objectgraph.com/wp-content/uploads/2012/04/Feature_sm.png"><img class="alignnone size-full wp-image-2580" title="Feature_sm" src="http://blog.objectgraph.com/wp-content/uploads/2012/04/Feature_sm.png" alt="" width="550" height="269" /></a></p>
<p>Check out the demo movie here</p>
<p><iframe width="560" height="315" src="http://www.youtube.com/embed/lQM0j7iHANY" frameborder="0" allowfullscreen></iframe></p>
<p>The app also works for tablet device. </p>
<p><iframe width="560" height="315" src="http://www.youtube.com/embed/Tewsy1su-M0" frameborder="0" allowfullscreen></iframe></p>
<p>In addition, we will cover some of those programming materials in our new online course, Mobile GIS (Starting this september).</p>
<p><a href="http://bit.ly/HGEvhQ"><img src="http://blog.objectgraph.com/wp-content/uploads/2012/04/googleplaylogo.gif" alt="" title="googleplaylogo" width="258" height="76" class="alignnone size-full wp-image-2584" /> Download Geo Measure from Google Play</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectgraph.com/index.php/2012/04/26/geo-measure-for-android-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Geo Elevation App for iPhone and iPad</title>
		<link>http://blog.objectgraph.com/index.php/2012/03/25/geo-elevation-app-for-iphone-and-ipad/</link>
		<comments>http://blog.objectgraph.com/index.php/2012/03/25/geo-elevation-app-for-iphone-and-ipad/#comments</comments>
		<pubDate>Sun, 25 Mar 2012 15:19:26 +0000</pubDate>
		<dc:creator>kiichi</dc:creator>
				<category><![CDATA[apple]]></category>
		<category><![CDATA[Geo]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[iphone development]]></category>
		<category><![CDATA[misc]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[bathymetric]]></category>
		<category><![CDATA[bike]]></category>
		<category><![CDATA[cross section]]></category>
		<category><![CDATA[exercise]]></category>
		<category><![CDATA[lab]]></category>
		<category><![CDATA[marathon]]></category>
		<category><![CDATA[mountain]]></category>
		<category><![CDATA[side view]]></category>
		<category><![CDATA[trench]]></category>

		<guid isPermaLink="false">http://blog.objectgraph.com/?p=2538</guid>
		<description><![CDATA[Send email to iphone [-at-] objectgraph.com or add a comment below to request a free coupon code! Hurry up, because we have very limited amount of coupon codes. Geo Elevation is a powerful tool to build a cross-sectional elevation chart from any paths/points on the map with a few clicks. Simply create a path and [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: #0000ff;"><strong>Send email to iphone [-at-] objectgraph.com or add a comment below to request a free coupon code! Hurry up, because we have very limited amount of coupon codes.</strong></span></p>
<p><a href="http://itunes.apple.com/us/app/geo-elevation-map-elevation/id509924746?mt=8"><img class="alignnone size-full wp-image-159" title="App Store Download" src="http://blog.objectgraph.com/wp-content/uploads/2008/10/appstore.png" alt="" width="190" height="62" /></a><br />
<strong></strong></p>
<p><strong>Geo Elevation</strong> is a powerful tool to build a cross-sectional elevation chart from any paths/points on the map with a few clicks. Simply create a path and click on &#8220;Get Elevation&#8221; you will see a nice chart. Now, this app works on both iPhone and iPad! Buy only once, and enjoy in both platform. We definitely recommend you to try it on iPad.</p>
<p><a href="http://blog.objectgraph.com/wp-content/uploads/2012/03/iphone4.png"><img title="Geo Elevation - Cut Through the Mt. Everest" src="http://blog.objectgraph.com/wp-content/uploads/2012/03/iphone4.png" alt="" width="384" height="576" /></a> <a href="http://blog.objectgraph.com/wp-content/uploads/2012/03/iphone3.png"><img class="alignnone  wp-image-2561" title="Geo Elevation - Strike Through Japan" src="http://blog.objectgraph.com/wp-content/uploads/2012/03/iphone3.png" alt="" width="384" height="576" /></a></p>
<p>How does Mt. Everest look like if you cut through the peak, and view it from the side? Try to draw a path from your place to the nearest shoreline. See how slope decline as it approach the ocean? How about investingating the Mariana Trench&#8217;s steep slope, which goes down to the deepest place on the Earth?</p>
<p><a href="http://blog.objectgraph.com/wp-content/uploads/2012/03/ios_1.png"><img class="alignnone size-large wp-image-2545" title="Geo Elevation App let you strike through continents and island" src="http://blog.objectgraph.com/wp-content/uploads/2012/03/ios_1-550x412.png" alt="" width="550" height="412" /></a></p>
<p>In addition, the line of the elevation profile is clickable to indicate corresponding location on the path that you draw.</p>
<p>[Features]<br />
- Get Elevation from single point<br />
- Get Elevation from a path<br />
- Path will automatically allocate 100 points (really high-definition of elevation profiles!)<br />
- Export cross-sectional chart in PDF<br />
- Export cross-sectional chart in PNG<br />
- Export raw data in CSV format<br />
- Export the path in KML<br />
- Single-click to export all formats<br />
- Indicator to match the side view and the top view<br />
- Retina display compatible<br />
- Customized UI for NEW iPad<br />
- Multi-touch in the chart screen<br />
- Current Location On/Off<br />
- Draggable Waypoints (Adjust the path later)<br />
- Instant calculation of the distance<br />
- State of art intuitive path draw tool<br />
- Universal binary works both iPhone and iPad.<br />
- Unlimited Undo / Redo<br />
- Convenient &#8220;Clear All&#8221; button to reset<br />
- Navigation Mode (Lock the screen to browse)<br />
- Search location to zoom the target location quickly</p>
<p>[Usage]<br />
- As a <strong>bike / running route builder</strong>: It&#8217;s convenient to research your bike road profile in order to figure out the schematics of hills.</p>
<p>- <strong>Mobile Learning Experience in the Classroom</strong>. If you are teaching Geology or Earth Science, you might have a handout to build a cross-sectional elevation chart from a contour map, and you can let students to verify their answer by themselves. Don&#8217;t forget, Geo Elevation will provide infinite locations to investigate! The usage is unlimited.</p>
<p>- Possible flood area investigation: Before storm surge or high tide hit your town, verify locations or road that could be flooded. Draw the path from your house to the nearest shoreline to see the vertical profile.</p>
<p>- Plan your Walk or Run: If you host a walk or run event, Geo Elevation will help you to find out the slope so that you can map challenging hill in your event. Additionally, it might help you to setup multiple routs depend of the slope.</p>
<p>- For hiker and mountaineers (send us your review if you used for your activities!)</p>
<p>Add your feedback in comments or send us email to iphone [-at-] objectgraph.com.</p>
<p>We would like to hear more user experiences! How did you use it? What did you use it for? Is there anything to improve?</p>
<p>&nbsp;</p>
<p><a href="http://blog.objectgraph.com/wp-content/uploads/2012/03/ios_2.png"><img class="alignnone size-large wp-image-2546" title="Geo Elevation with Mt. St. Helens" src="http://blog.objectgraph.com/wp-content/uploads/2012/03/ios_2-550x412.png" alt="" width="550" height="412" /></a></p>
<p><a href="http://blog.objectgraph.com/wp-content/uploads/2012/03/bike_path2.png"><img class="alignnone size-large wp-image-2563" title="Bike Path" src="http://blog.objectgraph.com/wp-content/uploads/2012/03/bike_path2-366x550.png" alt="" width="366" height="550" /></a></p>
<p>Bike Path Builder!</p>
<p><a href="http://itunes.apple.com/us/app/geo-elevation-map-elevation/id509924746?mt=8"><img class="alignnone size-full wp-image-159" title="App Store Download" src="http://blog.objectgraph.com/wp-content/uploads/2008/10/appstore.png" alt="" width="190" height="62" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectgraph.com/index.php/2012/03/25/geo-elevation-app-for-iphone-and-ipad/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Android Development: JavaScript Bridge Example &#8211; Fully Explained!</title>
		<link>http://blog.objectgraph.com/index.php/2012/03/16/android-development-javascript-bridge-example-fully-explained/</link>
		<comments>http://blog.objectgraph.com/index.php/2012/03/16/android-development-javascript-bridge-example-fully-explained/#comments</comments>
		<pubDate>Fri, 16 Mar 2012 15:02:52 +0000</pubDate>
		<dc:creator>kiichi</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[callback]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[webview]]></category>

		<guid isPermaLink="false">http://blog.objectgraph.com/?p=2500</guid>
		<description><![CDATA[In this smartphone generation, we expected have a full browser functionality in API; iOS SDK is coming with UIWebView and Android has WebView. This means, developer is able to take advantage the core engine, such as JavaScript parser. This might make developer&#8217;s life easier sometime because we can reuse same libraries from JavaScript &#8211; e.g [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.objectgraph.com/wp-content/uploads/2012/03/android_javascript_bridge_sample.png"><img class=" wp-image-2503 alignleft" title="android_javascript_bridge_sample" src="http://blog.objectgraph.com/wp-content/uploads/2012/03/android_javascript_bridge_sample-168x300.png" alt="" width="134" height="240" /></a></p>
<p>In this smartphone generation, we expected have a full browser functionality in API; iOS SDK is coming with UIWebView and Android has WebView.</p>
<p>This means, developer is able to take advantage the core engine, such as JavaScript parser. This might make developer&#8217;s life easier sometime because we can reuse same libraries from JavaScript &#8211; e.g form + validations, drawing chart and so on.</p>
<p>I looked around android documentations, StackOverflow and some forums but I could not find a good summary and organized complete example.<br />
Here, I demonstrate my experiment of a full cycle of JavaScript / Java function calls from both sides.<br />
<br/><br/><br/><br/></p>
<h4>Setup</h4>
<p><strong>1. Add WebView in your layout, and add HTML file in asset folder.<br />
</strong></p>
<div class="wp_syntax">
<div class="code">
<pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;WebView</span> <span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/myWebView&quot;</span></span>
<span style="color: #009900;">         <span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span>
<span style="color: #009900;">         <span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/WebView<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre>
</div>
</div>
<p>2. Create a JavaScriptHandler class which has a reference to parent activity.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> JavaScriptHandler <span style="color: #009900;">&#123;</span>
    MyActivity parentActivity<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">public</span> JavaScriptHandler<span style="color: #009900;">&#40;</span>MyActivity activity<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        parentActivity <span style="color: #339933;">=</span> activity<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setResult<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> val<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">parentActivity</span>.<span style="color: #006633;">javascriptCallFinished</span><span style="color: #009900;">&#40;</span>val<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> calcSomething<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> x, <span style="color: #000066; font-weight: bold;">int</span> y<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">parentActivity</span>.<span style="color: #006633;">changeText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Result is : &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>x <span style="color: #339933;">*</span> y<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></pre>
</div>
</div>
<p>3. Load HTML and JavaScript in the Activity class and add the JavaScriptHandler class above.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java" style="font-family:monospace;">myWebView <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>WebView<span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">findViewById</span><span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">myWebView</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
myWebView.<span style="color: #006633;">getSettings</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setJavaScriptEnabled</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>
myWebView.<span style="color: #006633;">addJavascriptInterface</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> JavaScriptHandler<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>, <span style="color: #0000ff;">&quot;MyHandler&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
myWebView.<span style="color: #006633;">loadUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;file:///android_asset/index.html&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
</div>
</div>
<p>4. Now, it&#8217;s ready to call from both side.</p>
<p>A) Call JavaScript from Java<br />
In step 3, we added the handler in the WebView, and &#8220;MyHandler&#8221; would be the object that you can call in the html as below:</p>
<div class="wp_syntax">
<div class="code">
<pre class="java" style="font-family:monospace;">window.<span style="color: #006633;">MyHandler</span>.<span style="color: #006633;">myfunction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
</div>
</div>
<p>B) Call JavaScript from Java</p>
<p>On the other hand, if you need to call JavaScript from Java side, we use loadUrl with javascript keyword as below:</p>
<div class="wp_syntax">
<div class="code">
<pre class="java" style="font-family:monospace;">myWebView.<span style="color: #006633;">loadUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;javascript:myjavascriptfunc()&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
</div>
</div>
<p>or you can directly manipulate something like:</p>
<div class="wp_syntax">
<div class="code">
<pre class="java" style="font-family:monospace;">myWebView.<span style="color: #006633;">loadUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;javascript:document.getElementById('test1').innerHTML = '&amp;lt;strong&amp;gt;&quot;</span><span style="color: #339933;">+</span>someText<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;&amp;lt;/strong&amp;gt;'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
</div>
</div>
<p>So how about the full cycle? What if I want to call JavaScript function from Java, then I would get the result back from the process?</p>
<p>Here is important key point: loadUrl function is asynchronous call. Let&#8217;s say, your Java function wants to call a JavaScript function via loadUrl.<br />
However, loadUrl dispatch the thread and you need to let WebView call your handler&#8217;s function inside. So let&#8217;s create two functions: call and finished.</p>
<p><em>Calling JavaScript</em></p>
<div class="wp_syntax">
<div class="code">
<pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> callJavaScriptFunctionAndGetResultBack<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> val1, <span style="color: #000066; font-weight: bold;">int</span> val2<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    myWebView.<span style="color: #006633;">loadUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;javascript:window.MyHandler.setResult( addSomething(&quot;</span><span style="color: #339933;">+</span>val1<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">+</span>val2<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;) )&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p><em>Catching when the JavaScript call finished</em></p>
<div class="wp_syntax">
<div class="code">
<pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> javascriptCallFinished<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> val<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    Toast.<span style="color: #006633;">makeText</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, <span style="color: #0000ff;">&quot;Callback got val: &quot;</span> <span style="color: #339933;">+</span> val, <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p>In this example, I&#8217;m passing two integer values in the first call function. In the argument, it&#8217;ll call addSomething() JavaScript function, and then<br />
it places the result back by calling MyHandler&#8217;s function, which is an interface object, in order to call Java function over there. Let&#8217;s come back to<br />
Java side. In Java side, since we get reference from the parent Activity class, we just call one of member functions.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> JavaScriptHandler <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">//....</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setResult<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> val<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">parentActivity</span>.<span style="color: #006633;">javascriptCallFinished</span><span style="color: #009900;">&#40;</span>val<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//....</span></pre>
</div>
</div>
<p>Here is the function to be called in Activity.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> javascriptCallFinished<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> val<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     Log.<span style="color: #006633;">v</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;mylog&quot;</span>,<span style="color: #0000ff;">&quot;MyActivity.javascriptCallFinished is called : &quot;</span> <span style="color: #339933;">+</span> val<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p>&#8230; however this would not give a good result when you write a real app because you often put the value back to UI which need to be run in the main thread!</p>
<p>So use a runOnUiThread (such a nice name). If you need to pass something, you must add final keyword, which allows the variable to be used inline Runnable class.</p>
<p>Finally, the &#8220;Finished&#8221; function will be look like this:</p>
<div class="wp_syntax">
<div class="code">
<pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> javascriptCallFinished<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> val<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    Log.<span style="color: #006633;">v</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;mylog&quot;</span>,<span style="color: #0000ff;">&quot;MyActivity.javascriptCallFinished is called : &quot;</span> <span style="color: #339933;">+</span> val<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// I need to run set operation of UI on the main thread.</span>
    <span style="color: #666666; font-style: italic;">// therefore, the above parameter &quot;val&quot; must be final</span>
    runOnUiThread<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Runnable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> run<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            myResult.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Callback got val: &quot;</span> <span style="color: #339933;">+</span> val<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;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p>Below is the diagram how it goes from Java to JavaScript and from JavaScript to Java.</p>
<p><a href="http://blog.objectgraph.com/wp-content/uploads/2012/03/AndroidJavaScriptBridgeDrawing2.png"><img src="http://blog.objectgraph.com/wp-content/uploads/2012/03/AndroidJavaScriptBridgeDrawing2-550x412.png" alt="" title="AndroidJavaScriptBridgeDrawing2" width="550" height="412" class="alignnone size-large wp-image-2535" /></a><br />
That&#8217;s it! This could be confusing in the first look, so please download the sample code. The project is created with IntelliJ and this is 100 times better IDE than eclipse.</p>
<h4>Download</h4>
<p><a href="https://github.com/kiichi/AndroidJavasScript">https://github.com/kiichi/AndroidJavasScript</a></p>
<h4>Demo</h4>
<p><iframe src="http://player.vimeo.com/video/38637562?title=0&amp;byline=0&amp;portrait=0" width="400" height="225" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></p>
<h4>Reference</h4>
<p>Most of information were published on those documentation pages:</p>
<p>http://developer.android.com/guide/webapps/webview.html</p>
<p>http://developer.android.com/resources/articles/using-webviews.html</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectgraph.com/index.php/2012/03/16/android-development-javascript-bridge-example-fully-explained/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rectangles Puzzle App For Android Released</title>
		<link>http://blog.objectgraph.com/index.php/2012/02/28/rectangles-puzzle-app-for-android-released/</link>
		<comments>http://blog.objectgraph.com/index.php/2012/02/28/rectangles-puzzle-app-for-android-released/#comments</comments>
		<pubDate>Tue, 28 Feb 2012 03:54:06 +0000</pubDate>
		<dc:creator>gavi</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[irectangles]]></category>
		<category><![CDATA[puzzle]]></category>
		<category><![CDATA[puzzle game]]></category>

		<guid isPermaLink="false">http://blog.objectgraph.com/?p=2473</guid>
		<description><![CDATA[We launch  Rectangles App for Android.]]></description>
			<content:encoded><![CDATA[<p>You might have read my previous <a href="http://blog.objectgraph.com/index.php/2011/12/30/intellij-android-like/" title="Article">article</a> about IntelliJ helping me get me back in Android development, Here is the output of that initiative.</p>
<p>I am pleased to announce Android version of our popular iRectangles puzzle for iOS. </p>
<p>You can download it <a href="https://market.android.com/details?id=com.objectgraph.rectangles">here</a> for Free.</p>
<p><a href="https://market.android.com/details?id=com.objectgraph.rectangles"><img src="http://blog.objectgraph.com/wp-content/uploads/2011/07/android-market-icon.gif"></a></p>
<p>For people who might not know.. Rectangles is the next generation of puzzle game from the same inventor of Sudoku!<br />
The objective of the game is to create rectangles that fill the entire board. Each of the rectangle should correspond to the number of cells posted.<br />
You can select the cells to create a rectangle by simply dragging your finger on the board. To deselect just double tap on the selected cells.</p>
<p><a href="http://blog.objectgraph.com/wp-content/uploads/2012/02/Feature.png"><img src="http://blog.objectgraph.com/wp-content/uploads/2012/02/Feature-550x268.png" alt="" title="Feature" width="550" height="268" class="alignnone size-large wp-image-2474" /></a></p>
<p>Video</p>
<p><iframe width="640" height="480" src="http://www.youtube.com/embed/dtTBxuwoaaU" frameborder="0" allowfullscreen></iframe><br />
<a href="https://market.android.com/details?id=com.objectgraph.rectangles"><img src="http://blog.objectgraph.com/wp-content/uploads/2011/07/android-market-icon.gif"></a></p>
<p>Additional Screenshots</p>
<p><a href='http://blog.objectgraph.com/index.php/2012/02/28/rectangles-puzzle-app-for-android-released/feature/' title='Feature'><img width="150" height="150" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/Feature-150x150.png" class="attachment-thumbnail" alt="Feature" title="Feature" /></a><br />
<a href='http://blog.objectgraph.com/index.php/2012/02/28/rectangles-puzzle-app-for-android-released/large_icon_114x114/' title='large_icon_114x114'><img width="114" height="114" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/large_icon_114x114.png" class="attachment-thumbnail" alt="large_icon_114x114" title="large_icon_114x114" /></a><br />
<a href='http://blog.objectgraph.com/index.php/2012/02/28/rectangles-puzzle-app-for-android-released/screenshot_2012-02-27-19-15-55/' title='Screenshot_2012-02-27-19-15-55'><img width="150" height="150" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/Screenshot_2012-02-27-19-15-55-150x150.png" class="attachment-thumbnail" alt="Screenshot_2012-02-27-19-15-55" title="Screenshot_2012-02-27-19-15-55" /></a><br />
<a href='http://blog.objectgraph.com/index.php/2012/02/28/rectangles-puzzle-app-for-android-released/screenshot_2012-02-27-19-15-59/' title='Screenshot_2012-02-27-19-15-59'><img width="150" height="150" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/Screenshot_2012-02-27-19-15-59-150x150.png" class="attachment-thumbnail" alt="Screenshot_2012-02-27-19-15-59" title="Screenshot_2012-02-27-19-15-59" /></a><br />
<a href='http://blog.objectgraph.com/index.php/2012/02/28/rectangles-puzzle-app-for-android-released/screenshot_2012-02-27-19-11-08/' title='Screenshot_2012-02-27-19-11-08'><img width="150" height="150" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/Screenshot_2012-02-27-19-11-08-150x150.png" class="attachment-thumbnail" alt="Screenshot_2012-02-27-19-11-08" title="Screenshot_2012-02-27-19-11-08" /></a><br />
<a href='http://blog.objectgraph.com/index.php/2012/02/28/rectangles-puzzle-app-for-android-released/screenshot_2012-02-27-19-03-18/' title='Screenshot_2012-02-27-19-03-18'><img width="150" height="150" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/Screenshot_2012-02-27-19-03-18-150x150.png" class="attachment-thumbnail" alt="Screenshot_2012-02-27-19-03-18" title="Screenshot_2012-02-27-19-03-18" /></a><br />
<a href='http://blog.objectgraph.com/index.php/2012/02/28/rectangles-puzzle-app-for-android-released/screenshot_2012-02-27-19-03-22/' title='Screenshot_2012-02-27-19-03-22'><img width="150" height="150" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/Screenshot_2012-02-27-19-03-22-150x150.png" class="attachment-thumbnail" alt="Screenshot_2012-02-27-19-03-22" title="Screenshot_2012-02-27-19-03-22" /></a><br />
<a href='http://blog.objectgraph.com/index.php/2012/02/28/rectangles-puzzle-app-for-android-released/screenshot_2012-02-27-19-03-47/' title='Screenshot_2012-02-27-19-03-47'><img width="150" height="150" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/Screenshot_2012-02-27-19-03-47-150x150.png" class="attachment-thumbnail" alt="Screenshot_2012-02-27-19-03-47" title="Screenshot_2012-02-27-19-03-47" /></a><br />
<a href='http://blog.objectgraph.com/index.php/2012/02/28/rectangles-puzzle-app-for-android-released/screenshot_2012-02-27-19-04-00/' title='Screenshot_2012-02-27-19-04-00'><img width="150" height="150" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/Screenshot_2012-02-27-19-04-00-150x150.png" class="attachment-thumbnail" alt="Screenshot_2012-02-27-19-04-00" title="Screenshot_2012-02-27-19-04-00" /></a><br />
<a href='http://blog.objectgraph.com/index.php/2012/02/28/rectangles-puzzle-app-for-android-released/screenshot_2012-02-27-19-07-58/' title='Screenshot_2012-02-27-19-07-58'><img width="150" height="150" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/Screenshot_2012-02-27-19-07-58-150x150.png" class="attachment-thumbnail" alt="Screenshot_2012-02-27-19-07-58" title="Screenshot_2012-02-27-19-07-58" /></a><br />
<a href='http://blog.objectgraph.com/index.php/2012/02/28/rectangles-puzzle-app-for-android-released/screenshot_2012-02-27-19-08-04/' title='Screenshot_2012-02-27-19-08-04'><img width="150" height="150" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/Screenshot_2012-02-27-19-08-04-150x150.png" class="attachment-thumbnail" alt="Screenshot_2012-02-27-19-08-04" title="Screenshot_2012-02-27-19-08-04" /></a><br />
<a href='http://blog.objectgraph.com/index.php/2012/02/28/rectangles-puzzle-app-for-android-released/screenshot_2012-02-27-19-08-11/' title='Screenshot_2012-02-27-19-08-11'><img width="150" height="150" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/Screenshot_2012-02-27-19-08-11-150x150.png" class="attachment-thumbnail" alt="Screenshot_2012-02-27-19-08-11" title="Screenshot_2012-02-27-19-08-11" /></a><br />
<a href='http://blog.objectgraph.com/index.php/2012/02/28/rectangles-puzzle-app-for-android-released/screenshot_2012-02-27-19-08-16/' title='Screenshot_2012-02-27-19-08-16'><img width="150" height="150" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/Screenshot_2012-02-27-19-08-16-150x150.png" class="attachment-thumbnail" alt="Screenshot_2012-02-27-19-08-16" title="Screenshot_2012-02-27-19-08-16" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectgraph.com/index.php/2012/02/28/rectangles-puzzle-app-for-android-released/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[Review] WiPry &#8211; Mesure WiFi Signals (iPhone Accessory)</title>
		<link>http://blog.objectgraph.com/index.php/2012/02/20/review-wipry-mesure-wifi-signals-iphone-accessory/</link>
		<comments>http://blog.objectgraph.com/index.php/2012/02/20/review-wipry-mesure-wifi-signals-iphone-accessory/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 01:17:46 +0000</pubDate>
		<dc:creator>kiichi</dc:creator>
				<category><![CDATA[apple]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[iphone development]]></category>
		<category><![CDATA[802.11]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[iOS5]]></category>
		<category><![CDATA[private framework]]></category>
		<category><![CDATA[wifi]]></category>
		<category><![CDATA[wifimanager]]></category>
		<category><![CDATA[wipry]]></category>

		<guid isPermaLink="false">http://blog.objectgraph.com/?p=2406</guid>
		<description><![CDATA[Have you ever wonder how the WiFi signals look like? I would like to introduce WiPry, which is a neat iPhone accessory and it allows users to visualize various WiFi channels around you. The device costs only $99 and the installation process is extremely simple. Hook up the little black antenna into your iPhone, then [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever wonder how the WiFi signals look like? I would like to introduce <a href="http://www.oscium.com/products/wipry-spectrum-spectrum-analyzer">WiPry</a>, which is a neat iPhone accessory and it allows users to visualize various WiFi channels around you.</p>
<p><img class="alignnone size-medium wp-image-2450" title="Screen Shot 2012-02-06 at 11.08.27 AM" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-06-at-11.08.27-AM-300x224.png" alt="" width="300" height="224" /></p>
<p>The device costs only $99 and the installation process is extremely simple. Hook up the little black antenna into your iPhone, then wait for 1 second for LED on. If you did not install Free WiPry app before, it will automatically ask you to download  the app for you.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-medium wp-image-2451" title="Screen Shot 2012-02-06 at 11.08.35 AM" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-06-at-11.08.35-AM-219x300.png" alt="" width="219" height="300" /></p>
<p>&nbsp;</p>
<p><img class="alignnone size-medium wp-image-2452" title="Screen Shot 2012-02-06 at 11.08.41 AM" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-06-at-11.08.41-AM-220x300.png" alt="" width="220" height="300" /></p>
<p>&nbsp;</p>
<p><img class="alignnone size-medium wp-image-2453" title="Screen Shot 2012-02-06 at 11.08.48 AM" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-06-at-11.08.48-AM-300x190.png" alt="" width="300" height="190" /></p>
<p>The main screen looks like a heat map, which active channels are represented as red-yellow spikes. Press the icon to toggle different channels and use your finger to drag across all channels. For example, if you are operating your WiFi router on channel 6, scrub the frame to the middle of screen. You will see some &#8220;hot area&#8221; within the range.</p>
<p><img class="alignnone size-medium wp-image-2454" title="Screen Shot 2012-02-06 at 11.08.57 AM" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-06-at-11.08.57-AM-300x199.png" alt="" width="300" height="199" /></p>
<p>This is the example of channel 1 signals in my work environment.</p>
<p><img class="alignnone size-medium wp-image-2455" title="Screen Shot 2012-02-06 at 11.09.10 AM" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-06-at-11.09.10-AM-300x196.png" alt="" width="300" height="196" /></p>
<p>Other channels like 10 or 11 dominates in this screenshot.</p>
<p><img class="alignnone size-medium wp-image-2456" title="Screen Shot 2012-02-06 at 11.09.17 AM" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-06-at-11.09.17-AM-300x199.png" alt="" width="300" height="199" /></p>
<p>Select your channels to investigate.</p>
<p>&nbsp;</p>
<p>The reason that I started looking for WiFi signal scanners is because iOS5 completely hide the <strong>Apples 802.11 WiFi manager</strong> framework, even it&#8217;s for private API usage. Our academic project, <a href="http://geo.objectgraph.com/2011/10/27/wifi-mapping-project-with-ipad-at-long-island-university/">WiFi Mapping</a>, used to use the functionality but it&#8217;s not available anymore. I start exploring different data collecting methods outside of iOS native, such as accessories, Android or Windows Phone.</p>
<p>As far as I see the current version of WiPry, I could not find SSID information along the signal strength. This could be the same restriction from Apple for those semiconductor companies (just like I experienced in above example&#8230;). Basically, Apple is not happy to give features that developers or manufactures are able to build a WiFi scanner app / device.</p>
<p>WiPry could be useful to analyze conflicted channels for network engineer; however, I could not use it for my WiFi mapper app due to lack of SSID information. I show this to folks in our network team and they show me some interests to purchase this device. The response on the screen is real-time and the user is expected to have some kind of special knowledge about WiFi. I would like to hear from real network engineers&#8217; opinion. Please leave comments if you have any thoughts.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectgraph.com/index.php/2012/02/20/review-wipry-mesure-wifi-signals-iphone-accessory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Review] Printer Server for iPad / iPhone &#8211; Lantronix</title>
		<link>http://blog.objectgraph.com/index.php/2012/02/07/review-printer-server-for-ipad-iphone-lantronix/</link>
		<comments>http://blog.objectgraph.com/index.php/2012/02/07/review-printer-server-for-ipad-iphone-lantronix/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 12:35:14 +0000</pubDate>
		<dc:creator>soe</dc:creator>
				<category><![CDATA[misc]]></category>
		<category><![CDATA[air print]]></category>
		<category><![CDATA[lantronix]]></category>
		<category><![CDATA[print server]]></category>
		<category><![CDATA[printer]]></category>
		<category><![CDATA[wifi]]></category>

		<guid isPermaLink="false">http://blog.objectgraph.com/?p=2395</guid>
		<description><![CDATA[Today I&#8217;d like to introduce a very easy to use device which connect the gap between network printers and iOS devices. Lantronix xPrintServer is a device that can easily convert all your network printers into wifi enable air printers. Let&#8217;s open the box: Lantronix xPrintServer &#160; Size: LxWxH 4.50&#8243; x 2.37&#8243; x .87&#8243;, Weight:.27 Kg/0.6 [...]]]></description>
			<content:encoded><![CDATA[<p>Today I&#8217;d like to introduce a very easy to use device which connect the gap between network printers and iOS devices. Lantronix xPrintServer is a device that can easily convert all your network printers into wifi enable air printers.<br />
Let&#8217;s open the box:</p>
<p><a href="http://blog.objectgraph.com/wp-content/uploads/2012/02/20120207-073421.jpg"><img class="alignnone size-full" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/20120207-073421.jpg" alt="20120207-073421.jpg" /></a><br />
<strong>Lantronix xPrintServer</strong></p>
<p>&nbsp;</p>
<p><a href="http://blog.objectgraph.com/wp-content/uploads/2012/02/20120207-073430.jpg"><img class="alignnone size-full" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/20120207-073430.jpg" alt="20120207-073430.jpg" /></a><br />
<strong>Size: LxWxH 4.50&#8243; x 2.37&#8243; x .87&#8243;, </strong></p>
<p><strong>Weight:.27 Kg/0.6 pounds </strong><strong>(xPrintServer device + power supply)</strong></p>
<p>&nbsp;</p>
<p><a href="http://blog.objectgraph.com/wp-content/uploads/2012/02/20120207-073437.jpg"><img class="alignnone size-full" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/20120207-073437.jpg" alt="20120207-073437.jpg" /></a><br />
<strong>Ethernet and power connections</strong></p>
<p>&nbsp;</p>
<p><a href="http://blog.objectgraph.com/wp-content/uploads/2012/02/20120207-073443.jpg"><img class="alignnone size-full" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/20120207-073443.jpg" alt="20120207-073443.jpg" /></a><br />
<strong>Power Adapter</strong></p>
<p>&nbsp;</p>
<p>Set up is very simple and straight forward. There&#8217;s no need to download any software or driver. You just need to connect the device to your network (router, switch, etc.) by using ethernet cable. The device will automatically discover all your network printers. Now all you need to do is connect your iPhone or iPad to the network via wifi, select the printer and print the documents.</p>
<ul>
<li><strong>Connect Lantronix xPrintServer to your network and power adapter</strong></li>
<li><strong>Open your idevices to the same network via wifi</strong></li>
<li><strong>Choose what you want to print, select print and select your printer</strong></li>
</ul>
<p><a href="http://blog.objectgraph.com/index.php/2012/02/07/review-printer-server-for-ipad-iphone-lantronix/xprinterserver_printerselection/" rel="attachment wp-att-2438"><img class="alignnone size-medium wp-image-2438" title="xprinterserver_printerselection" src="http://blog.objectgraph.com/wp-content/uploads/2012/02/xprinterserver_printerselection-300x279.png" alt="" width="300" height="279" /></a></p>
<p>&nbsp;</p>
<p>You can get more details at their website: <a href="http://www.lantronix.com/it-management/mobile-print-servers/xprintserver.html">lantronix.com</a></p>
<p>You can grab one for $149.95 <a href="http://store.lantronix.com/product_p/xps1001ne-01.htm">Here</a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectgraph.com/index.php/2012/02/07/review-printer-server-for-ipad-iphone-lantronix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Geo Measure Now Available In Japanese</title>
		<link>http://blog.objectgraph.com/index.php/2012/02/02/geo-measure-now-available-in-japanese/</link>
		<comments>http://blog.objectgraph.com/index.php/2012/02/02/geo-measure-now-available-in-japanese/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 01:32:47 +0000</pubDate>
		<dc:creator>gavi</dc:creator>
				<category><![CDATA[Geo]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[area distance measurement]]></category>
		<category><![CDATA[geomeasure]]></category>

		<guid isPermaLink="false">http://blog.objectgraph.com/?p=2383</guid>
		<description><![CDATA[I am happy to report the availability of a new version of Geo Measure localized for Japanese language. We hope to release other languages based on demand. We also added a new measure for area (Tsubo) Here are some screenshots from Japanese version: Also the iPad version has also been localized for Japan Download the [...]]]></description>
			<content:encoded><![CDATA[<p>I am happy to report the availability of a new version of Geo Measure localized for Japanese language. We hope to release other languages based on demand.</p>
<p>We also added a new measure for area (<a href="http://en.wikipedia.org/wiki/Japanese_units_of_measurement#Area">Tsubo</a>)</p>
<p>Here are some screenshots from Japanese version:</p>
<table>
<tr>
<td>
<img src="http://blog.objectgraph.com/wp-content/uploads/2012/02/ss1.png" alt="" title="ss1" width="180" />
</td>
<td>
<img src="http://blog.objectgraph.com/wp-content/uploads/2012/02/ss2.png" alt="" title="ss1" width="180" />
</td>
<td>
<img src="http://blog.objectgraph.com/wp-content/uploads/2012/02/ss3.png" alt="" title="ss1" width="180" />
</td>
</tr>
</table>
<p>Also the iPad version has also been localized for Japan</p>
<p>Download the Version 1.1 from the app store.</p>
<p><a href="http://itunes.apple.com/us/app/geo-measure-map-area-distance/id451326903?mt=8"><img src="http://www.iappphone.com/static/plain/images/appstore.png"/></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectgraph.com/index.php/2012/02/02/geo-measure-now-available-in-japanese/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Android Development: How to use sqlite in Android</title>
		<link>http://blog.objectgraph.com/index.php/2012/01/28/how-to-use-sqlite-in-android/</link>
		<comments>http://blog.objectgraph.com/index.php/2012/01/28/how-to-use-sqlite-in-android/#comments</comments>
		<pubDate>Sat, 28 Jan 2012 00:47:43 +0000</pubDate>
		<dc:creator>kiichi</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[cursor]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[execSQL]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[sqlite]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.objectgraph.com/?p=2368</guid>
		<description><![CDATA[One of nice part of Android is sqlite data access is very simple. You don't worry about the path to the sqlite database file and there are a couple of functions to make your file easier.]]></description>
			<content:encoded><![CDATA[<p>One of nice part of Android is sqlite data access is very simple. You don&#8217;t worry about the path to the sqlite database file and there are a couple of functions to make your file easier.</p>
<p><strong>Creating DB</strong></p>
<div class="wp_syntax">
<div class="code">
<pre class="java" style="font-family:monospace;">SQLiteDatabase db <span style="color: #339933;">=</span> openOrCreateDatabase<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;mydb&quot;</span>,MODE_PRIVATE,<span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
</div>
</div>
<p>This is a neat function which does open and create at the same time. You need to name your database (e.g. &#8220;mydb&#8221;) and specify the mode to open. In this example, I&#8217;m opening the database as private mode that allows only your app to touch the file.</p>
<p><strong>Execute SQL</strong></p>
<div class="wp_syntax">
<table>
<tr>
<td class="line_numbers">
<pre>1
2
</pre>
</td>
<td class="code">
<pre class="java" style="font-family:monospace;">db.<span style="color: #006633;">execSQL</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;CREATE TABLE IF NOT EXISTS mydata (first_name,last_name,age)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
db.<span style="color: #006633;">execSQL</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INSERT INTO mydata (first_name,last_name,age) VALUES('Jon','Doe',20)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
</td>
</tr>
</table>
</div>
<p>Since it&#8217;s already opened, executing CRUID operation is available via execSQL function.</p>
<p><strong>Query data</strong></p>
<div class="wp_syntax">
<table>
<tr>
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
</pre>
</td>
<td class="code">
<pre class="java" style="font-family:monospace;"><span style="color: #003399;">Cursor</span> cursor <span style="color: #339933;">=</span> db.<span style="color: #006633;">rawQuery</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM mydata ORDER BY age&quot;</span>,<span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>cursor.<span style="color: #006633;">moveToFirst</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #009900;">&#123;</span>
       Log.<span style="color: #006633;">v</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;mylog&quot;</span>, cursor.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;,&quot;</span> <span style="color: #339933;">+</span> cursor.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;,&quot;</span> <span style="color: #339933;">+</span> cursor.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>cursor.<span style="color: #006633;">moveToNext</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></pre>
</td>
</tr>
</table>
</div>
<p>To query data, you need two steps:</p>
<p>1. Create a cursor from the result of your select statement<br />
2. Move the cursor and retrieve data via get&#8230; functions. </p>
<p>I often make a mistake to retrieve data from the cursor without calling <strong>moveToFirst() </strong>function. Let&#8217;s call it first and this returns if there is a row to return or not. After moving to the first row, keep calling <strong>moveToNext()</strong> function until you reach the end of rows.</p>
<p><strong>Closing</strong></p>
<div class="wp_syntax">
<table>
<tr>
<td class="line_numbers">
<pre>1
2
</pre>
</td>
<td class="code">
<pre class="java" style="font-family:monospace;">cursor.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
db.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
</td>
</tr>
</table>
</div>
<p>Let&#8217;s make sure to close all connection to db. Avoid unnecessary memory usage.</p>
<p>That&#8217;s it. If you want to see a sample project (created by IntelliJ), please click <a href="https://github.com/kiichi/AndroidSQLiteTest/">here</a>. You can browse the entire source code from <a href="https://github.com/kiichi/AndroidSQLiteTest/blob/master/src/com/objectgraph/MyActivity.java">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectgraph.com/index.php/2012/01/28/how-to-use-sqlite-in-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Happy Chinese New Year. iPhone Feng Shui Updated for Year of the Dragon &#8211; 2012!</title>
		<link>http://blog.objectgraph.com/index.php/2012/01/24/happy-chinese-new-year-iphone-feng-shui-updated-for-year-of-the-dragon-2012/</link>
		<comments>http://blog.objectgraph.com/index.php/2012/01/24/happy-chinese-new-year-iphone-feng-shui-updated-for-year-of-the-dragon-2012/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 08:20:28 +0000</pubDate>
		<dc:creator>gavi</dc:creator>
				<category><![CDATA[FengShui]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[chinese astrology]]></category>
		<category><![CDATA[Chinese New Year]]></category>
		<category><![CDATA[feng shui]]></category>
		<category><![CDATA[fengshui]]></category>
		<category><![CDATA[year of the dragon]]></category>

		<guid isPermaLink="false">http://blog.objectgraph.com/?p=2344</guid>
		<description><![CDATA[Happy New Year! Check your forecast with our updated FengShui app 2012 Edition. Year of the Dragon Gong Yi Fa Cai 恭喜發財! In 2012, the Chinese New Year falls on January 23rd in China, which occurs before the official solar start of the year on February 4th, known as Li Chun 立春 or Spring Begins. [...]]]></description>
			<content:encoded><![CDATA[<p>Happy New Year!</p>
<p>Check your forecast with our updated FengShui app 2012 Edition. </p>
<p><a href="http://itunes.apple.com/us/app/feng-shui-chinese-astrology/id418671201?mt=8" target="_blank"><img src="http://www.iappphone.com/static/plain/images/appstore.png"/></a></p>
<p>Year of the Dragon</p>
<p>Gong Yi Fa Cai 恭喜發財! In 2012, the Chinese New Year falls on January 23rd in<br />
China, which occurs before the official solar start of the year on February 4th, known as Li Chun 立春 or Spring Begins. It is a powerful and dangerous year that starts fluidly; be sure to act smart and move fast. The calendar of this year is very complicated because the first new moon after the Winter Solstice on December 21, 2011 is December 23, 2012, followed by the second new moon and start of the lunar New Year, January 23, 2012 (January 22nd<br />
in Asia). This tight start indicates a “whipping” effect that will bring about strong winds and discontent. Be sure to leave the front door of your home open this evening, especially if it is facing in a beneficial direction, so that you can gather good fortune throughout the night. It is an important year to use Feng Shui, as there will be very dangerous periods during the year for which it will feel as if you are fighting for your life to survive.</p>
<p>Screenshots:</p>
<table>
<tr>
<td>
<img src="http://blog.objectgraph.com/wp-content/uploads/2012/01/Screenshot_1.png" alt="sc1" title="sc1" width="200"  class="alignnone size-full wp-image-1739" />
</td>
<td>
<img src="http://blog.objectgraph.com/wp-content/uploads/2012/01/Screenshot_2.png" alt="sc1" title="sc1" width="200" class="alignnone size-full wp-image-1739" />
</td>
</tr>
<tr>
<td>
<img src="http://blog.objectgraph.com/wp-content/uploads/2012/01/Screenshot_3.png" alt="sc3" title="sc1" width="200"  class="alignnone size-full wp-image-1739" />
</td>
<td>
<img src="http://blog.objectgraph.com/wp-content/uploads/2012/01/Screenshot_4.png" alt="sc4" title="sc1" width="200"  class="alignnone size-full wp-image-1739" />
</td>
</tr>
<tr>
<td>
<img src="http://blog.objectgraph.com/wp-content/uploads/2012/01/Screenshot_6.png" alt="sc5" title="sc1" width="200" class="alignnone size-full wp-image-1739" />
</td>
<td>
&nbsp;
</td>
</tr>
</table>
<p>You will download now!</p>
<p><a href="http://itunes.apple.com/us/app/feng-shui-chinese-astrology/id418671201?mt=8" target="_blank"><img src="http://www.iappphone.com/static/plain/images/appstore.png"/></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectgraph.com/index.php/2012/01/24/happy-chinese-new-year-iphone-feng-shui-updated-for-year-of-the-dragon-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MoPic is our new app that creates GIF animations</title>
		<link>http://blog.objectgraph.com/index.php/2012/01/12/mopic-is-our-new-app-that-creates-gif-animations/</link>
		<comments>http://blog.objectgraph.com/index.php/2012/01/12/mopic-is-our-new-app-that-creates-gif-animations/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 03:03:12 +0000</pubDate>
		<dc:creator>serge</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[effect]]></category>
		<category><![CDATA[gif]]></category>
		<category><![CDATA[motion]]></category>
		<category><![CDATA[movie]]></category>

		<guid isPermaLink="false">http://blog.objectgraph.com/?p=2312</guid>
		<description><![CDATA[We just finished our new app for camera enabled iDevices. We called it MoPic. MoPic is a free app that makes it easy to create fun GIFs and share them with your friends. Create a hilarious GIF animation of your cat in the washing machine, a donut disappearing in the mouth of your buddy as [...]]]></description>
			<content:encoded><![CDATA[<p>We just finished our new app for camera enabled iDevices.</p>
<p>We called it MoPic.</p>
<p>MoPic is a free app that makes it easy to create fun GIFs and share them with your friends.</p>
<p>Create a hilarious GIF animation of your cat in the washing machine, a donut disappearing in the mouth of your buddy as it’s being eaten, or anything else that comes to your mind. The possibilities are endless. Animations created with MoPic can easily be shared with your family and friends. Make them laugh endlessly as these GIFs replay these funny moments over and over again.</p>
<p><a href="http://itunes.apple.com/us/app/mopic-video-animation-gif/id492113893?mt=8"><img src="http://www.iappphone.com/static/plain/images/appstore.png"></a>.</p>
<p>How it works:<br />
1. Tap on “Take a Video” or “Choose from Library” buttons to select your video or single frames.<br />
2. Tap on “Done” to generate a preview of the GIF and adjust the speed<br />
3. Share it with your friends over Email, Twitter or Save it for later. (More options in upcoming updates)</p>
<p>Features:<br />
✓ Generate random GIFs based on the video you provide<br />
✓ Select frames you would like to use in your GIF animation<br />
✓ Share it with your friends.<br />
✓ Works only with 30 FPS at the moment.</p>
<table>
<tr>
<td><img src="http://blog.objectgraph.com/wp-content/uploads/2012/01/ss1-292x550.png" alt="" title="ss1" width="250" class="alignleft size-large wp-image-2326" /></td>
<td><img src="http://blog.objectgraph.com/wp-content/uploads/2012/01/ss2-292x550.png" alt="" title="ss1" width="250" class="alignleft size-large wp-image-2326" /></td>
</tr>
<tr>
<td><img src="http://blog.objectgraph.com/wp-content/uploads/2012/01/ss3-292x550.png" alt="" title="ss1" width="250" class="alignleft size-large wp-image-2326" /></td>
<td><img src="http://blog.objectgraph.com/wp-content/uploads/2012/01/ss4-292x550.png" alt="" title="ss1" width="250" class="alignleft size-large wp-image-2326" /></td>
</tr>
<tr>
<td><img src="http://blog.objectgraph.com/wp-content/uploads/2012/01/ss5-292x550.png" alt="" title="ss1" width="250" class="alignleft size-large wp-image-2326" /></td>
<td></td>
</tr>
</table>
<p>Compatible Hardware: iPhone 3GS, iPhone 4, 4th gen iPod Touch, iPad 2 (in 2x mode only)<br />
Compatible OS: iOS 4.1 and greater.</p>
<p>Please write us and feel free to give us your feedback or request new features that you would like to see in future updates.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectgraph.com/index.php/2012/01/12/mopic-is-our-new-app-that-creates-gif-animations/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>How to create a compass in iPhone</title>
		<link>http://blog.objectgraph.com/index.php/2012/01/10/how-to-create-a-compass-in-iphone/</link>
		<comments>http://blog.objectgraph.com/index.php/2012/01/10/how-to-create-a-compass-in-iphone/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 19:01:38 +0000</pubDate>
		<dc:creator>kiichi</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[FengShui]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[iphone development]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[CABasicAnimation]]></category>
		<category><![CDATA[CLLocationManager]]></category>
		<category><![CDATA[compass]]></category>
		<category><![CDATA[core animation]]></category>
		<category><![CDATA[didUpdateHeading]]></category>
		<category><![CDATA[direction]]></category>
		<category><![CDATA[location manager]]></category>
		<category><![CDATA[startUpdatingHeading]]></category>

		<guid isPermaLink="false">http://blog.objectgraph.com/?p=2194</guid>
		<description><![CDATA[A Happy New Year! I hope everyone enjoy this winter season. I want you to remember another new year holiday, which is in Chinese calendar, coming in a few weeks. We will update our Chinese Astrology and Feng Shui App with a bunch of features, such as a compass to show direction on the screen. [...]]]></description>
			<content:encoded><![CDATA[<p>A Happy New Year! I hope everyone enjoy this winter season. I want you to remember another new year holiday, which is in Chinese calendar, coming in a few weeks. We will update our <a href="http://blog.objectgraph.com/index.php/2011/02/15/chinese-astrology-and-feng-shui-app-for-iphone/">Chinese Astrology and Feng Shui App</a> with a bunch of features, such as a compass to show direction on the screen. According to our partner, Eco-Med LLC which is Feng Shui guru company, ancient Chinese people have developed complex schema to determine the layout of rooms / furnitures depend on your &#8220;lucky&#8221; direction. In 21st century, the iPhone in your pocket contains a small device, it&#8217;s called magnetrometer, helps you to solve the difficult puzzle in a quick and easy way. In this article, I would like to explain the simplest method to implement a compass in your app. This tutorial contains following items:</p>
<ul>
<li>Know how to use Location Manager</li>
<li>Convert degree to radian</li>
<li>Understanding Core Animation to rotate an image</li>
</ul>
<p><img src="http://blog.objectgraph.com/wp-content/uploads/2012/01/Screen-Shot-2012-01-02-at-3.07.19-PM-150x150.png" alt="" title="Screen-Shot-2012-01-02-at-3.07.19-PM" width="150" height="150" class="alignnone size-thumbnail wp-image-2209" /></p>
<p><strong>Step 1:</strong> Create a project (e.g. CompassExample) and include frameworks</p>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &lt;CoreLocation/CoreLocation.h&gt;</span>
<span style="color: #6e371a;">#import &lt;QuartzCore/QuartzCore.h&gt;</span></pre>
</div>
</div>
<p><img src="http://blog.objectgraph.com/wp-content/uploads/2012/01/Screen-Shot-2012-01-02-at-2.04.58-PM.png" alt="" title="Screen Shot 2012-01-02 at 2.04.58 PM" width="247" height="186" class="alignnone size-full wp-image-2210" /></p>
<p><strong>Step 2:</strong> In .h file, create Location Manager Object</p>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;">CLLocationManager <span style="color: #002200;">*</span>locationManager;</pre>
</div>
</div>
<p>Implement delegate</p>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;">&lt;CLLocationManagerDelegate&gt;</pre>
</div>
</div>
<p>Next, add parameter</p>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic,retain<span style="color: #002200;">&#41;</span> CLLocationManager <span style="color: #002200;">*</span>locationManager;</pre>
</div>
</div>
<p>&#8230; don&#8217;t forget to synthesize it in .m file.</p>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">@synthesize</span> locationManager;</pre>
</div>
</div>
<p><strong>Step 3:</strong> In .h file, create UIImageView and add reference in Interface Builder </p>
<p><img src="http://blog.objectgraph.com/wp-content/uploads/2012/01/Screen-Shot-2012-01-02-at-2.13.22-PM-300x248.png" alt="" title="Screen Shot 2012-01-02 at 2.13.22 PM" width="300" height="248" class="alignnone size-medium wp-image-2211" /></p>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;">IBOutlet UIImageView <span style="color: #002200;">*</span>compassImage;</pre>
</div>
</div>
<p><a href="https://github.com/kiichi/CompassExample/blob/master/CompassExample/compass_needle.png">Download Image from here</a></p>
<p><strong>Step 4:</strong> In .m file&#8217;s viewDidLoad function, initialize the location manager.</p>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;">	locationManager<span style="color: #002200;">=</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>CLLocationManager alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
	locationManager.desiredAccuracy <span style="color: #002200;">=</span> kCLLocationAccuracyBest;
	locationManager.headingFilter <span style="color: #002200;">=</span> <span style="color: #2400d9;">1</span>;
	locationManager.delegate<span style="color: #002200;">=</span>self;
	<span style="color: #002200;">&#91;</span>locationManager startUpdatingHeading<span style="color: #002200;">&#93;</span>;</pre>
</div>
</div>
<p><strong>Step 5:</strong> In .m file, implement delegate function.</p>
<p>First, you need to convert degree (e.g 360) to radian (e.g 3.14=2PI).<br />
Second, multiply -1 in order to rotate opposite direction that you twist your phone.<br />
Third, apply rotation with core animation function. In this example, I&#8217;m rotating from the current value to the new value. The duration is 0.5 second as you see below.</p>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>locationManager<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CLLocationManager <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>manager didUpdateHeading<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CLHeading <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>newHeading<span style="color: #002200;">&#123;</span>
	<span style="color: #11740a; font-style: italic;">// Convert Degree to Radian and move the needle</span>
	<span style="color: #a61390;">float</span> oldRad <span style="color: #002200;">=</span>  <span style="color: #002200;">-</span>manager.heading.trueHeading <span style="color: #002200;">*</span> M_PI <span style="color: #002200;">/</span> 180.0f;
	<span style="color: #a61390;">float</span> newRad <span style="color: #002200;">=</span>  <span style="color: #002200;">-</span>newHeading.trueHeading <span style="color: #002200;">*</span> M_PI <span style="color: #002200;">/</span> 180.0f;
	CABasicAnimation <span style="color: #002200;">*</span>theAnimation;
	theAnimation<span style="color: #002200;">=</span><span style="color: #002200;">&#91;</span>CABasicAnimation animationWithKeyPath<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;transform.rotation&quot;</span><span style="color: #002200;">&#93;</span>;
	theAnimation.fromValue <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithFloat<span style="color: #002200;">:</span>oldRad<span style="color: #002200;">&#93;</span>;
	theAnimation.toValue<span style="color: #002200;">=</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithFloat<span style="color: #002200;">:</span>newRad<span style="color: #002200;">&#93;</span>;
	theAnimation.duration <span style="color: #002200;">=</span> 0.5f;
	<span style="color: #002200;">&#91;</span>compassImage.layer addAnimation<span style="color: #002200;">:</span>theAnimation forKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;animateMyRotation&quot;</span><span style="color: #002200;">&#93;</span>;
	compassImage.transform <span style="color: #002200;">=</span> CGAffineTransformMakeRotation<span style="color: #002200;">&#40;</span>newRad<span style="color: #002200;">&#41;</span>;
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;%f (%f) =&gt; %f (%f)&quot;</span>, manager.heading.trueHeading, oldRad, newHeading.trueHeading, newRad<span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span></pre>
</div>
</div>
<p>That&#8217;s it! Of course, you have to deploy the app on your device to check the direction.</p>
<p><strong>Source Code:</strong></p>
<p><a href="https://github.com/kiichi/CompassExample">https://github.com/kiichi/CompassExample</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectgraph.com/index.php/2012/01/10/how-to-create-a-compass-in-iphone/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Android Development: Passing Data Between Activities</title>
		<link>http://blog.objectgraph.com/index.php/2012/01/03/android-development-passing-data-between-activities/</link>
		<comments>http://blog.objectgraph.com/index.php/2012/01/03/android-development-passing-data-between-activities/#comments</comments>
		<pubDate>Tue, 03 Jan 2012 20:57:46 +0000</pubDate>
		<dc:creator>gavi</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[activity]]></category>
		<category><![CDATA[android development]]></category>
		<category><![CDATA[data passing]]></category>

		<guid isPermaLink="false">http://blog.objectgraph.com/?p=2238</guid>
		<description><![CDATA[This article shows how to pass data between activities in Android. The main classes you would use are <code>Intent</code> and <code>Bundle</code>]]></description>
			<content:encoded><![CDATA[<p>Every thing you do in android is an instance of Activity class. The back button (mostly implemented in hardware &#8211; now also on software &#8211; Example Galaxy Tab 10.1 and ICS) allows to unload current activity and go back to previous one.</p>
<p>Lets say you are building a game and would like to pass data between your menu screen and the game screen. You show a bunch of options to the user in the menu screen and you have to pass the appropriate paramater to the Game Screen. Lets call our Activities <code>GameActivity</code> and <code>MenuActivity</code></p>
<p>Loading a different GameActivity from MenuActivity:</p>
<p>First thing you need to understand is how to load a different activity from current activity. In order to do this, we use Intent class. Here is some code.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java" style="font-family:monospace;">Intent intent<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> Intent<span style="color: #009900;">&#40;</span>view.<span style="color: #006633;">getContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,GameActivity.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
startActivity<span style="color: #009900;">&#40;</span>intent<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
</div>
</div>
<p>As you can see Intent class will load the class dynamically (reflection) and show you the new activity on the screen. Lets assume you created 3 buttons on the menu screen</p>
<p>1. Easy<br />
2. Medium<br />
3. Hard</p>
<p>You have to pass a parameter to your GameActivity which level the user wants to play. Here is some code that will accomplish it.</p>
<div class="wp_syntax">
<table>
<tr>
<td class="line_numbers">
<pre>1
2
3
4
5
</pre>
</td>
<td class="code">
<pre class="java" style="font-family:monospace;">Intent intent<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> Intent<span style="color: #009900;">&#40;</span>view.<span style="color: #006633;">getContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,GameActivity.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Bundle bundle<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> Bundle<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
bundle.<span style="color: #006633;">putString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;gameLevel&quot;</span>,<span style="color: #0000ff;">&quot;Easy&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
intent.<span style="color: #006633;">putExtras</span><span style="color: #009900;">&#40;</span>bundle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
startActivity<span style="color: #009900;">&#40;</span>intent<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
</td>
</tr>
</table>
</div>
<p>You would repeat the same code above for different Game Level selections on your MenuActivity.</p>
<p>In the Game Activity you need to retrieve the passed bundle.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java" style="font-family:monospace;">Bundle bundle<span style="color: #339933;">=</span>getIntent<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getExtras</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> level<span style="color: #339933;">=</span>bundle.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;gameLevel&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>level.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Easy&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
...
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>level.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Medium&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span>
...
<span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p><img src="http://blog.objectgraph.com/wp-content/uploads/2012/01/datapassing.png" alt="" title="datapassing" width="600" height="500" class="alignnone size-full wp-image-2251" /></p>
<p>You can pass various other types in a bundle.  Check Android documentation at <a href="http://developer.android.com/reference/android/os/Bundle.html">http://developer.android.com/reference/android/os/Bundle.html</a></p>
<p>Download Source for the sample project Below</p>
<p><a href="http://blog.objectgraph.com/wp-content/uploads/2012/01/DataPassingBetweenActivities.zip"><img src="http://blog.objectgraph.com/wp-includes/images/crystal/archive.png">Sample Project</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectgraph.com/index.php/2012/01/03/android-development-passing-data-between-activities/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Android Development: Using SoundPool instead of MediaPlayer</title>
		<link>http://blog.objectgraph.com/index.php/2012/01/02/android-development-using-soundpool-instead-of-mediaplayer/</link>
		<comments>http://blog.objectgraph.com/index.php/2012/01/02/android-development-using-soundpool-instead-of-mediaplayer/#comments</comments>
		<pubDate>Mon, 02 Jan 2012 20:41:57 +0000</pubDate>
		<dc:creator>gavi</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[MediaPlayer]]></category>
		<category><![CDATA[SoundPool]]></category>

		<guid isPermaLink="false">http://blog.objectgraph.com/?p=2079</guid>
		<description><![CDATA[We show how you can use SoundPlayer and MediaPlayer when you need to play sounds in Android.]]></description>
			<content:encoded><![CDATA[<p>I wanted to launch a simple app for Kindle Fire to test the Amazon market place for Android Apps. You can download the app <a href="http://www.amazon.com/ObjectGraph-LLC-Christmas-Sounds/dp/B006LLZ1Z6/ref=sr_1_cc_1?s=electronics&#038;ie=UTF8&#038;qid=1325539455&#038;sr=1-1-catcorr">here</a>.</p>
<p> I chose one of our simplest sounds apps for Christmas. Here is a screenshot of the same.</p>
<p><img src="http://blog.objectgraph.com/wp-content/uploads/2012/01/ss1_fire.png" alt="" title="ss1_fire" width="600" height="1024" class="alignnone size-full wp-image-2207" /></p>
<p>The top buttons play the background music and the individual icons on the shelf play simple sounds.</p>
<p>My first struggle was with the layout and making it work with various other android devices. I will write an another post for that. But with regards to playing the actual sound files there were problems also.</p>
<p>There are 2 ways of playing sounds.</p>
<p>1. MediaPlayer class<br />
2. SoundPool class</p>
<p>MediaPlayer:</p>
<p>Using media player is simple.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java" style="font-family:monospace;">MediaPlayer backgroundMusicPlayer1<span style="color: #339933;">;</span>
backgroundMusicPlayer1 <span style="color: #339933;">=</span> MediaPlayer.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, R.<span style="color: #006633;">raw</span>.<span style="color: #006633;">music1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
backgroundMusicPlayer1.<span style="color: #006633;">setLooping</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></pre>
</div>
</div>
<p>And in order to play the music, just call</p>
<div class="wp_syntax">
<div class="code">
<pre class="java" style="font-family:monospace;">backgroundMusicPlayer1.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
</div>
</div>
<p>This is fine for playing a few files, but as you keep calling <code>MediaPlayer.create(..)</code>, You will run out of memory and your app will crash. The better way to do this is using SoundPool class.</p>
<p>Instantiate SoundPool class</p>
<div class="wp_syntax">
<div class="code">
<pre class="java" style="font-family:monospace;">&nbsp;
<span style="color: #666666; font-style: italic;">//Declaration</span>
SoundPool soundPool<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Initialization </span>
soundPool <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SoundPool<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">8</span>, AudioManager.<span style="color: #006633;">STREAM_MUSIC</span>, <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
</div>
</div>
<p>The first parameter is number of simultaneous streams you can have. second is type of stream and third is quality. 3rd parameter has not been implemented as of this writing, so you can safely just put a zero.</p>
<p>Here is documentation for SoundPool: <a href="http://developer.android.com/reference/android/media/SoundPool.html" title="http://developer.android.com/reference/android/media/SoundPool.html">http://developer.android.com/reference/android/media/SoundPool.html</a></p>
<p>Unfortunately whenever a sound is loaded to the soundPool, it generates its own SoundID (An integer) that you have to keep track of. In my app, I just created a hashmap that takes cares of mapping the loaded soundIDs to Icon tags.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//Declaration</span>
HashMap<span style="color: #339933;">&lt;</span>String, Integer<span style="color: #339933;">&gt;</span> soundPlayers<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Initialization</span>
soundPlayers <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HashMap<span style="color: #339933;">&lt;</span>String, Integer<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
</div>
</div>
<p>I load sounds dynamically when an icon is clicked. Here is my code.</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
</pre>
</td>
<td class="code">
<pre class="java" style="font-family:monospace;">btn.<span style="color: #006633;">setOnClickListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> OnClickListener<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <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><span style="color: #003399;">View</span> v<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     v.<span style="color: #006633;">startAnimation</span><span style="color: #009900;">&#40;</span>AnimationUtils.<span style="color: #006633;">loadAnimation</span><span style="color: #009900;">&#40;</span>ChristmasSoundsActivity.<span style="color: #000000; font-weight: bold;">this</span>, R.<span style="color: #006633;">anim</span>.<span style="color: #006633;">image_click</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>soundPlayers.<span style="color: #006633;">containsKey</span><span style="color: #009900;">&#40;</span>v.<span style="color: #006633;">getTag</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: #009900;">&#123;</span>
         <span style="color: #000066; font-weight: bold;">int</span> sound <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#41;</span> soundPlayers.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>v.<span style="color: #006633;">getTag</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         soundPool.<span style="color: #006633;">play</span><span style="color: #009900;">&#40;</span>sound, 1.0f, 1.0f, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">0</span>, 1.0f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #009900;">&#125;</span>
     <span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
         <span style="color: #000066; font-weight: bold;">int</span> sound <span style="color: #339933;">=</span> soundPool.<span style="color: #006633;">load</span><span style="color: #009900;">&#40;</span>ChristmasSoundsActivity.<span style="color: #000000; font-weight: bold;">this</span>, getResources<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getIdentifier</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;sound&quot;</span> <span style="color: #339933;">+</span> v.<span style="color: #006633;">getTag</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #0000ff;">&quot;raw&quot;</span>, <span style="color: #0000ff;">&quot;com.objectgraph.ChristmasSounds&quot;</span><span style="color: #009900;">&#41;</span>, <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         soundPlayers.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>v.<span style="color: #006633;">getTag</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>, sound<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #009900;">&#125;</span>
&nbsp;
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
</td>
</tr>
</table>
</div>
<p>In Line6 as you can see, I am calling the soundPool.play</p>
<p>The first parameter is the soundID which i get from my hashmap. The parameters are listed below.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java" style="font-family:monospace;">paramter <span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span>soundID	a soundID returned by the load<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> function
paramter <span style="color: #cc66cc;">2</span><span style="color: #339933;">:</span>leftVolume	left volume value <span style="color: #009900;">&#40;</span>range <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.0</span> to <span style="color: #cc66cc;">1.0</span><span style="color: #009900;">&#41;</span>
paramter <span style="color: #cc66cc;">3</span><span style="color: #339933;">:</span>rightVolume	right volume value <span style="color: #009900;">&#40;</span>range <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.0</span> to <span style="color: #cc66cc;">1.0</span><span style="color: #009900;">&#41;</span>
paramter <span style="color: #cc66cc;">4</span><span style="color: #339933;">:</span>priority	stream priority <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span> <span style="color: #339933;">=</span> lowest priority<span style="color: #009900;">&#41;</span>
paramter <span style="color: #cc66cc;">5</span><span style="color: #339933;">:</span>loop	loop mode <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span> <span style="color: #339933;">=</span> no loop, <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">=</span> loop forever<span style="color: #009900;">&#41;</span>
paramter <span style="color: #cc66cc;">6</span><span style="color: #339933;">:</span>rate	playback rate <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1.0</span> <span style="color: #339933;">=</span> normal playback, range <span style="color: #cc66cc;">0.5</span> to <span style="color: #cc66cc;">2.0</span><span style="color: #009900;">&#41;</span></pre>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectgraph.com/index.php/2012/01/02/android-development-using-soundpool-instead-of-mediaplayer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Core Image Framework in IOS 5.0</title>
		<link>http://blog.objectgraph.com/index.php/2011/12/31/core-image-framework-in-ios-5-0/</link>
		<comments>http://blog.objectgraph.com/index.php/2011/12/31/core-image-framework-in-ios-5-0/#comments</comments>
		<pubDate>Sat, 31 Dec 2011 07:36:58 +0000</pubDate>
		<dc:creator>soe</dc:creator>
				<category><![CDATA[iPad]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[iphone development]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[coreimage]]></category>

		<guid isPermaLink="false">http://blog.objectgraph.com/?p=2149</guid>
		<description><![CDATA[With the new ios 5 comes new frameworks. Today we are going to investigate one of the new framework: Core Image Framework. Core Image framework contains built in image filters to manipulate images and videos. The framework includes basic image filters like Sepia tone and Monochrome to advance image operations like face detection. One of [...]]]></description>
			<content:encoded><![CDATA[<p>With the new ios 5 comes new frameworks. Today we are going to investigate one of the new framework: Core Image Framework. Core Image framework contains built in image filters to manipulate images and videos. The framework includes basic image filters like <span>Sepia tone and Monochrome to advance image operations like face detection. One of the main advantage of the Core Image Framework is it&#8217;s ability to be able to use both CPU and GPU power, and the result is very fast image processing. The framework can even support the real time processing of video frames.</span><br />
There are 3 main components in Core Image Framework:</p>
<ul>
<li>CIImage: holds the image data</li>
<li>CIFilter: holds filters information and attributes</li>
<li>CIContext: is where all the image processing are taking place</li>
</ul>
<p>For this article we will try out &#8220;CISepiaTone&#8221; filter. Let&#8217;s start</p>
<p>1. Open your Xcode and create a single view application<br />
2. Add CoreImage.framework framework to the project<br />
3. Add an image (any image in jpg or png) to our project<br />
4. Let&#8217;s add an UIImageView to our xib and add the UIImageView in our .h file and connect with our UIImageView in the xib</p>
<ol></ol>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;">UIImageView <span style="color: #002200;">*</span>imageView;</pre>
</div>
</div>
<p>5. In the viewDidLoad method, add the following code</p>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;">  <span style="color: #11740a; font-style: italic;">//First load our image</span>
   <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>filePath <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSBundle</span> mainBundle<span style="color: #002200;">&#93;</span> pathForResource<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;image_name&quot;</span> ofType<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;jpg&quot;</span><span style="color: #002200;">&#93;</span>;
   <span style="color: #400080;">NSURL</span> <span style="color: #002200;">*</span>fileNameAndPath <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURL</span> fileURLWithPath<span style="color: #002200;">:</span>filePath<span style="color: #002200;">&#93;</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;">//We need context, filter, sourceimage and outputimage</span>
    CIContext <span style="color: #002200;">*</span>context;
    CIFilter <span style="color: #002200;">*</span>filter;
    CIImage <span style="color: #002200;">*</span>sourceImage;
    CIImage <span style="color: #002200;">*</span>outputImage;
&nbsp;
    <span style="color: #11740a; font-style: italic;">//Get the source image from NSURL </span>
    sourceImage <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CIImage imageWithContentsOfURL<span style="color: #002200;">:</span>fileNameAndPath<span style="color: #002200;">&#93;</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;">//Create context, here you can also specify cpu or gpu option</span>
    context <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CIContext contextWithOptions<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;">//Declare our filter and attribute value</span>
    filter <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CIFilter filterWithName<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;CISepiaTone&quot;</span>
                        keysAndValues<span style="color: #002200;">:</span> kCIInputImageKey, sourceImage,
                        <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;inputIntensity&quot;</span>, <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithFloat<span style="color: #002200;">:</span><span style="color: #2400d9;">0.8</span><span style="color: #002200;">&#93;</span>, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;">//Apply filter and write to output image</span>
    outputImage <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>filter outputImage<span style="color: #002200;">&#93;</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;">//Assign outputimage to cgimage, cgimage to UIImage and then to our UIImageView</span>
    CGImageRef cgimg <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>context createCGImage<span style="color: #002200;">:</span>outputImage fromRect<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>outputImage extent<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
    UIImage <span style="color: #002200;">*</span>newImg <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIImage imageWithCGImage<span style="color: #002200;">:</span>cgimg<span style="color: #002200;">&#93;</span>;
&nbsp;
    <span style="color: #002200;">&#91;</span>imageView setImage<span style="color: #002200;">:</span>newImg<span style="color: #002200;">&#93;</span>;
&nbsp;
    CGImageRelease<span style="color: #002200;">&#40;</span>cgimg<span style="color: #002200;">&#41;</span>;</pre>
</div>
</div>
<p>Run the project and you will see your image is transformed by the filter. You can read more about the framework and additional filters on developer.apple.com<br />
Here are the screen shots of before and after effects of our filter:<br />
<a href="http://blog.objectgraph.com/wp-content/uploads/2011/12/ScreenShotBefore.png"><img src="http://blog.objectgraph.com/wp-content/uploads/2011/12/ScreenShotBefore.png" alt="ScreenShotBefore" title="ScreenShotBefore" width="396" height="744" class="alignnone size-full wp-image-2188" /></a><a href="http://blog.objectgraph.com/wp-content/uploads/2011/12/ScreenShotAfter.png"><img src="http://blog.objectgraph.com/wp-content/uploads/2011/12/ScreenShotAfter.png" alt="ScreenShotAfter" title="ScreenShotAfter" width="396" height="744" class="alignnone size-full wp-image-2189" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectgraph.com/index.php/2011/12/31/core-image-framework-in-ios-5-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My adventures with the Sparrow framework</title>
		<link>http://blog.objectgraph.com/index.php/2011/12/31/my-adventures-with-the-sparrow-framework/</link>
		<comments>http://blog.objectgraph.com/index.php/2011/12/31/my-adventures-with-the-sparrow-framework/#comments</comments>
		<pubDate>Sat, 31 Dec 2011 06:01:40 +0000</pubDate>
		<dc:creator>ken</dc:creator>
				<category><![CDATA[apple]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[iphone development]]></category>
		<category><![CDATA[mac os x]]></category>
		<category><![CDATA[misc]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[sparrow]]></category>

		<guid isPermaLink="false">http://blog.objectgraph.com/?p=2153</guid>
		<description><![CDATA[I had been looking into 2D game development frameworks when one of my friends suggested the Sparrow framework. Having struggled with OpenGLES in the past, I was eager to find a higher-level framework that would allow me to produce some working concepts without writing mountains of code just to render a basic shape on the [...]]]></description>
			<content:encoded><![CDATA[<p>I had been looking into 2D game development frameworks when one of my friends suggested the Sparrow framework. Having struggled with OpenGLES in the past, I was eager to find a higher-level framework that would allow me to produce some working concepts without writing mountains of code just to render a basic shape on the screen.</p>
<p>I found Sparrow extremely easy to learn and if you have prior 2D or 3D game development experience, it should be even easier to pick up. To get started, download the latest package from:</p>
<p>http://www.sparrow-framework.org/download/</p>
<p>This package comes with the Sparrow library, a demo project, and a scaffold project that can be used as a starting point for all of your Sparrow apps.</p>
<p>For more detail, you can always read the Getting Started guide at:</p>
<p>http://www.sparrow-framework.org/help/gettingstarted/</p>
<p>When you first try to compile, you may get some errors related to the Sparrow source path. To remedy this, go to Xcode preferences > Locations > Source Trees. Create a variable called SPARROW_SRC and point it to the absolute path of your /sparrow/src/ folder.</p>
<p>For example, mine is:</p>
<div class="wp_syntax">
<div class="code">
<pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>ken<span style="color: #000000; font-weight: bold;">/</span>Work<span style="color: #000000; font-weight: bold;">/</span>Sparrow-Framework<span style="color: #000000; font-weight: bold;">/</span>sparrow<span style="color: #000000; font-weight: bold;">/</span>src</pre>
</div>
</div>
<p>Try testing out the scaffold project to see if it works. If you&#8217;re able to see a red square rendered on the screen, Sparrow is setup correctly. Pretty boring so far, right?</p>
<p>I wanted to take it a step further and had an idea in my mind. My first inspiration came from typing in &#8220;let it snow&#8221; in Google. Determined to produce something with a somewhat similar effect on the iPhone, I had to see what Sparrow was capable of. The concept was to show a glass window on a snowy night. As time passes, snow will accumulate on the window. You may then use your finger to swipe away the snow.</p>
<p><img src="http://blog.objectgraph.com/wp-content/uploads/2011/12/google_let_it_snow-550x300.png" alt="google_let_it_snow" title="google_let_it_snow" width="550" height="300" class="alignnone size-large wp-image-2161" /></p>
<p>First I created a canvas of type SPRenderTexture to draw on.</p>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;">SPRenderTexture <span style="color: #002200;">*</span>mTexCanvas;
SPImage <span style="color: #002200;">*</span>mImgCanvas;</pre>
</div>
</div>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;">mTexCanvas <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>SPRenderTexture alloc<span style="color: #002200;">&#93;</span> initWithWidth<span style="color: #002200;">:</span><span style="color: #2400d9;">320</span> height<span style="color: #002200;">:</span><span style="color: #2400d9;">480</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>mTexCanvas clearWithColor<span style="color: #002200;">:</span>0xffffff alpha<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#93;</span>;
mImgCanvas <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>SPImage imageWithTexture<span style="color: #002200;">:</span>mTexCanvas<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>self addChild<span style="color: #002200;">:</span>mImgCanvas<span style="color: #002200;">&#93;</span>;</pre>
</div>
</div>
<p>Next, I needed snowflakes of type SPImage for a few different sizes.</p>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;">SPImage <span style="color: #002200;">*</span>mImgSnowLarge;
SPImage <span style="color: #002200;">*</span>mImgSnowMed;
SPImage <span style="color: #002200;">*</span>mImgSnowSmall;</pre>
</div>
</div>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;">mImgSnowLarge <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>SPImage imageWithContentsOfFile<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;snow_l.png&quot;</span><span style="color: #002200;">&#93;</span>;
mImgSnowMed <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>SPImage imageWithContentsOfFile<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;snow_m.png&quot;</span><span style="color: #002200;">&#93;</span>;
mImgSnowSmall <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>SPImage imageWithContentsOfFile<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;snow_s.png&quot;</span><span style="color: #002200;">&#93;</span>;</pre>
</div>
</div>
<p>We will also need to create an eraser brush to wipe away the snow.</p>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;">SPImage <span style="color: #002200;">*</span>brush;</pre>
</div>
</div>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;">brush <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>SPImage imageWithContentsOfFile<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;erase.png&quot;</span><span style="color: #002200;">&#93;</span>;</pre>
</div>
</div>
<p>I also created an SPImage for the background of the sky.</p>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;">SPImage <span style="color: #002200;">*</span>mImgSky;</pre>
</div>
</div>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;">mImgSky <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>SPImage imageWithContentsOfFile<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;night.png&quot;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>mImgSky retain<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>self addChild<span style="color: #002200;">:</span>mImgSky<span style="color: #002200;">&#93;</span>;</pre>
</div>
</div>
<p>Since I wanted the snow to accumulate on the window glass over time, I also added a timer.</p>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSTimer</span> <span style="color: #002200;">*</span>mTimer;</pre>
</div>
</div>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;">mTimer <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSTimer</span> scheduledTimerWithTimeInterval<span style="color: #002200;">:</span>0.1f target<span style="color: #002200;">:</span>self selector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>ticked<span style="color: #002200;">&#41;</span> userInfo<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> repeats<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;</pre>
</div>
</div>
<p>To keep track of the touch events when you drag the eraser brush over the snow, I added event listeners to check when erasing firt took place and when erasing finished.</p>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span>self addEventListener<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>update<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span> atObject<span style="color: #002200;">:</span>self forType<span style="color: #002200;">:</span>SP_EVENT_TYPE_ENTER_FRAME<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>self addEventListener<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>touched<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span> atObject<span style="color: #002200;">:</span>self forType<span style="color: #002200;">:</span>SP_EVENT_TYPE_TOUCH<span style="color: #002200;">&#93;</span>;</pre>
</div>
</div>
<p>One thing that I had noticed was that Sparrow did not support erasing out of the box. After digging through some of the Sparrow extensions, I stumbled upon SPRenderTexture+Erase that might be able to do what I wanted.</p>
<p>After some experimentation, it did exactly what I needed it to do. This extension allowed me to erase a SPRenderTexture with an SPDisplayObject. In my case, my eraser brush was an SPImage. Erasing is simply one line of code whenever erasing took place.</p>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span>mTexCanvas eraseWithObject<span style="color: #002200;">:</span>brush<span style="color: #002200;">&#93;</span>;</pre>
</div>
</div>
<p>My update and touched event handlers look like this.</p>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>update<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>SPEnterFrameEvent<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>event<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>drawing<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
		<span style="color: #11740a; font-style: italic;">// group the draw calls together for speed</span>
		<span style="color: #002200;">&#91;</span>mTexCanvas bundleDrawCalls<span style="color: #002200;">:^</span><span style="color: #002200;">&#123;</span>
			<span style="color: #a61390;">double</span> incX <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>newTouch.x <span style="color: #002200;">-</span> lastTouch.x<span style="color: #002200;">&#41;</span><span style="color: #002200;">/</span>numSteps;
			<span style="color: #a61390;">double</span> incY <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>newTouch.y <span style="color: #002200;">-</span> lastTouch.y<span style="color: #002200;">&#41;</span><span style="color: #002200;">/</span>numSteps;
			brush.x <span style="color: #002200;">=</span> lastTouch.x <span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>brush.width<span style="color: #002200;">/</span><span style="color: #2400d9;">2</span><span style="color: #002200;">&#41;</span>;
			brush.y <span style="color: #002200;">=</span> lastTouch.y <span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>brush.height<span style="color: #002200;">/</span><span style="color: #2400d9;">2</span><span style="color: #002200;">&#41;</span>;
&nbsp;
			<span style="color: #11740a; font-style: italic;">// loop through so that if our touches are far apart we still create a line</span>
			<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span> i<span style="color: #002200;">=</span><span style="color: #2400d9;">0</span>; i&lt;numSteps; i<span style="color: #002200;">++</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
				<span style="color: #002200;">&#91;</span>mTexCanvas eraseWithObject<span style="color: #002200;">:</span>brush<span style="color: #002200;">&#93;</span>;
				brush.x <span style="color: #002200;">+=</span> incX;
				brush.y <span style="color: #002200;">+=</span> incY;
			<span style="color: #002200;">&#125;</span>
		<span style="color: #002200;">&#125;</span><span style="color: #002200;">&#93;</span>;
		lastTouch <span style="color: #002200;">=</span> CGPointMake<span style="color: #002200;">&#40;</span>newTouch.x, newTouch.y<span style="color: #002200;">&#41;</span>;
	<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span></pre>
</div>
</div>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>touched<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>SPTouchEvent<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>event<span style="color: #002200;">&#123;</span>
	SPTouch <span style="color: #002200;">*</span>touchStart <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>event touchesWithTarget<span style="color: #002200;">:</span>self andPhase<span style="color: #002200;">:</span>SPTouchPhaseBegan<span style="color: #002200;">&#93;</span> anyObject<span style="color: #002200;">&#93;</span>;
	SPPoint <span style="color: #002200;">*</span>touchPosition;
	<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>touchStart<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
		touchPosition <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>touchStart locationInSpace<span style="color: #002200;">:</span>self<span style="color: #002200;">&#93;</span>;
		lastTouch <span style="color: #002200;">=</span> CGPointMake<span style="color: #002200;">&#40;</span>touchPosition.x, touchPosition.y<span style="color: #002200;">&#41;</span>;
		newTouch <span style="color: #002200;">=</span> CGPointMake<span style="color: #002200;">&#40;</span>touchPosition.x, touchPosition.y<span style="color: #002200;">&#41;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	SPTouch <span style="color: #002200;">*</span>touchMove <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>event touchesWithTarget<span style="color: #002200;">:</span>self andPhase<span style="color: #002200;">:</span>SPTouchPhaseMoved<span style="color: #002200;">&#93;</span> anyObject<span style="color: #002200;">&#93;</span>;
	<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>touchMove<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
		touchPosition <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>touchMove locationInSpace<span style="color: #002200;">:</span>self<span style="color: #002200;">&#93;</span>;
		newTouch <span style="color: #002200;">=</span> CGPointMake<span style="color: #002200;">&#40;</span>touchPosition.x, touchPosition.y<span style="color: #002200;">&#41;</span>;
		drawing <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	SPTouch <span style="color: #002200;">*</span>touchEnd <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>event touchesWithTarget<span style="color: #002200;">:</span>self andPhase<span style="color: #002200;">:</span>SPTouchPhaseEnded<span style="color: #002200;">&#93;</span> anyObject<span style="color: #002200;">&#93;</span>;
	<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>touchEnd<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
		touchPosition <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>touchEnd locationInSpace<span style="color: #002200;">:</span>self<span style="color: #002200;">&#93;</span>;
		lastTouch <span style="color: #002200;">=</span> CGPointMake<span style="color: #002200;">&#40;</span>touchPosition.x, touchPosition.y<span style="color: #002200;">&#41;</span>;
		newTouch <span style="color: #002200;">=</span> CGPointMake<span style="color: #002200;">&#40;</span>touchPosition.x, touchPosition.y<span style="color: #002200;">&#41;</span>;
		drawing <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;
	<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span></pre>
</div>
</div>
<p>That&#8217;s all there is to it. Once I build and run, I get something like this.</p>
<p><img src="http://blog.objectgraph.com/wp-content/uploads/2011/12/sparrow_ss01-292x550.png" alt="sparrow_ss01" title="sparrow_ss01" width="292" height="550" class="alignnone size-large wp-image-2159" /></p>
<p><img src="http://blog.objectgraph.com/wp-content/uploads/2011/12/sparrow_ss02-292x550.png" alt="sparrow_ss02" title="sparrow_ss02" width="292" height="550" class="alignnone size-large wp-image-2160" /></p>
<p>I&#8217;ve also posted a short 30 seconds video below.</p>
<p><iframe width="420" height="315" src="http://www.youtube.com/embed/qqU6ITFbYA8" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectgraph.com/index.php/2011/12/31/my-adventures-with-the-sparrow-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IntelliJ brings back my interest in Android</title>
		<link>http://blog.objectgraph.com/index.php/2011/12/30/intellij-android-like/</link>
		<comments>http://blog.objectgraph.com/index.php/2011/12/30/intellij-android-like/#comments</comments>
		<pubDate>Fri, 30 Dec 2011 22:12:31 +0000</pubDate>
		<dc:creator>gavi</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[andorid]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[ide]]></category>

		<guid isPermaLink="false">http://blog.objectgraph.com/?p=2126</guid>
		<description><![CDATA[IntelliJ is awesome for developing Android apps.  In this blog post, I show how to setup your IntelliJ community edition for Android development.]]></description>
			<content:encoded><![CDATA[<p>Eclipse sucks!</p>
<p>Sorry to all Eclipse lovers, I just hate developing in Eclipse. Coming from Visual Studio and XCode, I just felt that eclipse was not responsive enough for Android development. I started my research for a good alternative. I even contemplated building everything manually using TextMate. But I think I finally found some good Android development tool that does not suck. Its IntelliJ IDEA and I use their free community edition. IDEA can open your eclipse projects and works seamlessly with Android emulator.</p>
<p>Downloading:</p>
<p>Download IntelliJ IDEA community edition from <a href="http://www.jetbrains.com">http://www.jetbrains.com</a> and install it on your platform. The rest of the post is for Mac OSX Lion. But it should be similar for others platforms.</p>
<p>Setting Up:</p>
<p>First thing you would do is download the android SDK and install some where. I put mine @</p>
<div class="wp_syntax">
<div class="code">
<pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>gavi<span style="color: #000000; font-weight: bold;">/</span>work<span style="color: #000000; font-weight: bold;">/</span>android-sdk-mac</pre>
</div>
</div>
<p>Add the android path in your profile. Edit your .bash_profile</p>
<div class="wp_syntax">
<div class="code">
<pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vi</span> ~<span style="color: #000000; font-weight: bold;">/</span>.bash_profile</pre>
</div>
</div>
<p>Add SDK tools paths</p>
<p>export PATH=$PATH:/Users/gavi/work/android-sdk-mac/platform-tools:/Users/gavi/work/android-sdk-mac/tools</p>
<p>Save the file and execute </p>
<pre>
source ~/.bash_profile
android
</pre>
<p>Then you can download the necessary SDKs you need(Android 2.3.3, ICS etc). Here is a screen shot.<br />
<a href="http://blog.objectgraph.com/wp-content/uploads/2011/12/android_sdk_manager.png"><img src="http://blog.objectgraph.com/wp-content/uploads/2011/12/android_sdk_manager.png" alt="android_sdk_manager" title="android_sdk_manager" width="500" class="alignnone size-full wp-image-2135" /></a></p>
<p>Once your sdk is setup. Start up IntelliJ</p>
<p>The first thing you want to do is setup your Java SDK. On Mac,  The path is similar to below</p>
<div class="wp_syntax">
<div class="code">
<pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>System<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Java<span style="color: #000000; font-weight: bold;">/</span>JavaVirtualMachines<span style="color: #000000; font-weight: bold;">/</span>1.6.0.jdk<span style="color: #000000; font-weight: bold;">/</span>Contents<span style="color: #000000; font-weight: bold;">/</span>Home</pre>
</div>
</div>
<p>Then you can add Android SDKs. Here is a quick video I recorded which makes it simple.</p>
<p><iframe src="http://player.vimeo.com/video/34385790?title=0&amp;byline=0&amp;portrait=0" width="600" height="375" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<p><a href="http://vimeo.com/34385790">Setting Up IntelliJ SDKs for Android</a> from <a href="http://vimeo.com/objectgraph">ObjectGraph LLC</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>Thats it. Just have fun developing for Andorid!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectgraph.com/index.php/2011/12/30/intellij-android-like/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ASP.NET Page Methods and jQuery</title>
		<link>http://blog.objectgraph.com/index.php/2011/12/30/asp-net-page-methods-and-jquery/</link>
		<comments>http://blog.objectgraph.com/index.php/2011/12/30/asp-net-page-methods-and-jquery/#comments</comments>
		<pubDate>Fri, 30 Dec 2011 20:23:09 +0000</pubDate>
		<dc:creator>bozena</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[pagemethod]]></category>

		<guid isPermaLink="false">http://blog.objectgraph.com/?p=2095</guid>
		<description><![CDATA[ASP.NET has a very nice architecture to pack all backend AJAX methods and jQuery in the same ASPX file. In this blog post I show a simple way to connect the dots between ASP.NET Page methods and jQuery on the client.
]]></description>
			<content:encoded><![CDATA[<p>ASP.NET has a very nice architecture to pack all backend AJAX methods and jQuery in the same ASPX file.<br />
Lets say you have a simple Page Method like below. You need to include the &#8220;System.Web.Services&#8221; and declare your method as WebMethod.</p>
<div class="wp_syntax">
<table>
<tr>
<td class="line_numbers">
<pre>1
2
3
4
</pre>
</td>
<td class="code">
<pre class="csharp" style="font-family:monospace;"><span style="color: #000000;">&#91;</span>WebMethod<span style="color: #000000;">&#93;</span>
<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #FF0000;">int</span> Sum<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> a, <span style="color: #FF0000;">int</span> b<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">return</span> a <span style="color: #008000;">+</span> b<span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre>
</td>
</tr>
</table>
</div>
<p>Make sure your page method is static</p>
<p>The JQuery way of calling this function would be something similar to this.</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
</pre>
</td>
<td class="code">
<pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#btnSum&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        $.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
            type<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;POST&quot;</span><span style="color: #339933;">,</span>
            url<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Default.aspx/Sum&quot;</span><span style="color: #339933;">,</span>
            data<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;{'a':&quot;</span> <span style="color: #339933;">+</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#txtA&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;,'b':&quot;</span> <span style="color: #339933;">+</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#txtB&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;}&quot;</span><span style="color: #339933;">,</span>
            contentType<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;application/json; charset=utf-8&quot;</span><span style="color: #339933;">,</span>
            dataType<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;json&quot;</span><span style="color: #339933;">,</span>
            success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#lblOutput&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>result.<span style="color: #660066;">d</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;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
</td>
</tr>
</table>
</div>
<p>In Line 5, I am assuming the file name is Default.aspx and thus you call Default.aspx/Sum. If you notice on line 10, the result is enclosed in a json object called &#8220;d&#8221;. So to unpack you would have to call result.d</p>
<p>HTML Form would be something like this</p>
<div class="wp_syntax">
<table>
<tr>
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
</pre>
</td>
<td class="code">
<pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;form1&quot;</span> runat<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;server&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
          A: <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;txtA&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
          B: <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;txtB&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;button&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Sum&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;btnSum&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;lblOutput&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span></pre>
</td>
</tr>
</table>
</div>
<p>You can download the file below</p>
<p><a href='http://blog.objectgraph.com/wp-content/uploads/2011/12/Default.aspx.zip'><img src="http://blog.objectgraph.com/wp-includes/images/crystal/archive.png">Page Methods Sample</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectgraph.com/index.php/2011/12/30/asp-net-page-methods-and-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Integrating ShareKit + ASIHTTPRequest for TwitPic</title>
		<link>http://blog.objectgraph.com/index.php/2011/12/27/integrating-sharekit-and-asihttprequestwith-twitpic/</link>
		<comments>http://blog.objectgraph.com/index.php/2011/12/27/integrating-sharekit-and-asihttprequestwith-twitpic/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 20:08:21 +0000</pubDate>
		<dc:creator>kiichi</dc:creator>
				<category><![CDATA[iphone]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[twitpic]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://blog.objectgraph.com/?p=2080</guid>
		<description><![CDATA[ShareKit (2.0 is here) is a nice SNS library to make your iPhone development life easy. Dropping the folder int your project and enable share in a few lines of codes. I&#8217;ve been using TwitPic for twitter user to share their image but ShareKit uses img.ly as default. TwitPic is better for me in terms [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://getsharekit.com/">ShareKit</a> (<a href="https://github.com/ShareKit/ShareKit">2.0 is here</a>) is a nice SNS library to make your iPhone development life easy. Dropping the folder int your project and enable share in a few lines of codes. I&#8217;ve been using TwitPic for twitter user to share their image but ShareKit uses img.ly as default. TwitPic is better for me in terms of supported formats and the simplicity; however, the recent OAuth things make so complicated. I&#8217;m not sure OAuth really contributing more secure authentication and I&#8217;m not sure SNS needs that high-level security system (people just upset after Obama&#8217;s account hacked?). Anyway, I miss TwitPic&#8217;s simple API back then. Another great network library, <a href="http://allseeing-i.com/ASIHTTPRequest/">ASIHTTPRequest</a> by Ben, is make everyone&#8217;s life easier too.  In this article, I would like to explain how to modify ShareKit to change the image uploading service to TwitPic. You can also read this article as &#8220;How to integrate Twitter Image upload service without bothering complicated OAuth mechanism?&#8221;</p>
<p>Step 1. Add <a href="http://allseeing-i.com/ASIHTTPRequest/">ASIHTTPRequest</a> in your project.</p>
<p>Step 2. Add <a href="http://getsharekit.com/">ShareKit</a> in your project.</p>
<p>Step 3. Get TwitPic application key and add it in SHKConfig.h</p>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#define SHKTwitPicKey				@&quot;a2f2c8902414d2c624d10403463c50c9&quot;</span></pre>
</div>
</div>
<p>Step 4. Replace codes around sendImage function in ShareKit > Sharers > Services > Twitter > SHKTwitter.m</p>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &quot;ASIHTTPRequest.h&quot;</span>
<span style="color: #6e371a;">#import &quot;ASIFormDataRequest.h&quot;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>sendImage <span style="color: #002200;">&#123;</span>
	<span style="color: #400080;">NSURL</span> <span style="color: #002200;">*</span>url <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURL</span> URLWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;http://api.twitpic.com/1/uploadAndPost.json&quot;</span><span style="color: #002200;">&#93;</span>;
	ASIFormDataRequest <span style="color: #002200;">*</span>req <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>ASIFormDataRequest requestWithURL<span style="color: #002200;">:</span>url<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>req addPostValue<span style="color: #002200;">:</span>SHKTwitPicKey forKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;key&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>req addPostValue<span style="color: #002200;">:</span>consumerKey forKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;consumer_token&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>req addPostValue<span style="color: #002200;">:</span>SHKTwitterSecret forKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;consumer_secret&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>req addPostValue<span style="color: #002200;">:</span>accessToken.key forKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;oauth_token&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>req addPostValue<span style="color: #002200;">:</span>accessToken.secret forKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;oauth_secret&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>req addPostValue<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>item customValueForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;status&quot;</span><span style="color: #002200;">&#93;</span> forKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;message&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>req addData<span style="color: #002200;">:</span>UIImageJPEGRepresentation<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>item image<span style="color: #002200;">&#93;</span>, <span style="color: #2400d9;">0.8</span><span style="color: #002200;">&#41;</span> forKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;media&quot;</span><span style="color: #002200;">&#93;</span>;
	req.requestMethod <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;POST&quot;</span>;
	<span style="color: #002200;">&#91;</span>req setDelegate<span style="color: #002200;">:</span>self<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>req startAsynchronous<span style="color: #002200;">&#93;</span>;
	<span style="color: #a61390;">return</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>requestFinished<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>ASIHTTPRequest <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>request<span style="color: #002200;">&#123;</span>
	<span style="color: #11740a; font-style: italic;">//NSString *responseString = [request responseString]; // do json parsing if you want.</span>
	<span style="color: #002200;">&#91;</span>self sendDidFinish<span style="color: #002200;">&#93;</span>; <span style="color: #11740a; font-style: italic;">// remove the spining shit</span>
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>requestFailed<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>ASIHTTPRequest <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>request<span style="color: #002200;">&#123;</span>
<span style="color: #11740a; font-style: italic;">//	NSError *error = [request error];</span>
	<span style="color: #002200;">&#91;</span>self sendDidFinish<span style="color: #002200;">&#93;</span>; <span style="color: #11740a; font-style: italic;">// remove the spining shit</span>
<span style="color: #002200;">&#125;</span></pre>
</div>
</div>
<p>Step 4. Call Twitter service from ShareKit like:</p>
<div class="wp_syntax">
<div class="code">
<pre class="objc" style="font-family:monospace;">	SHKItem <span style="color: #002200;">*</span>item <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>SHKItem image<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIImage imageWithContentsOfFile<span style="color: #002200;">:</span>mFileName<span style="color: #002200;">&#93;</span> title<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Look at this picture!&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>SHKTwitter shareItem<span style="color: #002200;">:</span>item<span style="color: #002200;">&#93;</span>;</pre>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectgraph.com/index.php/2011/12/27/integrating-sharekit-and-asihttprequestwith-twitpic/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

