<?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>StrictMode &#8211; Wiebe Elsinga</title>
	<atom:link href="http://wiebe-elsinga.com/blog/tag/strictmode/feed/" rel="self" type="application/rss+xml" />
	<link>http://wiebe-elsinga.com/blog</link>
	<description>Blog</description>
	<lastBuildDate>Wed, 16 Nov 2011 05:53:35 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.8.1</generator>
	<item>
		<title>Android Best Practices: StrictMode</title>
		<link>http://wiebe-elsinga.com/blog/869/</link>
					<comments>http://wiebe-elsinga.com/blog/869/#respond</comments>
		
		<dc:creator><![CDATA[W.Elsinga]]></dc:creator>
		<pubDate>Wed, 26 Oct 2011 23:05:37 +0000</pubDate>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[StrictMode]]></category>
		<guid isPermaLink="false">http://wiebe-elsinga.com/blog/?p=869</guid>

					<description><![CDATA[When developing Android applications that uses network and database access, you need to do performance tuning. This is where StrictMode comes in handy StrictMode? StrictMode is used to detect memory leaks. It&#8217;s has introduced in Gingerbread and can be used as a development tool. The configuration below was the proposed in the reference documentation: public void onCreate&#40;&#41; &#123; &#160; &#160; &#160;if &#40;DEVELOPER_MODE&#41; &#123; &#160; &#160; &#160; &#160; &#160;StrictMode.setThreadPolicy&#40;new StrictMode.ThreadPolicy.Builder&#40;&#41; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;.detectDiskReads&#40;&#41; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;.detectDiskWrites&#40;&#41; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;.detectNetwork&#40;&#41; &#160; // or .detectAll() for all detectable problems &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;.penaltyLog&#40;&#41; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;.build&#40;&#41;&#41;; &#160; &#160; &#160; &#160; &#160;StrictMode.setVmPolicy&#40;new StrictMode.VmPolicy.Builder&#40;&#41; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;.detectLeakedSqlLiteObjects&#40;&#41; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;.detectLeakedClosableObjects&#40;&#41; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;.penaltyLog&#40;&#41; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;.penaltyDeath&#40;&#41; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;.build&#40;&#41;&#41;; &#160; &#160; &#160;&#125; &#160; &#160; &#160;super.onCreate&#40;&#41;; &#160;&#125; Update If you&#8217;re looking on how to get StrictMode working for all Android platform versions, have a look at this article.]]></description>
										<content:encoded><![CDATA[<p>When developing Android applications that uses network and database access, you need to do performance tuning. This is where StrictMode comes in handy</p>
<h3>StrictMode?</h3>
<p>StrictMode is used to detect memory leaks. It&#8217;s has introduced in Gingerbread and can be used as a development tool.</p>
<p>The configuration below was the proposed in the <a href="http://developer.android.com/reference/android/os/StrictMode.html" target="_blank">reference</a> documentation:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onCreate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>DEVELOPER_MODE<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;StrictMode.<span style="color: #006633;">setThreadPolicy</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> StrictMode.<span style="color: #006633;">ThreadPolicy</span>.<span style="color: #006633;">Builder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.<span style="color: #006633;">detectDiskReads</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.<span style="color: #006633;">detectDiskWrites</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.<span style="color: #006633;">detectNetwork</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> &nbsp; <span style="color: #666666; font-style: italic;">// or .detectAll() for all detectable problems</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.<span style="color: #006633;">penaltyLog</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.<span style="color: #006633;">build</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;StrictMode.<span style="color: #006633;">setVmPolicy</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> StrictMode.<span style="color: #006633;">VmPolicy</span>.<span style="color: #006633;">Builder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.<span style="color: #006633;">detectLeakedSqlLiteObjects</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.<span style="color: #006633;">detectLeakedClosableObjects</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.<span style="color: #006633;">penaltyLog</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.<span style="color: #006633;">penaltyDeath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.<span style="color: #006633;">build</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp;<span style="color: #009900;">&#125;</span></div></div>
<p><strong>Update</strong> If you&#8217;re looking on how to get StrictMode working for all Android platform versions, have a look at <a href="http://www.simpligility.com/2011/01/android-strictmode-for-all-platform-versions/" target="_blank">this</a> article.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://wiebe-elsinga.com/blog/869/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
