<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1459919476916734020</id><updated>2012-02-01T02:36:21.541-08:00</updated><category term='Stock'/><category term='Life'/><category term='PlayBook'/><category term='iPhone'/><category term='BlackBerry'/><category term='Technique'/><category term='Forex'/><title type='text'>Yan</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default?start-index=101&amp;max-results=100'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>116</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-2826949888424945959</id><published>2011-11-15T09:34:00.001-08:00</published><updated>2011-11-15T09:34:26.127-08:00</updated><title type='text'>save data in local storage</title><content type='html'>&lt;code&gt; localStorage.setItem("name", "Brian");&lt;/code&gt;&lt;br /&gt;&lt;code&gt; var name = localStorage.getItem("name");&lt;/code&gt;&lt;br /&gt;localStorage.setItem("data",  {"foo":"bar","flip":"rep","arr":[1,3,4]});&lt;br /&gt;var data = localStorage.getItem("data");&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-2826949888424945959?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/2826949888424945959/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=2826949888424945959' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/2826949888424945959'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/2826949888424945959'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2011/11/save-data-in-local-storage.html' title='save data in local storage'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-5548952794964143939</id><published>2011-10-25T11:59:00.000-07:00</published><updated>2011-10-25T11:59:26.660-07:00</updated><title type='text'>NFC Primer for Developers</title><content type='html'>&lt;a href="http://supportforums.blackberry.com/t5/Java-Development/NFC-Primer-for-Developers/ta-p/1334857#.TqcHBxJe3aw.blogger"&gt;NFC Primer for Developers&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-5548952794964143939?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/5548952794964143939/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=5548952794964143939' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/5548952794964143939'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/5548952794964143939'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2011/10/nfc-primer-for-developers.html' title='NFC Primer for Developers'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-7883682564154319358</id><published>2011-10-25T11:35:00.000-07:00</published><updated>2011-10-25T11:35:07.286-07:00</updated><title type='text'>A good turtoial for object saving on plist</title><content type='html'>http://cocoadevcentral.com/articles/000084.php&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-7883682564154319358?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/7883682564154319358/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=7883682564154319358' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/7883682564154319358'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/7883682564154319358'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2011/10/good-turtoial-for-object-saving-on.html' title='A good turtoial for object saving on plist'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-2145653279508506046</id><published>2011-10-25T11:33:00.000-07:00</published><updated>2011-10-25T11:33:01.840-07:00</updated><title type='text'>Add UIProgressView to UITableViewCell</title><content type='html'>&lt;pre class="lang-c prettyprint"&gt;&lt;code&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;UITableViewCell&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;*&lt;/span&gt;&lt;span class="pln"&gt;cell &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;[&lt;/span&gt;&lt;span class="pln"&gt;tableView dequeueReusableCellWithIdentifier&lt;/span&gt;&lt;span class="pun"&gt;:@&lt;/span&gt;&lt;span class="str"&gt;"downloadcell"&lt;/span&gt;&lt;span class="pun"&gt;];&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="kwd"&gt;if&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;cell&lt;/span&gt;&lt;span class="pun"&gt;==&lt;/span&gt;&lt;span class="pln"&gt;nil&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="pun"&gt;{&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; cell &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;[[[&lt;/span&gt;&lt;span class="typ"&gt;UITableViewCell&lt;/span&gt;&lt;span class="pln"&gt; alloc&lt;/span&gt;&lt;span class="pun"&gt;]&lt;/span&gt;&lt;span class="pln"&gt; initWithStyle&lt;/span&gt;&lt;span class="pun"&gt;:&lt;/span&gt;&lt;span class="typ"&gt;UITableViewCellStyleSubtitle&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;reuseIdentifier&lt;/span&gt;&lt;span class="pun"&gt;:@&lt;/span&gt;&lt;span class="str"&gt;"downloadcell"&lt;/span&gt;&lt;span class="pun"&gt;]&lt;/span&gt;&lt;span class="pln"&gt; autorelease&lt;/span&gt;&lt;span class="pun"&gt;];&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="typ"&gt;UIProgressView&lt;/span&gt;&lt;span class="pun"&gt;*&lt;/span&gt;&lt;span class="pln"&gt; downPreView &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;[[&lt;/span&gt;&lt;span class="typ"&gt;UIProgressView&lt;/span&gt;&lt;span class="pln"&gt; alloc&lt;/span&gt;&lt;span class="pun"&gt;]&lt;/span&gt;&lt;span class="pln"&gt; initWithProgressViewStyle&lt;/span&gt;&lt;span class="pun"&gt;:&lt;/span&gt;&lt;span class="typ"&gt;UIProgressViewStyleDefault&lt;/span&gt;&lt;span class="pun"&gt;];&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; downPreView&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;tag &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;1234&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; downPreView&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;frame &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;CGRectMake&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="lit"&gt;400&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="lit"&gt;70&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;200&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="lit"&gt;10&lt;/span&gt;&lt;span class="pun"&gt;);&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;[&lt;/span&gt;&lt;span class="pln"&gt;cell&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;contentView addSubview&lt;/span&gt;&lt;span class="pun"&gt;:&lt;/span&gt;&lt;span class="pln"&gt;downPreView&lt;/span&gt;&lt;span class="pun"&gt;];&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="pun"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class="lang-c prettyprint"&gt;&lt;code&gt;&lt;span class="pun"&gt;&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class="lang-c prettyprint"&gt;&lt;code&gt;&lt;span class="pun"&gt;//update the progress&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class="lang-c prettyprint"&gt;&lt;code&gt;&lt;span class="typ"&gt;UIProgressView&lt;/span&gt;&lt;span class="pun"&gt;*&lt;/span&gt;&lt;span class="pln"&gt; downPreView &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="typ"&gt;UIProgressView&lt;/span&gt;&lt;span class="pun"&gt;*)[&lt;/span&gt;&lt;span class="pln"&gt;cell viewWithTag&lt;/span&gt;&lt;span class="pun"&gt;:&lt;/span&gt;&lt;span class="lit"&gt;123&lt;/span&gt;&lt;span class="pun"&gt;];&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;downPreView&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;progress &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; downloadPre&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span class="pun"&gt; &lt;/span&gt;&lt;span class="pln"&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-2145653279508506046?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/2145653279508506046/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=2145653279508506046' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/2145653279508506046'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/2145653279508506046'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2011/10/add-uiprogressview-to-uitableviewcell.html' title='Add UIProgressView to UITableViewCell'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-1791862310913168567</id><published>2011-10-17T18:39:00.001-07:00</published><updated>2011-10-17T18:39:13.855-07:00</updated><title type='text'>PhoneGap and ASIHTTPRequest conflicting problem</title><content type='html'>&lt;span class="corners-top"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;        &lt;br /&gt;&lt;h3&gt;&lt;a href="http://www.nimblekit.com/forum/viewtopic.php?f=5&amp;amp;t=1835#p15683"&gt;Re: Conflict with ASIHTTPRequest (Reachability Issue)&lt;/a&gt;&lt;/h3&gt;&lt;div class="author"&gt;&lt;a href="http://www.nimblekit.com/forum/viewtopic.php?p=15683&amp;amp;sid=c922667b3bc0e6450c3be257b78fde92#p15683"&gt;&lt;img alt="Post" height="9" src="http://www.nimblekit.com/forum/styles/prosilverNK/imageset/icon_post_target.gif" title="Post" width="11" /&gt;&lt;/a&gt;by &lt;strong&gt;&lt;a href="http://www.nimblekit.com/forum/memberlist.php?mode=viewprofile&amp;amp;u=2092&amp;amp;sid=c922667b3bc0e6450c3be257b78fde92"&gt;ryanagler&lt;/a&gt;&lt;/strong&gt; » Tue Aug 02, 2011 10:12 pm &lt;/div&gt;I dont know the reprecussions of this, but it appears I got it to work by replacing the Reachability.h that comes with ASIHTTPRequest with Apple's version 2.2 here:&lt;br /&gt;&lt;br /&gt;&lt;a class="postlink" href="http://developer.apple.com/library/ios/#samplecode/Reachability/Listings/Classes_Reachability_h.html%23//apple_ref/doc/uid/DTS40007324-Classes_Reachability_h-DontLinkElementID_5"&gt;http://developer.apple.com/library/ios/ ... lementID_5&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-1791862310913168567?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/1791862310913168567/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=1791862310913168567' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/1791862310913168567'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/1791862310913168567'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2011/10/phonegap-and-asihttprequest-conflicting.html' title='PhoneGap and ASIHTTPRequest conflicting problem'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-7906497677884497176</id><published>2011-10-17T07:57:00.000-07:00</published><updated>2011-10-17T07:57:08.015-07:00</updated><title type='text'>get iPhone udid by phoneGap api</title><content type='html'>&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="votecell"&gt;        &lt;/td&gt;&lt;td class="answercell"&gt;    &lt;div class="post-text"&gt;var string = device.uuid;&lt;br /&gt;PhoneGap api docs are here if you need any more info...&lt;a href="http://docs.phonegap.com/phonegap_device_device.md.html#device.uuid" rel="nofollow"&gt;http://docs.phonegap.com/phonegap_device_device.md.html#device.uuid&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-7906497677884497176?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/7906497677884497176/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=7906497677884497176' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/7906497677884497176'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/7906497677884497176'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2011/10/get-iphone-udid-by-phonegap-api.html' title='get iPhone udid by phoneGap api'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-754128611492371360</id><published>2011-10-17T07:38:00.001-07:00</published><updated>2011-10-17T07:38:20.509-07:00</updated><title type='text'>How to get the Blackberry address book image photo</title><content type='html'>&lt;pre&gt;Vector contactList = Phone.getContactsByPhoneNumber(inputNumber);&lt;br /&gt;Contact contact = (Contact) contactList.elementAt(0);&lt;br /&gt;byteStream = contact.getBinary(Contact.PHOTO, Contact.ATTR_NONE);&lt;br /&gt;   &lt;br /&gt;EncodedImage contactPic = EncodedImage.createEncodedImage(byteStream, 0, byteStream.length); &lt;br /&gt;String picType = String.valueOf( contactPic.getImageType() );&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-754128611492371360?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/754128611492371360/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=754128611492371360' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/754128611492371360'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/754128611492371360'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2011/10/how-to-get-blackberry-address-book.html' title='How to get the Blackberry address book image photo'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-8704228940591431160</id><published>2011-06-01T08:34:00.001-07:00</published><updated>2011-06-01T08:34:19.325-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><title type='text'>iphone webview loading percentage</title><content type='html'>&lt;p&gt;Instead of using a UIWebView, you can pull the webpage down as an  NSData object using an NSURLConnection.  When you get the initial  response from your request from&lt;/p&gt;  &lt;pre class="default prettyprint"&gt;&lt;code&gt;&lt;span class="pun"&gt;-&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="kwd"&gt;void&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt;connection&lt;/span&gt;&lt;span class="pun"&gt;:(&lt;/span&gt;&lt;span class="typ"&gt;NSURLConnection&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;*)&lt;/span&gt;&lt;span class="pln"&gt;connection didReceiveResponse&lt;/span&gt;&lt;span class="pun"&gt;:(&lt;/span&gt;&lt;span class="typ"&gt;NSURLResponse&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;*)&lt;/span&gt;&lt;span class="pln"&gt;response&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;the webserver should return a value of "expected content size" (which  should be included in the response).  Then you will keep getting the  following method called each time you receive data:&lt;/p&gt;  &lt;pre class="default prettyprint"&gt;&lt;code&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;-&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="kwd"&gt;void&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt;connection&lt;/span&gt;&lt;span class="pun"&gt;:(&lt;/span&gt;&lt;span class="typ"&gt;NSURLConnection&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;*)&lt;/span&gt;&lt;span class="pln"&gt;connection didReceiveData&lt;/span&gt;&lt;span class="pun"&gt;:(&lt;/span&gt;&lt;span class="typ"&gt;NSData&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;*)&lt;/span&gt;&lt;span class="pln"&gt;data&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;Keep appending the data to an existing NSData object.  Then you can  check the size of your current data object (NSData.bytes) against the  expected response size.&lt;/p&gt;  &lt;pre class="default prettyprint"&gt;&lt;code&gt;&lt;span class="pln"&gt;percentage &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;myData&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;bytes&lt;/span&gt;&lt;span class="pun"&gt;/&lt;/span&gt;&lt;span class="pln"&gt;theResponse&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;expectedContentSize&lt;/span&gt;&lt;span class="pun"&gt;)*&lt;/span&gt;&lt;span class="lit"&gt;100&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;Then you can update a progress bar with that percentage!  When &lt;/p&gt;  &lt;pre class="default prettyprint"&gt;&lt;code&gt;&lt;span class="pun"&gt;-&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="kwd"&gt;void&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt;connectionDidFinishLoading&lt;/span&gt;&lt;span class="pun"&gt;:(&lt;/span&gt;&lt;span class="typ"&gt;NSURLConnection&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;*)&lt;/span&gt;&lt;span class="pln"&gt;connection&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;runs, use your data to call&lt;/p&gt;  &lt;pre class="default prettyprint"&gt;&lt;code&gt;&lt;span class="pun"&gt;[&lt;/span&gt;&lt;span class="pln"&gt;myWebView loadData&lt;/span&gt;&lt;span class="pun"&gt;:&lt;/span&gt;&lt;span class="pln"&gt;myData &lt;/span&gt;&lt;span class="typ"&gt;MIMEType&lt;/span&gt;&lt;span class="pun"&gt;:&lt;/span&gt;&lt;span class="pln"&gt;myMimeType textEncodingName&lt;/span&gt;&lt;span class="pun"&gt;:&lt;/span&gt;&lt;span class="pln"&gt;myEncoding baseURL&lt;/span&gt;&lt;span class="pun"&gt;:&lt;/span&gt;&lt;span class="pln"&gt;baseURL&lt;/span&gt;&lt;span class="pun"&gt;];&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;and it will load everything you pulled down into your web view.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-8704228940591431160?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/8704228940591431160/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=8704228940591431160' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/8704228940591431160'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/8704228940591431160'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2011/06/iphone-webview-loading-percentage.html' title='iphone webview loading percentage'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-3628984283148179551</id><published>2011-06-01T07:51:00.002-07:00</published><updated>2011-06-01T07:52:30.195-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><title type='text'>UITables with Downloaded Images – Easy Asynchronous Code</title><content type='html'>http://davidgolightly.blogspot.com/2009/02/asynchronous-image-caching-with-iphone.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-3628984283148179551?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/3628984283148179551/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=3628984283148179551' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/3628984283148179551'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/3628984283148179551'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2011/06/uitables-with-downloaded-images-easy.html' title='UITables with Downloaded Images – Easy Asynchronous Code'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-523886371141570611</id><published>2011-06-01T07:51:00.001-07:00</published><updated>2011-06-01T07:51:39.967-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><title type='text'>an example of method swizzling by customizing an UINavigationBar</title><content type='html'>&lt;h1&gt;an example of method swizzling by customizing an UINavigationBar&lt;/h1&gt;     &lt;div class="snipt-count left"&gt;         &lt;span class="posted-by tags-title"&gt;posted on Sep 08, 2010 at 7:46 a.m. EDT in &lt;/span&gt;         &lt;ul class="left snipt-tags clearfix" id="tags-list-18301" style="padding-top: 0 !important;"&gt;&lt;li&gt;&lt;a href="http://snipt.net/jonatasmiguel/tag/cgcontextfillrect"&gt;cgcontextfillrect&lt;/a&gt;, &lt;/li&gt;&lt;li&gt;&lt;a href="http://snipt.net/jonatasmiguel/tag/cgrectmake"&gt;cgrectmake&lt;/a&gt;, &lt;/li&gt;&lt;li&gt;&lt;a href="http://snipt.net/jonatasmiguel/tag/cocoa%20touch"&gt;cocoa touch&lt;/a&gt;, &lt;/li&gt;&lt;li&gt;&lt;a href="http://snipt.net/jonatasmiguel/tag/drawinrect"&gt;drawinrect&lt;/a&gt;, &lt;/li&gt;&lt;li&gt;&lt;a href="http://snipt.net/jonatasmiguel/tag/drawrect"&gt;drawrect&lt;/a&gt;, &lt;/li&gt;&lt;li&gt;&lt;a href="http://snipt.net/jonatasmiguel/tag/ios"&gt;ios&lt;/a&gt;, &lt;/li&gt;&lt;li&gt;&lt;a href="http://snipt.net/jonatasmiguel/tag/ipad"&gt;ipad&lt;/a&gt;, &lt;/li&gt;&lt;li&gt;&lt;a href="http://snipt.net/jonatasmiguel/tag/iphone"&gt;iphone&lt;/a&gt;, &lt;/li&gt;&lt;li&gt;&lt;a href="http://snipt.net/jonatasmiguel/tag/ipod"&gt;ipod&lt;/a&gt;, &lt;/li&gt;&lt;li&gt;&lt;a href="http://snipt.net/jonatasmiguel/tag/mac"&gt;mac&lt;/a&gt;, &lt;/li&gt;&lt;li&gt;&lt;a href="http://snipt.net/jonatasmiguel/tag/method%20swizzling"&gt;method swizzling&lt;/a&gt;, &lt;/li&gt;&lt;li&gt;&lt;a href="http://snipt.net/jonatasmiguel/tag/objective-c"&gt;objective-c&lt;/a&gt;, &lt;/li&gt;&lt;li&gt;&lt;a href="http://snipt.net/jonatasmiguel/tag/objective-c%202.0"&gt;objective-c 2.0&lt;/a&gt;, &lt;/li&gt;&lt;li&gt;&lt;a href="http://snipt.net/jonatasmiguel/tag/osx"&gt;osx&lt;/a&gt;, &lt;/li&gt;&lt;li&gt;&lt;a href="http://snipt.net/jonatasmiguel/tag/swizzling"&gt;swizzling&lt;/a&gt;, &lt;/li&gt;&lt;li&gt;&lt;a href="http://snipt.net/jonatasmiguel/tag/uigraphicsgetcurrentcontext"&gt;uigraphicsgetcurrentcontext&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;     &lt;/div&gt;     &lt;form id="toggle-wrap-form" method="post" action="."&gt;&lt;div id="toggle-wrap"&gt;&lt;input id="wrap-check" checked="checked" type="checkbox"&gt;&lt;label for="wrap-check"&gt; &lt;span id="wrap-text"&gt;wrap code&lt;/span&gt;&lt;/label&gt;&lt;/div&gt;&lt;/form&gt;     &lt;div id="full-page-snipt"&gt;         &lt;ul class="snipts" style="padding-top: 0;"&gt;&lt;li class="container-18301 clearfix"&gt;                                                                                     &lt;div id="code-stylized-18301" class="code-stylized"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="cm"&gt;/*&lt;/span&gt; &lt;span class="cm"&gt; * Some references:&lt;/span&gt; &lt;span class="cm"&gt; *     http://www.cocoadev.com/index.pl?MethodSwizzling&lt;/span&gt; &lt;span class="cm"&gt; *     http://samsoff.es/posts/customize-uikit-with-method-swizzling&lt;/span&gt; &lt;span class="cm"&gt; *     http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocCategories.html#//apple_ref/doc/uid/TP30001163-CH20-SW1&lt;/span&gt; &lt;span class="cm"&gt; *     http://developer.apple.com/iphone/library/documentation/uikit/reference/UIKitFunctionReference/Reference/reference.html&lt;/span&gt; &lt;span class="cm"&gt; *     http://developer.apple.com/mac/library/documentation/GraphicsImaging/Reference/CGContext/Reference/reference.html&lt;/span&gt; &lt;span class="cm"&gt; *     http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html&lt;/span&gt; &lt;span class="cm"&gt; *&lt;/span&gt; &lt;span class="cm"&gt; */&lt;/span&gt;   &lt;span class="cm"&gt;/* UINavigationBar+Additions.h */&lt;/span&gt; &lt;span class="cp"&gt;#import &lt;foundation h=""&gt;&lt;/foundation&gt;&lt;/span&gt;  &lt;span class="k"&gt;@interface&lt;/span&gt; &lt;span class="nc"&gt;UINavigationBar&lt;/span&gt; &lt;span class="nl"&gt;(Additions)&lt;/span&gt;  &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="nl"&gt;drawRectCustom:&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;CGRect&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;rect&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="k"&gt;@end&lt;/span&gt;   &lt;span class="cm"&gt;/* UINavigationBar+Additions.m */&lt;/span&gt; &lt;span class="cp"&gt;#import "UINavigationBar+Additions.h"&lt;/span&gt;   &lt;span class="k"&gt;@implementation&lt;/span&gt; &lt;span class="nc"&gt;UINavigationBar&lt;/span&gt; &lt;span class="nl"&gt;(Additions)&lt;/span&gt;   &lt;span class="c1"&gt;// When the object is set up it calls drawRect, which then loads this method because of the method swizzling&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="nl"&gt;drawRectCustom:&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;CGRect&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;rect&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;      &lt;span class="c1"&gt;// If the style of the bar is the default style, apply our custom visuals&lt;/span&gt;     &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;barStyle&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;UIBarStyleDefault&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;          &lt;span class="c1"&gt;// Create the drawing context&lt;/span&gt;         &lt;span class="n"&gt;CGContextRef&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;UIGraphicsGetCurrentContext&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;          &lt;span class="c1"&gt;// Set the background color of the navbar&lt;/span&gt;         &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="n"&gt;UIColor&lt;/span&gt; &lt;span class="n"&gt;blackColor&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;set&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;         &lt;span class="n"&gt;CGRect&lt;/span&gt; &lt;span class="n"&gt;fillRect&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;CGRectMake&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;         &lt;span class="n"&gt;CGContextFillRect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fillRect&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;          &lt;span class="c1"&gt;// Create an instance of the image we want to draw&lt;/span&gt;         &lt;span class="n"&gt;UIImage&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;logo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;UIImage&lt;/span&gt; &lt;span class="nl"&gt;imageWithContentsOfFile:&lt;/span&gt;&lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="n"&gt;NSBundle&lt;/span&gt; &lt;span class="n"&gt;mainBundle&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="nl"&gt;pathForResource:&lt;/span&gt;&lt;span class="s"&gt;@"path/to/logo"&lt;/span&gt; &lt;span class="nl"&gt;ofType:&lt;/span&gt;&lt;span class="s"&gt;@"png"&lt;/span&gt;&lt;span class="p"&gt;]];&lt;/span&gt;          &lt;span class="c1"&gt;// Get the absolute center points relative to the image and the screen&lt;/span&gt;         &lt;span class="n"&gt;NSNumber&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;centerX&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;NSNumber&lt;/span&gt; &lt;span class="nl"&gt;numberWithFloat:&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;logo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)];&lt;/span&gt;         &lt;span class="n"&gt;NSNumber&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;centerY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;NSNumber&lt;/span&gt; &lt;span class="nl"&gt;numberWithFloat:&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;logo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)];&lt;/span&gt;          &lt;span class="c1"&gt;// Draw the image&lt;/span&gt;         &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;logo&lt;/span&gt; &lt;span class="nl"&gt;drawInRect:&lt;/span&gt;&lt;span class="n"&gt;CGRectMake&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;centerX&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;floatValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;centerY&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;floatValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;logo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;logo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;)];&lt;/span&gt;          &lt;span class="c1"&gt;// End execution of the method&lt;/span&gt;         &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="p"&gt;}&lt;/span&gt;      &lt;span class="c1"&gt;// By this time drawRectCustom is actually referencing to drawRect&lt;/span&gt;     &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt; &lt;span class="nl"&gt;drawRectCustom:&lt;/span&gt;&lt;span class="n"&gt;rect&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;   &lt;span class="k"&gt;@end&lt;/span&gt;   &lt;span class="cm"&gt;/* main.m */&lt;/span&gt; &lt;span class="cp"&gt;#import &lt;uikit h=""&gt;&lt;/uikit&gt;&lt;/span&gt; &lt;span class="cp"&gt;#import &lt;objc h=""&gt; &lt;/objc&gt;&lt;/span&gt;&lt;span class="c1"&gt;// Needed for the Method objects&lt;/span&gt; &lt;span class="cp"&gt;#import "UINavigationBar+Additions.h" &lt;/span&gt;&lt;span class="c1"&gt;// Needed to reference the method we wish to swizzle&lt;/span&gt;  &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;argc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[])&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;     &lt;span class="n"&gt;NSAutoreleasePool&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;pool&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="n"&gt;NSAutoreleasePool&lt;/span&gt; &lt;span class="n"&gt;alloc&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;init&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;      &lt;span class="cm"&gt;/* Method Swizzling */&lt;/span&gt;      &lt;span class="c1"&gt;// Get our drawRectCustom method&lt;/span&gt;     &lt;span class="n"&gt;Method&lt;/span&gt; &lt;span class="n"&gt;drawRectCustom&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;class_getInstanceMethod&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;UINavigationBar&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="k"&gt;@selector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;drawRectCustom:&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;      &lt;span class="c1"&gt;// Get the original drawRect method&lt;/span&gt;     &lt;span class="n"&gt;Method&lt;/span&gt; &lt;span class="n"&gt;drawRect&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;class_getInstanceMethod&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;UINavigationBar&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="k"&gt;@selector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;drawRect:&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;      &lt;span class="c1"&gt;// Swap the methods, drawRect now becomes drawRectCustom and vice-versa&lt;/span&gt;     &lt;span class="n"&gt;method_exchangeImplementations&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;drawRect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;drawRectCustom&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;      &lt;span class="cm"&gt;/* End Method Swizzling */&lt;/span&gt;      &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;retVal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;UIApplicationMain&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;argc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;      &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;pool&lt;/span&gt; &lt;span class="n"&gt;release&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;     &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;retVal&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;   &lt;span class="k"&gt;@end&lt;/span&gt; &lt;/pre&gt;&lt;/div&gt; &lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-523886371141570611?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/523886371141570611/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=523886371141570611' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/523886371141570611'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/523886371141570611'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2011/06/example-of-method-swizzling-by.html' title='an example of method swizzling by customizing an UINavigationBar'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-4554274880466205414</id><published>2011-05-28T20:13:00.001-07:00</published><updated>2011-05-28T20:13:33.428-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><title type='text'>几个常用的Objective-C开源类库</title><content type='html'>&lt;h2&gt;几个常用的Objective-C开源类库&lt;/h2&gt; &lt;p class="p-who"&gt;发布者: indream 分类: &lt;a href="http://freegezi.net/blog/category/ios%e5%bc%80%e5%8f%91" title="查看 ios开发 的全部文章" rel="category tag"&gt;ios开发&lt;/a&gt;|&lt;a href="http://freegezi.net/blog/category/%e8%bd%ac%e8%bd%bd" title="查看 转载 的全部文章" rel="category tag"&gt;转载&lt;/a&gt;&lt;/p&gt;    &lt;div class="p-con"&gt; &lt;p&gt;1. &lt;a href="http://code.google.com/p/json-framework/" target="_blank"&gt;json-framework&lt;/a&gt;A strict JSON parser/generator for Objective-C&lt;br /&gt;2. &lt;a href="http://code.google.com/p/google-toolbox-for-mac/source/browse/trunk/Foundation/" target="_blank"&gt;GTMBase64 &lt;/a&gt;Google Toolbox for Mac&lt;br /&gt;3. &lt;a href="https://github.com/TouchCode/TouchXML" target="_blank"&gt;TouchXML&lt;/a&gt; xml解析&lt;br /&gt;4. &lt;a href="https://github.com/ldandersen/scifihifi-iphone" target="_blank"&gt;SFHFKeychainUtils&lt;/a&gt; 安全保存用户密码到keychain中&lt;br /&gt;5. &lt;a href="https://github.com/jdg/MBProgressHUD" target="_blank"&gt;MBProgressHUD&lt;/a&gt; 很棒的一个加载等待特效框架&lt;br /&gt;6. &lt;a href="http://allseeing-i.com/ASIHTTPRequest" target="_blank"&gt;ASIHTTPRequest&lt;/a&gt; http等相关协议封装&lt;br /&gt;7. &lt;a href="https://github.com/enormego/EGOTableViewPullRefresh" target="_blank"&gt;EGORefreshTableHeaderView&lt;/a&gt; 下拉刷新代码&lt;br /&gt;8. &lt;a href="http://www.markj.net/iphone-asynchronous-table-image/" target="_blank"&gt;AsyncImageView&lt;/a&gt; 异步加载图片并缓存代码&lt;br /&gt;9. &lt;a href="http://blog.blackwhale.at/" target="_blank"&gt;类似setting的竖立也分栏程序&lt;/a&gt;&lt;/p&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-4554274880466205414?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/4554274880466205414/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=4554274880466205414' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/4554274880466205414'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/4554274880466205414'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2011/05/objective-c.html' title='几个常用的Objective-C开源类库'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-2464240661086046337</id><published>2011-05-19T13:59:00.001-07:00</published><updated>2011-05-19T13:59:34.257-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><title type='text'>How To Choose The Best XML Parser for Your iPhone Project</title><content type='html'>&lt;h1&gt;How To Choose The Best XML Parser for Your iPhone Project&lt;/h1&gt;        &lt;div id="attachment_554" class="wp-caption alignright" style="width: 260px"&gt;&lt;a href="http://www.raywenderlich.com/553/how-to-chose-the-best-xml-parser-for-your-iphone-project/xmlparserlist" rel="attachment wp-att-554"&gt;&lt;img src="http://d1xzuxjlafny7l.cloudfront.net/wp-content/uploads/2010/02/XMLParserList.jpg" alt="XMLPerformance Test App Extended For 3rd Party Libraries" title="XMLPerformance Test App Extended To Compare 3rd Party Libraries" class="size-full wp-image-554" height="375" width="250" /&gt;&lt;/a&gt;&lt;p class="wp-caption-text"&gt;XMLPerformance Test App Extended To Compare 3rd Party Libraries&lt;/p&gt;&lt;/div&gt; &lt;p&gt;There are a lot of options when it comes to parsing XML on the  iPhone.  The iPhone SDK comes with two different libraries to choose  from, and there are several popular third party libraries available such  as TBXML, TouchXML, KissXML, TinyXML, and GDataXML.  How is a developer  to choose?&lt;/p&gt; &lt;p&gt;I have been recently taking a look at the various options out there,  and ended up extending the XMLPerformance sample from Apple to try out  each of the above libraries to learn how they worked and compare their  performance.  I thought I’d share what I’ve learned thus far to others  who might be searching for the best XML library for their iPhone  project.&lt;/p&gt; &lt;p&gt;In this article we’ll give a detailed comparison of the features and  performance of the most popular iPhone libraries, explain how to choose  between them, and give a sample project showing how to read XML data  using each of the above libraries.&lt;/p&gt; &lt;h2&gt;SAX vs. DOM&lt;/h2&gt; &lt;p&gt;Before we begin, I wanted to make sure everyone is aware of the most  important difference between XML parsers: whether the parser is a SAX or  a DOM parser.&lt;/p&gt; &lt;ul&gt;&lt;li&gt;A &lt;em&gt;SAX parser&lt;/em&gt; is one where your code is notified as the  parser walks through the XML tree, and you are responsible for keeping  track of state and constructing any objects you might want to keep track  of the data as the parser marches through.&lt;/li&gt;&lt;li&gt;A &lt;em&gt;A DOM parser&lt;/em&gt; reads the entire document and builds up an  in-memory representation that you can query for different elements.   Often, you can even construct XPath queries to pull out particular  pieces.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Ok, now let’s discuss some of the libraries!&lt;/p&gt; &lt;h2&gt;The Most Popular XML Parsers for the iPhone&lt;/h2&gt; &lt;p&gt;In my research, here’s what seemed to me to be the most popular XML Parsers for the iPhone, and a brief description of each one:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;a href="http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/Reference/Reference.html"&gt;NSXMLParser&lt;/a&gt;  is a SAX parser included by default with the iPhone SDK.  It’s written  in Objective-C and is quite straightforward to use, but perhaps not  quite as easy as the DOM model.&lt;/li&gt;&lt;li&gt;&lt;a href="http://xmlsoft.org/"&gt;libxml2&lt;/a&gt; is an Open Source library  that is included by default with the iPhone SDK.  It is a C-based API,  so is a bit more work to use than NSXML.  The library supports both DOM  and SAX processing.  The libxml2 SAX processor is especially cool, as it  has a unique feature of being able to parse the data as it’s being  read.  For example, you could be reading a large XML document from the  network and displaying data that you’re reading for it to the user while  you’re still downloading.&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.tbxml.co.uk/"&gt;TBXML&lt;/a&gt; is a lightweight DOM XML  parser designed to be as quick as possible while consuming few memory  resources.  It saves time by not performing validation, not supporting  XPath, and by being read-only – i.e. you can read XML with it, but you  can’t then modify the XML and write it back out again.&lt;/li&gt;&lt;li&gt;&lt;a href="http://code.google.com/p/touchcode/wiki/TouchXML"&gt;TouchXML&lt;/a&gt; is an NSXML style DOM XML parser for the iPhone.  Like TBXML, it is also read-only, but unlike TBXML it does support XPath.&lt;/li&gt;&lt;li&gt;&lt;a href="http://code.google.com/p/kissxml"&gt;KissXML&lt;/a&gt; is another  NSSXML style DOM XML parser for the iPhone, actually based on TouchXML.   The main difference is KissXML also supports editing and writing XML as  well as reading.&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.grinninglizard.com/tinyxml/"&gt;TinyXML&lt;/a&gt; is a  small C-based DOM XML parser that consists of just four C files and two  headers.  It supports both reading and writing XML documents, but it  does not support XPath on its own.  However, you can use a related  library – TinyXPath – for that.&lt;/li&gt;&lt;li&gt;&lt;a href="http://code.google.com/p/gdata-objectivec-client/source/browse/trunk/Source/XMLSupport/"&gt;GDataXML&lt;/a&gt;  is yet another NSXML style DOM XML parser for the iPhone, developed by  Google as part of their Objective-C client library.  Consisting of just a  M file and a header, it supports both reading and writing XML documents  and XPath queries.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Ok, now let’s start comparing all these libraries!&lt;/p&gt; &lt;h2&gt;XML Parser Performance Comparison App&lt;/h2&gt; &lt;p&gt;&lt;a href="http://www.raywenderlich.com/553/how-to-chose-the-best-xml-parser-for-your-iphone-project/xmlparserstats" rel="attachment wp-att-555"&gt;&lt;img src="http://d1xzuxjlafny7l.cloudfront.net/wp-content/uploads/2010/02/XMLParserStats.jpg" alt="XML Parser Stats Display in Test App" title="XML Parser Stats Display in Test App" class="alignnone size-full wp-image-555" height="480" width="320" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Apple has made an excellent code sample called XMLPerformance that  allows you to compare the time it takes to parse a ~900KB XML document  containing the top 300 iTunes songs with both the NSXML and libxml2  APIs.  &lt;/p&gt; &lt;p&gt;The sample allows you to choose a parsing method and then parse the  document, and it keeps statistics on how long it took to download the  file and parse the file in a database.  You can then go to a statistics  screen to see the average download and parse times for each method. &lt;/p&gt; &lt;p&gt;I thought this would be an ideal way to test out how these various  APIs performed against each other, so I extended the sample to include  all of the above libraries.  You can download the updated project below  if you want to try it out on your device.  It also serves as a nice  example of how to use each of the above APIs!&lt;/p&gt; &lt;p&gt;&lt;a href="http://d1xzuxjlafny7l.cloudfront.net/downloads/XMLPerformance.zip"&gt;Download Updated XMLPerformance Project&lt;/a&gt;&lt;/p&gt; &lt;p&gt;A note on the project: if the library included XPath support, I used  it for a single lookup, because I felt it represented the way the  library would be used in practice.  But of course XPath is generally  slower than manually walking through the tree, so it adds to the  benchmarks for those libraries.&lt;/p&gt; &lt;p&gt;So anyway – I’ll discuss the results of how things performed on my  device here with the sample written as-is – but feel free to give it a  shot on your device, or tweak the code based on the actual XML data you  need to parse!&lt;/p&gt; &lt;h2&gt;XML Parser Performance Comparison&lt;/h2&gt; &lt;p&gt;Here’s some graphs that shows how quickly the various parsers parsed the XML document on my device (an iPhone 3Gs):&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.raywenderlich.com/553/how-to-chose-the-best-xml-parser-for-your-iphone-project/xmlparserspeed" rel="attachment wp-att-556"&gt;&lt;img src="http://d1xzuxjlafny7l.cloudfront.net/wp-content/uploads/2010/02/XMLParserSpeed.jpg" alt="Parsing Time By Parser" title="Parsing Time By Parser" class="alignnone size-full wp-image-556" height="270" width="617" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;As you can see here, NSXMLParser was the slowest method by far.   TBXML was the fastest, which makes sense because many features were  taken out in order to optimize parse time for reading only.&lt;/p&gt; &lt;p&gt;I was surprised, however, to see that TBXML and some of the other DOM  parsing methods performed faster than libxml2′s SAX parser, which I had  thought would be the fastest of all of the methods.  I haven’t profiled  it, but my guess as to why it is slower is because of the frequent  string compares needed to parse the document in the SAX method.&lt;/p&gt; &lt;p&gt;However, don’t discount libxml2′s SAX method by looking at this  chart.  Remember that libxml2 is the only one of these methods that can  parse the document as it’s reading in – so it can let your app start  displaying data right away rather than having to let the download finish  first.&lt;/p&gt; &lt;p&gt;Ok, here’s a graph that shows the peak memory usage by parser (this  was obtained through running the various methods through the Object  Allocations tool):&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.raywenderlich.com/553/how-to-chose-the-best-xml-parser-for-your-iphone-project/xmlparsermemoryusage" rel="attachment wp-att-557"&gt;&lt;img src="http://d1xzuxjlafny7l.cloudfront.net/wp-content/uploads/2010/02/XMLParserMemoryUsage.jpg" alt="Memory Usage By Parser" title="Memory Usage By Parser" class="alignnone size-full wp-image-557" height="283" width="614" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Note that the DOM methods usually require more memory overhead than  the SAX methods (with the exception of TBXML, which is indeed quite  efficient).  This is something to consider when you are dealing with  especially large documents, given the memory constraints on an iPhone.&lt;/p&gt; &lt;p&gt;Also note that libxml2′s SAX method is the best option as far as peak  memory usage is concerned (and I suspect it would scale better than the  others as well).&lt;/p&gt; &lt;p&gt;Finally, let’s wrap up with a chart that summarizes the differences between the parsers and everything we’ve discussed above:&lt;/p&gt; &lt;table&gt; &lt;tbody&gt;&lt;tr&gt; &lt;th&gt;&lt;br /&gt;&lt;/th&gt; &lt;th&gt;NSXML&lt;/th&gt; &lt;th&gt;libxml2 – SAX&lt;/th&gt; &lt;th&gt;TBXML&lt;/th&gt; &lt;th&gt;TouchXML&lt;/th&gt; &lt;th&gt;KissXML&lt;/th&gt; &lt;th&gt;TinyXML&lt;/th&gt; &lt;th&gt;GDataXML&lt;/th&gt; &lt;th&gt;libxml2 – DOM&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="key"&gt;Included with SDK?&lt;/td&gt; &lt;td class="good"&gt;Yes&lt;/td&gt; &lt;td class="good"&gt;Yes&lt;/td&gt; &lt;td&gt;No&lt;/td&gt; &lt;td&gt;No&lt;/td&gt; &lt;td&gt;No&lt;/td&gt; &lt;td&gt;No&lt;/td&gt; &lt;td&gt;No&lt;/td&gt; &lt;td&gt;Yes&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="key"&gt;Seconds to Parse&lt;/td&gt; &lt;td&gt;1.87&lt;/td&gt; &lt;td class="good"&gt;1.19&lt;/td&gt; &lt;td class="good"&gt;0.68&lt;/td&gt; &lt;td class="good"&gt;1.1&lt;/td&gt; &lt;td&gt;1.37&lt;/td&gt; &lt;td&gt;1.27&lt;/td&gt; &lt;td class="good"&gt;1.07&lt;/td&gt; &lt;td class="good"&gt;0.84&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="key"&gt;Peak Memory Usage&lt;/td&gt; &lt;td class="good"&gt;3.11&lt;/td&gt; &lt;td class="good"&gt;3.01&lt;/td&gt; &lt;td class="good"&gt;3.07&lt;/td&gt; &lt;td&gt;6.5&lt;/td&gt; &lt;td&gt;5.25&lt;/td&gt; &lt;td&gt;4.8&lt;/td&gt; &lt;td&gt;4.15&lt;/td&gt; &lt;td&gt;4.97&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="key"&gt;Parse While Downloading?&lt;/td&gt; &lt;td&gt;No&lt;/td&gt; &lt;td class="good"&gt;Yes&lt;/td&gt; &lt;td&gt;No&lt;/td&gt; &lt;td&gt;No&lt;/td&gt; &lt;td&gt;No&lt;/td&gt; &lt;td&gt;No&lt;/td&gt; &lt;td&gt;No&lt;/td&gt; &lt;td&gt;No&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="key"&gt;Edit/Save XML?&lt;/td&gt; &lt;td&gt;No&lt;/td&gt; &lt;td&gt;No&lt;/td&gt; &lt;td&gt;No&lt;/td&gt; &lt;td&gt;No&lt;/td&gt; &lt;td class="good"&gt;Yes&lt;/td&gt; &lt;td class="good"&gt;Yes&lt;/td&gt; &lt;td class="good"&gt;Yes&lt;/td&gt; &lt;td class="good"&gt;Yes&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="key"&gt;XPath Support?&lt;/td&gt; &lt;td&gt;No&lt;/td&gt; &lt;td&gt;No&lt;/td&gt; &lt;td&gt;No&lt;/td&gt; &lt;td class="good"&gt;Yes&lt;/td&gt; &lt;td class="good"&gt;Yes&lt;/td&gt; &lt;td class="good"&gt;Yes*&lt;/td&gt; &lt;td class="good"&gt;Yes&lt;/td&gt; &lt;td class="good"&gt;Yes&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="key"&gt;C or Obj-C&lt;/td&gt; &lt;td class="good"&gt;Obj-C&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td class="good"&gt;Obj-C&lt;/td&gt; &lt;td class="good"&gt;Obj-C&lt;/td&gt; &lt;td class="good"&gt;Obj-C&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td class="good"&gt;Obj-C&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="key"&gt;License&lt;/td&gt; &lt;td&gt;Apple&lt;/td&gt; &lt;td&gt;MIT&lt;/td&gt; &lt;td&gt;MIT&lt;/td&gt; &lt;td&gt;MIT&lt;/td&gt; &lt;td&gt;MIT&lt;/td&gt; &lt;td&gt;ZLib&lt;/td&gt; &lt;td&gt;Apache&lt;/td&gt; &lt;td&gt;MIT&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;* = with TinyXPath&lt;/p&gt; &lt;h2&gt;Which To Choose?&lt;/h2&gt; &lt;p&gt;Which XML parser to choose really depends on what you want to do with the parser.&lt;/p&gt; &lt;ul&gt;&lt;li&gt;If you just want to &lt;em&gt;read small XML documents&lt;/em&gt;, performance  doesn’t matter as much with small documents.  You probably want to pick  something with XPath support and something that is written in  Objective-C to make your job easier.  So I’d recommend either TouchXML,  KissXML, or GDataXML for this case.&lt;/li&gt;&lt;li&gt;If you want to both &lt;em&gt;read and write small XML documents&lt;/em&gt;,  again performance doesn’t matter as much as functionality and ease of  use.  You probably want to pick something with XPath support, written in  Objective-C, with read/write capability.  So I’d recommend KissXML or  GDataXML for this case.&lt;/li&gt;&lt;li&gt;If you want to &lt;em&gt;read extremely large XML documents&lt;/em&gt;,  performance is the critical issue here.  You’ll want to consider libxml2  SAX, TBXML, or libxml DOM for this, depending on what your exact  situation is.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;What about the ones I didn’t mention?&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;em&gt;NSXML&lt;/em&gt; is a decent choice if you’re dealing with relatively  small documents, and you don’t feel like adding a third party library to  the SDK.&lt;/li&gt;&lt;li&gt;&lt;em&gt;TinyXML&lt;/em&gt; could be an OK choice for medium sized documents if  you already have experience with the API and are comfortable with C as  it ports quite easily over to the iPhone.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;I took a look at two other XML libraries during the course of this  investigation (VTD-XML and Objective-XML), but I couldn’t get them  working.  If someone else has had more luck with these, feel free to  extend the sample project to include them!&lt;/p&gt; &lt;h2&gt;Where To Go From Here?&lt;/h2&gt; &lt;p&gt;If you’re looking for some help using one of these libraries, check out my post on &lt;a href="http://www.raywenderlich.com/725/how-to-read-and-write-xml-documents-with-gdataxml"&gt;How to Read and Write XML Documents with GDataXML&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;And if anyone has any additional feedback about these libraries or tips that may help other developers, please chime in below! &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-2464240661086046337?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/2464240661086046337/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=2464240661086046337' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/2464240661086046337'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/2464240661086046337'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2011/05/how-to-choose-best-xml-parser-for-your.html' title='How To Choose The Best XML Parser for Your iPhone Project'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-1075344306921885623</id><published>2011-05-18T11:00:00.001-07:00</published><updated>2011-05-18T11:00:23.025-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><title type='text'>Singletons, AppDelegates and top-level data.</title><content type='html'>&lt;h3 class="post-title entry-title"&gt; &lt;a href="http://cocoawithlove.com/2008/11/singletons-appdelegates-and-top-level.html"&gt;Singletons, AppDelegates and top-level data.&lt;/a&gt; &lt;/h3&gt;  &lt;span class="introduction"&gt;&lt;p&gt;If you require only a single instance of  an object in your application, where should it go? How should you  control and manage it? Here are some different approaches, their  implementations, their strengths and their weaknesses.&lt;/p&gt;&lt;/span&gt;  &lt;span class="fullpost"&gt; &lt;h4&gt;A little about global variables&lt;/h4&gt;  &lt;h5&gt;They should scare you&lt;/h5&gt;  &lt;p&gt;&lt;em&gt;&lt;a href="http://en.wikipedia.org/wiki/Global_variable"&gt;Global variables&lt;/a&gt;&lt;/em&gt;  is a term that invokes a sense of dread in experienced programmers.  They are feared because a program filled with global variables (when it  should use scoped variables instead) is a program without structure; a  totally unmanageable mess.&lt;/p&gt;  &lt;p&gt;This post will be entirely about writing and using global variables.&lt;/p&gt;  &lt;h5&gt;They're essential&lt;/h5&gt;  &lt;p&gt;The reality is that applications need to have &lt;em&gt;some&lt;/em&gt; global state; we must have global variables. A variable will need to be global if &lt;strong&gt;all&lt;/strong&gt; of the following are true:&lt;/p&gt;  &lt;ol&gt;&lt;li&gt;No other object owns, manages or is otherwise responsible for it&lt;/li&gt;&lt;li&gt;There is exactly one in the whole program&lt;/li&gt;&lt;li&gt;It is not a constant (like a string or number)&lt;/li&gt;&lt;/ol&gt;  &lt;p&gt;If all of these are true, then you should use a global variable.&lt;/p&gt;  &lt;blockquote&gt;If you're wondering, variables that fall outside these rules should be (respectively): &lt;ol&gt;&lt;li&gt;child variables of the object that manages them&lt;/li&gt;&lt;li&gt;children of the object that manages the collection&lt;/li&gt;&lt;li&gt;a &lt;code&gt;#define&lt;/code&gt; or a &lt;code&gt;const&lt;/code&gt; (constants are state for the compiler, not the program)&lt;/li&gt;&lt;/ol&gt;&lt;/blockquote&gt;  &lt;h5&gt;In Cocoa, they're not quite global&lt;/h5&gt;  &lt;p&gt;Actually, what I will be showing are the "in practice" global  variables of a Cocoa program — in reality, none of the techniques I show  you will be &lt;em&gt;true&lt;/em&gt; global variables in the Standard C Language  sense but these approaches have replaced true global variables in Cocoa  programs in almost all cases.&lt;/p&gt;  &lt;p&gt;I will be showing you top-level child objects (children of the  application delegate) and singleton objects. Explaining why these are  normally considered equivalent to globals:&lt;/p&gt;  &lt;ul&gt;&lt;li&gt;The application object is the first constructed object in the  program from which all other hierarchically arranged objects are  constructed, making it effectively the top-level scope in the program  (like a global scope). The application delegate should be considered a  basic extension of the application object itself (especially since you  should never override the application class).&lt;/li&gt;&lt;li&gt;A &lt;em&gt;&lt;a href="http://en.wikipedia.org/wiki/Singleton_pattern"&gt;singleton&lt;/a&gt;&lt;/em&gt;  is an object that can be allocated only once (and can't be deleted) —  making it a single, global instance. While singletons are stored in a  true global variable, they are never accessed that way in Objective-C (a  class method is used to access them), providing a least some  abstraction around the implementation.&lt;/li&gt;&lt;/ul&gt;  &lt;h4&gt;AppDelegates and AppControllers&lt;/h4&gt;  &lt;p&gt;As every Cocoa programmer knows, an application delegate is created in the MainMenu.xib file:&lt;/p&gt;  &lt;img src="http://lh5.ggpht.com/_gfktUGS0ov0/SR-dWIG550I/AAAAAAAAAQI/2cIfqkhD8xk/appdelegatecreation.png?imgmax=800" alt="appdelegatecreation.png" border="0" height="269" width="421" /&gt;  &lt;p&gt;or the MainWindow.xib file for the iPhoneSDK.&lt;/p&gt;  &lt;p&gt;A globally accessed variable can be initialized in the &lt;code&gt;applicationDidFinishLauching&lt;/code&gt; delegate method:&lt;/p&gt;  &lt;pre&gt;- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {     myGlobalObject = [[MyGlobalObject alloc] init]; }&lt;/pre&gt;  &lt;p&gt;and assuming &lt;code&gt;myGlobalObject&lt;/code&gt; has an associated getter method, you can now access it globally using:&lt;/p&gt;  &lt;pre&gt;[[NSApp delegate] myGlobalObject]&lt;/pre&gt;  &lt;p&gt;or on the iPhone:&lt;/p&gt;  &lt;pre&gt;[[UIApplication sharedApplication].delegate myGlobalObject]&lt;/pre&gt;  &lt;p&gt;Since the &lt;code&gt;delegate&lt;/code&gt; property returns an &lt;code&gt;id&lt;/code&gt; (instead of the actual class of your delegate), you can't use property notation for the &lt;code&gt;myGlobalObject&lt;/code&gt; itself unless the &lt;code&gt;myGlobalObject&lt;/code&gt;  is a property and you wrap the delegate in parentheses and inside the  parentheses cast the delegate to your application delegate's class, like  this:&lt;/p&gt;  &lt;pre&gt;((MyAppDelegate *)[UIApplication sharedApplication].delegate).myGlobalObject&lt;/pre&gt;  &lt;p&gt;Although I have seen people declare the following macro in their delegate's header:&lt;/p&gt;  &lt;pre&gt;#define UIAppDelegate \     ((MyAppDelegate *)[UIApplication sharedApplication].delegate)&lt;/pre&gt;  &lt;p&gt;which then allows you to use:&lt;/p&gt;  &lt;pre&gt;UIAppDelegate.myGlobalObject&lt;/pre&gt;  &lt;p&gt;from anywhere that includes your delegate's header.&lt;/p&gt;  &lt;h4&gt;Why AppDelegates are bad&lt;/h4&gt;  &lt;p&gt;Having explained that the above &lt;em&gt;could&lt;/em&gt; be done, I will tell you that in my programs, I avoid using the &lt;code&gt;AppDelegate&lt;/code&gt; for anything other than:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;implemenations of the &lt;code&gt;NSApplication&lt;/code&gt; delegate methods (including &lt;code&gt;applicationDidFinishLaunching:&lt;/code&gt; to finalize application construction)&lt;/li&gt;&lt;li&gt;handling menu items for items that don't exist in a window (for example, opening the application Preferences window)&lt;/li&gt;&lt;/ul&gt;  &lt;p&gt;Relying on your &lt;code&gt;AppDelegate&lt;/code&gt; object to manage your global  variables can quickly get scary for the same reason that global  variables in general are considered scary: you can easily put too much  into this top level and it becomes a big, unstructured mess. This  problem is an anti-pattern, often called the &lt;a href="http://en.wikipedia.org/wiki/Big_ball_of_mud"&gt;Big Ball of Mud&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;It is a bad idea structurally for two reasons. The first is &lt;em&gt;encapsulation&lt;/em&gt;. The AppDelegate should only really be connected to things related to the AppDelegate (i.e. the &lt;code&gt;NSApplication&lt;/code&gt;  object and related state). If you store data related to other objects  inside the AppDelegate, you rob those other objects of control over  themselves.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Separation of concerns&lt;/em&gt; is the other serious problem. It is  not the application delegate's responsibility to be the gatekeeper and  manager of non-Application-related variables within the program.&lt;/p&gt;  &lt;p&gt;A well-designed program organizes its classes so that they are all  discrete, self-contained entities, shoving connections to everything  into the &lt;code&gt;AppDelegate&lt;/code&gt; violates this idea.&lt;/p&gt;  &lt;h4&gt;Singletons in Cocoa&lt;/h4&gt;  &lt;p&gt;The solution to the encapsulation problem is to create classes that  manage any global data as discreet modules. This is done through a  singleton.&lt;/p&gt;  &lt;p&gt;The basic recipe for making a singleton is given by Apple: &lt;a href="http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/TP40002974-CH4-SW32"&gt;Creating a Singleton Instance&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;I personally like to put these singleton methods into a macro, which you can download in my &lt;a href="http://projectswithlove.com/projects/SynthesizeSingleton.h.zip"&gt;SynthesizeSingleton.h file&lt;/a&gt;. If you &lt;code&gt;#import&lt;/code&gt; this header at the top of a class implementation, then all you need to do is write:&lt;/p&gt;  &lt;pre&gt;SYNTHESIZE_SINGLETON_FOR_CLASS(MyClassName);&lt;/pre&gt;  &lt;p&gt;inside the &lt;code&gt;@implementation MyClassName&lt;/code&gt; declaration and your class will become a singleton. You will also need to add the line:&lt;/p&gt;  &lt;pre&gt;+ (MyClassName *)sharedMyClassName;&lt;/pre&gt;  &lt;p&gt;to the header file for &lt;code&gt;MyClassName&lt;/code&gt; so the singleton accessor method can be found from other source files if they &lt;code&gt;#import&lt;/code&gt; the header.&lt;/p&gt;  &lt;p&gt;Once your class is a singleton, you can access the instance of it using the line:&lt;/p&gt;  &lt;pre&gt;[MyClassName sharedMyClassName];&lt;/pre&gt;  &lt;blockquote&gt;&lt;strong&gt;Note&lt;/strong&gt;: A singleton does not need to be explicitly allocated or initialized (the &lt;code&gt;alloc&lt;/code&gt; and &lt;code&gt;init&lt;/code&gt; methods will be called automatically on first access) but you can still implement the default &lt;code&gt;init&lt;/code&gt; method if you want to perform initialization.&lt;/blockquote&gt;  &lt;h4&gt;Advantages of a singleton&lt;/h4&gt;  &lt;p&gt;A well-designed singleton is a discrete, self-managing object that manages a specific role within your program.&lt;/p&gt;  &lt;p&gt;Where variables hung off the Application delegate may have nothing in  common with the delegate object itself, a singleton should be entirely  focussed on its own specific role and responsibilities.&lt;/p&gt;  &lt;p&gt;Search the Mac OS X 10.5 Reference in XCode for methods that begin  with "shared" to see the ways in which Apple use singletons to create  "manager" objects which allow you to get, set and manipulate entities  that exist only once in a program.&lt;/p&gt;  &lt;p&gt;Also, since the singleton is accessed through a method, there is some  abstraction around the specific implementation — you could move from a  true singleton to a per-thread based implementation if you needed,  without changing the external interface.&lt;/p&gt;  &lt;h4&gt;Conclusion&lt;/h4&gt;  &lt;p&gt;Don't use globals unless you &lt;em&gt;need&lt;/em&gt; to do so. An overwhelming majority of the data in your program has a sensible parent that is &lt;em&gt;not&lt;/em&gt; the top-level. Singletons and top-level data should be used only when the data they contain truly belongs at the top level.&lt;/p&gt;  &lt;p&gt;Cocoa singletons are flexible and useful when you need them. Using  your application delegate to hold top-level data will work but try to  limit its responsibilities to MainMenu.xib allocated objects where  possible.&lt;/p&gt;  &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-1075344306921885623?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/1075344306921885623/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=1075344306921885623' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/1075344306921885623'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/1075344306921885623'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2011/05/singletons-appdelegates-and-top-level.html' title='Singletons, AppDelegates and top-level data.'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_gfktUGS0ov0/SR-dWIG550I/AAAAAAAAAQI/2cIfqkhD8xk/s72-c/appdelegatecreation.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-5746892052525824440</id><published>2011-05-16T13:40:00.000-07:00</published><updated>2011-05-16T13:41:06.192-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><title type='text'>Posts Tagged UIActivityIndicatorView</title><content type='html'>&lt;h1 class="pagetitle"&gt;Posts Tagged UIActivityIndicatorView&lt;/h1&gt;                               &lt;h3&gt;&lt;a href="http://www.chrisdanielson.com/2009/12/04/apple-iphone-web-kit-with-activity-indicator/" rel="bookmark" title="Permanent Link: Apple iPhone Web Kit with Activity Indicator"&gt;Apple iPhone Web Kit with Activity Indicator&lt;/a&gt;&lt;/h3&gt;                  &lt;div class="postheader"&gt;             &lt;div class="postinfo"&gt;             &lt;p&gt;             Posted by &lt;a href="http://www.chrisdanielson.com/author/chris/" title="Posts by Chris Danielson "&gt;Chris Danielson&lt;/a&gt; in &lt;a href="http://www.chrisdanielson.com/category/iphone-development/" title="View all posts in iPhone Development" rel="category tag"&gt;iPhone Development&lt;/a&gt; on December 4th, 2009 &lt;span class="editlink"&gt;&lt;/span&gt;&lt;/p&gt;             &lt;/div&gt;         &lt;/div&gt;                         &lt;p&gt;Welcome to the club of searching for an overly simple  UIWebView a.k.a. WebKit example!  In this example, I’ll show you simply  how to hand code a quick UIWebView into your program as well as to add a  UIActivityIndicatorView a.k.a. an activity indicator.  Without jabbing  Apple too hard here, the documentation is pretty bad and that is why  it’s nice to have an example just shown to you as-is.  I hope this  example helps shine a light on the situation for anyone wanting to  implement a nice and quick Apple iPhone WebKit solution.&lt;/p&gt;  &lt;div class="wp_codebox_msgheader"&gt;&lt;span class="right"&gt;&lt;/span&gt;&lt;span class="left"&gt;&lt;a&gt;View Code&lt;/a&gt; OBJC&lt;/span&gt;&lt;/div&gt;&lt;div class="wp_codebox"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr id="p2901"&gt;&lt;td class="code" id="p290code1"&gt;&lt;pre class="objc" style="font-family:monospace;"&gt;  &lt;span style="color: #6e371a;"&gt;#import &lt;uikit h=""&gt;&lt;/uikit&gt;&lt;/span&gt;   &lt;span style="color: #a61390;"&gt;@interface&lt;/span&gt; FirstViewController &lt;span style="color: #002200;"&gt;:&lt;/span&gt; UIViewController &lt;uiwebviewdelegate&gt; &lt;span style="color: #002200;"&gt;{&lt;/span&gt;  UIWebView &lt;span style="color: #002200;"&gt;*&lt;/span&gt;myWebView;  UIActivityIndicatorView &lt;span style="color: #002200;"&gt;*&lt;/span&gt;activityIndicator;  &lt;span style="color: #002200;"&gt;}&lt;/span&gt;&lt;/uiwebviewdelegate&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;   &lt;div class="wp_codebox_msgheader"&gt;&lt;span class="right"&gt;&lt;/span&gt;&lt;span class="left"&gt;&lt;a&gt;View Code&lt;/a&gt; OBJC&lt;/span&gt;&lt;/div&gt;&lt;div class="wp_codebox"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr id="p2902"&gt;&lt;td class="code" id="p290code2"&gt;&lt;pre class="objc" style="font-family:monospace;"&gt;&lt;span style="color: #11740a; font-style: italic;"&gt;/* Inside the @implementation FirstViewController ...  */&lt;/span&gt; &lt;span style="color: #002200;"&gt;-&lt;/span&gt; &lt;span style="color: #002200;"&gt;(&lt;/span&gt;&lt;span style="color: #a61390;"&gt;void&lt;/span&gt;&lt;span style="color: #002200;"&gt;)&lt;/span&gt;viewDidLoad &lt;span style="color: #002200;"&gt;{&lt;/span&gt; &lt;span style="color: #11740a; font-style: italic;"&gt;//We have a NIB file in play here, so I dropped the loadView here.  Just make sure that your loadView is not getting called twice!&lt;/span&gt;     &lt;span style="color: #002200;"&gt;[&lt;/span&gt;super viewDidLoad&lt;span style="color: #002200;"&gt;]&lt;/span&gt;;     &lt;span style="color: #002200;"&gt;[&lt;/span&gt;self loadView&lt;span style="color: #002200;"&gt;]&lt;/span&gt;; &lt;span style="color: #002200;"&gt;}&lt;/span&gt;   &lt;span style="color: #002200;"&gt;-&lt;/span&gt; &lt;span style="color: #002200;"&gt;(&lt;/span&gt;&lt;span style="color: #a61390;"&gt;void&lt;/span&gt;&lt;span style="color: #002200;"&gt;)&lt;/span&gt;loadView &lt;span style="color: #002200;"&gt;{&lt;/span&gt;  UIView &lt;span style="color: #002200;"&gt;*&lt;/span&gt;contentView &lt;span style="color: #002200;"&gt;=&lt;/span&gt; &lt;span style="color: #002200;"&gt;[&lt;/span&gt;&lt;span style="color: #002200;"&gt;[&lt;/span&gt;UIView alloc&lt;span style="color: #002200;"&gt;]&lt;/span&gt; initWithFrame&lt;span style="color: #002200;"&gt;:&lt;/span&gt;&lt;span style="color: #002200;"&gt;[&lt;/span&gt;&lt;span style="color: #002200;"&gt;[&lt;/span&gt;UIScreen mainScreen&lt;span style="color: #002200;"&gt;]&lt;/span&gt; applicationFrame&lt;span style="color: #002200;"&gt;]&lt;/span&gt;&lt;span style="color: #002200;"&gt;]&lt;/span&gt;;  self.view &lt;span style="color: #002200;"&gt;=&lt;/span&gt; contentView;     CGRect webFrame &lt;span style="color: #002200;"&gt;=&lt;/span&gt; &lt;span style="color: #002200;"&gt;[&lt;/span&gt;&lt;span style="color: #002200;"&gt;[&lt;/span&gt;UIScreen mainScreen&lt;span style="color: #002200;"&gt;]&lt;/span&gt; applicationFrame&lt;span style="color: #002200;"&gt;]&lt;/span&gt;;  webFrame.origin.y &lt;span style="color: #002200;"&gt;=&lt;/span&gt; 0.0f;  myWebView &lt;span style="color: #002200;"&gt;=&lt;/span&gt; &lt;span style="color: #002200;"&gt;[&lt;/span&gt;&lt;span style="color: #002200;"&gt;[&lt;/span&gt;UIWebView alloc&lt;span style="color: #002200;"&gt;]&lt;/span&gt; initWithFrame&lt;span style="color: #002200;"&gt;:&lt;/span&gt;webFrame&lt;span style="color: #002200;"&gt;]&lt;/span&gt;;  myWebView.backgroundColor &lt;span style="color: #002200;"&gt;=&lt;/span&gt; &lt;span style="color: #002200;"&gt;[&lt;/span&gt;UIColor blueColor&lt;span style="color: #002200;"&gt;]&lt;/span&gt;;  myWebView.scalesPageToFit &lt;span style="color: #002200;"&gt;=&lt;/span&gt; &lt;span style="color: #a61390;"&gt;YES&lt;/span&gt;;  myWebView.autoresizingMask &lt;span style="color: #002200;"&gt;=&lt;/span&gt; &lt;span style="color: #002200;"&gt;(&lt;/span&gt;UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight&lt;span style="color: #002200;"&gt;)&lt;/span&gt;;  myWebView.delegate &lt;span style="color: #002200;"&gt;=&lt;/span&gt; self;  &lt;span style="color: #002200;"&gt;[&lt;/span&gt;self.view addSubview&lt;span style="color: #002200;"&gt;:&lt;/span&gt; myWebView&lt;span style="color: #002200;"&gt;]&lt;/span&gt;;  &lt;span style="color: #002200;"&gt;[&lt;/span&gt;myWebView loadRequest&lt;span style="color: #002200;"&gt;:&lt;/span&gt;&lt;span style="color: #002200;"&gt;[&lt;/span&gt;&lt;a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURLRequest_Class/"&gt;&lt;span style="color: #400080;"&gt;NSURLRequest&lt;/span&gt;&lt;/a&gt; requestWithURL&lt;span style="color: #002200;"&gt;:&lt;/span&gt;&lt;span style="color: #002200;"&gt;[&lt;/span&gt;&lt;a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/"&gt;&lt;span style="color: #400080;"&gt;NSURL&lt;/span&gt;&lt;/a&gt; URLWithString&lt;span style="color: #002200;"&gt;:&lt;/span&gt;&lt;span style="color: #bf1d1a;"&gt;@&lt;/span&gt;&lt;span style="color: #bf1d1a;"&gt;"http://www.maxpowersoft.com/"&lt;/span&gt;&lt;span style="color: #002200;"&gt;]&lt;/span&gt;&lt;span style="color: #002200;"&gt;]&lt;/span&gt;&lt;span style="color: #002200;"&gt;]&lt;/span&gt;;    activityIndicator &lt;span style="color: #002200;"&gt;=&lt;/span&gt; &lt;span style="color: #002200;"&gt;[&lt;/span&gt;&lt;span style="color: #002200;"&gt;[&lt;/span&gt;UIActivityIndicatorView alloc&lt;span style="color: #002200;"&gt;]&lt;/span&gt;initWithActivityIndicatorStyle&lt;span style="color: #002200;"&gt;:&lt;/span&gt;UIActivityIndicatorViewStyleGray&lt;span style="color: #002200;"&gt;]&lt;/span&gt;;  activityIndicator.frame &lt;span style="color: #002200;"&gt;=&lt;/span&gt; CGRectMake&lt;span style="color: #002200;"&gt;(&lt;/span&gt;&lt;span style="color: #2400d9;"&gt;0.0&lt;/span&gt;, &lt;span style="color: #2400d9;"&gt;0.0&lt;/span&gt;, &lt;span style="color: #2400d9;"&gt;40.0&lt;/span&gt;, &lt;span style="color: #2400d9;"&gt;40.0&lt;/span&gt;&lt;span style="color: #002200;"&gt;)&lt;/span&gt;;  activityIndicator.center &lt;span style="color: #002200;"&gt;=&lt;/span&gt; self.view.center;  &lt;span style="color: #002200;"&gt;[&lt;/span&gt;self.view addSubview&lt;span style="color: #002200;"&gt;:&lt;/span&gt; activityIndicator&lt;span style="color: #002200;"&gt;]&lt;/span&gt;; &lt;span style="color: #002200;"&gt;}&lt;/span&gt;   &lt;span style="color: #002200;"&gt;-&lt;/span&gt; &lt;span style="color: #002200;"&gt;(&lt;/span&gt;&lt;span style="color: #a61390;"&gt;void&lt;/span&gt;&lt;span style="color: #002200;"&gt;)&lt;/span&gt;dealloc &lt;span style="color: #002200;"&gt;{&lt;/span&gt;  &lt;span style="color: #002200;"&gt;[&lt;/span&gt;activityIndicator release&lt;span style="color: #002200;"&gt;]&lt;/span&gt;;  &lt;span style="color: #002200;"&gt;[&lt;/span&gt;myWebView release&lt;span style="color: #002200;"&gt;]&lt;/span&gt;;         &lt;span style="color: #002200;"&gt;[&lt;/span&gt;super dealloc&lt;span style="color: #002200;"&gt;]&lt;/span&gt;; &lt;span style="color: #002200;"&gt;}&lt;/span&gt;   &lt;span style="color: #6e371a;"&gt;#pragma mark WEBVIEW Methods&lt;/span&gt;   &lt;span style="color: #002200;"&gt;-&lt;/span&gt; &lt;span style="color: #002200;"&gt;(&lt;/span&gt;&lt;span style="color: #a61390;"&gt;void&lt;/span&gt;&lt;span style="color: #002200;"&gt;)&lt;/span&gt;webViewDidStartLoad&lt;span style="color: #002200;"&gt;:&lt;/span&gt;&lt;span style="color: #002200;"&gt;(&lt;/span&gt;UIWebView &lt;span style="color: #002200;"&gt;*&lt;/span&gt;&lt;span style="color: #002200;"&gt;)&lt;/span&gt;webView &lt;span style="color: #002200;"&gt;{&lt;/span&gt;  &lt;span style="color: #11740a; font-style: italic;"&gt;// starting the load, show the activity indicator in the status bar&lt;/span&gt;  &lt;span style="color: #002200;"&gt;[&lt;/span&gt;UIApplication sharedApplication&lt;span style="color: #002200;"&gt;]&lt;/span&gt;.networkActivityIndicatorVisible &lt;span style="color: #002200;"&gt;=&lt;/span&gt; &lt;span style="color: #a61390;"&gt;YES&lt;/span&gt;;  &lt;span style="color: #002200;"&gt;[&lt;/span&gt;activityIndicator startAnimating&lt;span style="color: #002200;"&gt;]&lt;/span&gt;; &lt;span style="color: #002200;"&gt;}&lt;/span&gt;   &lt;span style="color: #002200;"&gt;-&lt;/span&gt; &lt;span style="color: #002200;"&gt;(&lt;/span&gt;&lt;span style="color: #a61390;"&gt;void&lt;/span&gt;&lt;span style="color: #002200;"&gt;)&lt;/span&gt;webViewDidFinishLoad&lt;span style="color: #002200;"&gt;:&lt;/span&gt;&lt;span style="color: #002200;"&gt;(&lt;/span&gt;UIWebView &lt;span style="color: #002200;"&gt;*&lt;/span&gt;&lt;span style="color: #002200;"&gt;)&lt;/span&gt;webView &lt;span style="color: #002200;"&gt;{&lt;/span&gt;  &lt;span style="color: #11740a; font-style: italic;"&gt;// finished loading, hide the activity indicator in the status bar&lt;/span&gt;  &lt;span style="color: #002200;"&gt;[&lt;/span&gt;UIApplication sharedApplication&lt;span style="color: #002200;"&gt;]&lt;/span&gt;.networkActivityIndicatorVisible &lt;span style="color: #002200;"&gt;=&lt;/span&gt; &lt;span style="color: #a61390;"&gt;NO&lt;/span&gt;;  &lt;span style="color: #002200;"&gt;[&lt;/span&gt;activityIndicator stopAnimating&lt;span style="color: #002200;"&gt;]&lt;/span&gt;; &lt;span style="color: #002200;"&gt;}&lt;/span&gt;   &lt;span style="color: #002200;"&gt;-&lt;/span&gt; &lt;span style="color: #002200;"&gt;(&lt;/span&gt;&lt;span style="color: #a61390;"&gt;void&lt;/span&gt;&lt;span style="color: #002200;"&gt;)&lt;/span&gt;webView&lt;span style="color: #002200;"&gt;:&lt;/span&gt;&lt;span style="color: #002200;"&gt;(&lt;/span&gt;UIWebView &lt;span style="color: #002200;"&gt;*&lt;/span&gt;&lt;span style="color: #002200;"&gt;)&lt;/span&gt;webView didFailLoadWithError&lt;span style="color: #002200;"&gt;:&lt;/span&gt;&lt;span style="color: #002200;"&gt;(&lt;/span&gt;&lt;a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSError_Class/"&gt;&lt;span style="color: #400080;"&gt;NSError&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #002200;"&gt;*&lt;/span&gt;&lt;span style="color: #002200;"&gt;)&lt;/span&gt;error &lt;span style="color: #002200;"&gt;{&lt;/span&gt;  &lt;span style="color: #11740a; font-style: italic;"&gt;// load error, hide the activity indicator in the status bar&lt;/span&gt;  &lt;span style="color: #002200;"&gt;[&lt;/span&gt;UIApplication sharedApplication&lt;span style="color: #002200;"&gt;]&lt;/span&gt;.networkActivityIndicatorVisible &lt;span style="color: #002200;"&gt;=&lt;/span&gt; &lt;span style="color: #a61390;"&gt;NO&lt;/span&gt;;    &lt;span style="color: #11740a; font-style: italic;"&gt;// report the error inside the webview&lt;/span&gt;  &lt;a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"&gt;&lt;span style="color: #400080;"&gt;NSString&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #002200;"&gt;*&lt;/span&gt; errorString &lt;span style="color: #002200;"&gt;=&lt;/span&gt; &lt;span style="color: #002200;"&gt;[&lt;/span&gt;&lt;a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"&gt;&lt;span style="color: #400080;"&gt;NSString&lt;/span&gt;&lt;/a&gt; stringWithFormat&lt;span style="color: #002200;"&gt;:&lt;/span&gt;         &lt;span style="color: #bf1d1a;"&gt;@&lt;/span&gt;&lt;span style="color: #bf1d1a;"&gt;"&lt;center&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:+5;color:red;"&gt;Error&lt;br /&gt;&lt;br /&gt;Your request %@&lt;/span&gt;&lt;/center&gt;"&lt;/span&gt;,         error.localizedDescription&lt;span style="color: #002200;"&gt;]&lt;/span&gt;;  &lt;span style="color: #002200;"&gt;[&lt;/span&gt;myWebView loadHTMLString&lt;span style="color: #002200;"&gt;:&lt;/span&gt;errorString baseURL&lt;span style="color: #002200;"&gt;:&lt;/span&gt;&lt;span style="color: #a61390;"&gt;nil&lt;/span&gt;&lt;span style="color: #002200;"&gt;]&lt;/span&gt;; &lt;span style="color: #002200;"&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;  &lt;p&gt;That is all there is to it.  It’s really simple as you can see.  Feel free to copy and paste accordingly.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-5746892052525824440?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/5746892052525824440/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=5746892052525824440' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/5746892052525824440'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/5746892052525824440'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2011/05/posts-tagged-uiactivityindicatorview.html' title='Posts Tagged UIActivityIndicatorView'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-1460906648069638244</id><published>2011-05-16T11:47:00.001-07:00</published><updated>2011-05-16T11:47:57.224-07:00</updated><title type='text'>iPhone Dev Sessions: Making a Splash Screen</title><content type='html'>&lt;div class="post-content clearfix"&gt;   &lt;h1 class="title"&gt;   iPhone Dev Sessions: Making a Splash Screen&lt;/h1&gt;   &lt;div class="post-meta-wrap clearfix"&gt;    &lt;div id="post-meta-174160" class=""&gt;     &lt;span class="post-meta the-author"&gt;By &lt;a rel="nofollow" href="http://gigaom.com/author/ggeoffre/" title="Posts by Geoffrey Goetz"&gt;Geoffrey Goetz&lt;/a&gt;&lt;/span&gt;     &lt;span class="post-meta the-date"&gt;Apr. 20, 2010, 3:00pm PT&lt;/span&gt;     &lt;span class="post-meta comments-link"&gt;&lt;a href="http://gigaom.com/apple/iphone-dev-sessions-making-a-splash-screen/#comments" rev="post-174160" rel="nofollow" title="Comment on iPhone Dev Sessions: Making a Splash Screen"&gt;17 Comments&lt;/a&gt;&lt;/span&gt;    &lt;/div&gt;    &lt;div class="post-meta-right social-knobs"&gt;    &lt;/div&gt;   &lt;/div&gt;    &lt;div class="sharing-counters clearfix"&gt;     &lt;div class="facebook-like-this-bottom"&gt;     &lt;ul&gt;&lt;li class="twitter-me facebook-bottom first"&gt;&lt;br /&gt;&lt;/li&gt;&lt;li class="facebook-bottom last"&gt;&lt;span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;    &lt;/div&gt;    &lt;/div&gt;     &lt;div class="the-content clearfix"&gt;    &lt;p&gt;All too often an iPhone application’s launch sequence is an  overlooked detail. The most common approach is to misuse the provided  Default.png file as a splash screen. As it turns out, this detailing of  an application is more than a little challenging if you want to get it  right and stay within Apple’s guidelines.&lt;/p&gt; &lt;p&gt;The key to a smooth and professional looking launch sequence starts  with knowing exactly where the application will land at startup. Some  applications start at exactly the same place each and every successive  launch, others attempt to preserve the application’s state and launch  into the screen where the user last used the application. Keeping this  in mind can change the strategy of how the launch sequence is  implemented. This includes screen orientation as well as how and even if  the status bar it to be displayed.&lt;/p&gt; &lt;p&gt;One may witness flickering of the status bar from blue, to black or  from black to blue during the launch sequence. This is mainly due to the  fact that there are two places to change the behavior of the status  bar. One is hidden in the info.plist file, and the other is typically  via code in the Application Delegate’s &lt;code&gt;applicationDidFinishLaunching&lt;/code&gt; method. The &lt;code&gt;info.plist&lt;/code&gt;  configuration is used before the main window is loaded, and the code in  the Application Delegate is used during the launching of the main  window. The reason one may want to utilize both styles is to take  advantage of a full screen splash page, and then enable the appropriate  looking status bar once the application has finished loading.&lt;/p&gt; &lt;p&gt;For the purpose of this example application, we will assume that the  user state is preserved between executions, and we do not know exactly  what the screen will look like when the user enters the application. We  will therefore be implementing a full-screen splash view that will have  the status bar hidden during the launch sequence. Once the splash view  has disappeared, a black opaque status bar will be utilized throughout  the application. It is also assumed that the application will launch in  portrait mode, and that the first screen the user will see will also be  in portrait mode.&lt;/p&gt; &lt;h2&gt;Editing the Configuration File&lt;/h2&gt; &lt;p&gt;The first order of business is to take care of the status bar. In Xcode, locate the &lt;code&gt;info.plist&lt;/code&gt;  file for the project. To add an additional property to the plist file,  simply select one of the entries and click on the plus tab that appears  to the right and select Status Bar Style from the drop down list:&lt;/p&gt; &lt;div id="attachment_44274" class="wp-caption alignnone" style="width: 580px"&gt;&lt;img title="Edit Projects plist File" src="http://gigapple.files.wordpress.com/2010/04/image-001.jpg?w=570&amp;amp;h=337" alt="Edit Projects plist File" class=" alignleft" height="337" width="570" /&gt;&lt;p class="wp-caption-text"&gt;Edit Projects plist File&lt;/p&gt;&lt;/div&gt; &lt;p&gt;There are only three different styles to choose from. Try each style  out to see which one fits the needs of the application being developed.  For this example we will set the style to &lt;code&gt;UIStatusBarStyleDefault&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;UIStatusBarStyles:&lt;/strong&gt;&lt;br /&gt;&lt;code&gt;UIStatusBarStyleDefault&lt;/code&gt; — Gray (the default)&lt;br /&gt;&lt;code&gt;UIStatusBarStyleBlackTranslucent&lt;/code&gt; — Transparent black (specifically, black with an alpha of 0.5)&lt;br /&gt;&lt;code&gt;UIStatusBarStyleBlackOpaque&lt;/code&gt; — Opaque black&lt;/p&gt; &lt;p&gt;If on the other hand the desire is to hide the status bar when the  application launches, then yet another property needs to be set. In this  case, add the “Status Bar is initially hidden” property to the plist  file and be sure to check the box next to the property.&lt;/p&gt; &lt;h2&gt;Editing the Application Delegate code&lt;/h2&gt; &lt;p&gt;So now that the status bar style is set, and initially hidden, how  does one get the status bar to display again? You can actually turn the  status bar on and off programmatically via code. This is particularly  handy when the need arises to display a full screen view, such as the  splash screen this application is utilizing. In the &lt;code&gt;applicationDidFinishLaunching&lt;/code&gt; method of the Application’s designated AppDelegate class, add the following line of code to make the status bar visible again:&lt;/p&gt; &lt;div class="syntaxhighlighter  " id="highlighter_61664"&gt;&lt;div class="lines"&gt;&lt;div class="line alt1"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;1&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="plain"&gt;- (&lt;/code&gt;&lt;code class="datatypes"&gt;void&lt;/code&gt;&lt;code class="plain"&gt;)applicationDidFinishLaunching:(UIApplication *)application {&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="line alt2"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;2&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="spaces"&gt;    &lt;/code&gt;&lt;code class="comment"&gt;// Override point for customization after app launch&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="line alt1"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;3&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="spaces"&gt;    &lt;/code&gt;&lt;code class="plain"&gt;[window addSubview:viewController.view];&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="line alt2"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;4&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="spaces"&gt;    &lt;/code&gt;&lt;code class="plain"&gt;[window makeKeyAndVisible];&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="line alt1"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;5&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="spaces"&gt;    &lt;/code&gt;&lt;code class="plain"&gt;[[UIApplication sharedApplication] setStatusBarHidden:&lt;/code&gt;&lt;code class="keyword"&gt;NO&lt;/code&gt; &lt;code class="plain"&gt;animated:&lt;/code&gt;&lt;code class="keyword"&gt;YES&lt;/code&gt;&lt;code class="plain"&gt;];&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="line alt2"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;6&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="plain"&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2&gt;Adding a Default.png Image&lt;/h2&gt; &lt;p&gt;Surprisingly, the size of this file is not as important as the naming  convention of the file. Default.png is a case sensitive PNG file. The  image should be 480×320 according to Apple. Following Apple’s  conventions, this image should look like the view that the user will see  when the application has launched, and not the actual splash screen.&lt;/p&gt; &lt;p&gt;Xcode provides a mechanism to create a Default.png file from an  attached device running the application. From the Organizer window,  select the device, click on screenshots and click capture. To make that  screenshot your application’s default image, click Save As Default  Image. Even though the image that is created includes the status bar as  it looked when the screen shot was captured, the iPhone OS replaces it  with the current status bar when your application launches. Just to be  clear, this is not a splash screen…not yet.&lt;/p&gt; &lt;h2&gt;Long Launch Sequences to Varying Views&lt;/h2&gt; &lt;p&gt;So far, this is what most applications will implement if they  implement any sort of controlled visual experience when the application  launches. If you follow Apple’s guidelines, and the image you produce is  the first screen that the user will see, all is good. Except, what if  the launch sequence is not as fast as the user expects? What if the  application preserves state and lands on a different view based on the  users last know state? Then this technique is not up to the task.&lt;/p&gt; &lt;p&gt;Photoshop a branded image representing the application and save it as  a PNG image sized at 480×320. Do not include a status bar of any kind  in the image file being created. Add this image file to the project. Now  the application sort of has a splash screen, through a misused  implementation of the Default.png file. To correct this, simply add an  image view as a property to the App Delegates header and create it as  follows:&lt;/p&gt; &lt;div class="syntaxhighlighter  " id="highlighter_702290"&gt;&lt;div class="lines"&gt;&lt;div class="line alt1"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;1&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="plain"&gt;splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="line alt2"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;2&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="plain"&gt;splashView.image = [UIImage imageNamed:&lt;/code&gt;&lt;code class="string"&gt;@"Default.png"&lt;/code&gt;&lt;code class="plain"&gt;];&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="line alt1"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;3&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="plain"&gt;[window addSubview:splashView];&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="line alt2"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;4&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="plain"&gt;[window bringSubviewToFront:splashView];&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;At this point, the image view is utilizing the exact same image file  that was created in Photoshop. There’s no chance of the initial view  being different than the Default.png file at this point. The one  remaining problem is the timing of when to remove the image view from  the subview. This can be handled in one of two ways…&lt;/p&gt; &lt;h2&gt;Controlling the Duration of the Splash Screen&lt;/h2&gt; &lt;p&gt;The first option is for those with quick startup times that just want  a splash screen. In this situation, create a method to remove and  release the splash view, then calling that method via a timed perform  selector call as follows:&lt;/p&gt; &lt;div class="syntaxhighlighter  " id="highlighter_237036"&gt;&lt;div class="lines"&gt;&lt;div class="line alt1"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;1&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="plain"&gt;[&lt;/code&gt;&lt;code class="keyword"&gt;self&lt;/code&gt; &lt;code class="plain"&gt;performSelector:&lt;/code&gt;&lt;code class="keyword"&gt;@selector&lt;/code&gt;&lt;code class="plain"&gt;(removeSplash) withObject:&lt;/code&gt;&lt;code class="keyword"&gt;nil&lt;/code&gt; &lt;code class="plain"&gt;afterDelay:1.5];&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;The &lt;code&gt;removeSplash&lt;/code&gt; method does just that, removes the image view from the subview and releases the object.&lt;/p&gt; &lt;div class="syntaxhighlighter  " id="highlighter_360137"&gt;&lt;div class="lines"&gt;&lt;div class="line alt1"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;1&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="plain"&gt;-(&lt;/code&gt;&lt;code class="datatypes"&gt;void&lt;/code&gt;&lt;code class="plain"&gt;)removeSplash;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="line alt2"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;2&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="plain"&gt;{&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="line alt1"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;3&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="spaces"&gt;  &lt;/code&gt;&lt;code class="plain"&gt;[splashView removeFromSuperview];&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="line alt2"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;4&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="spaces"&gt;  &lt;/code&gt;&lt;code class="plain"&gt;[splashView release];&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="line alt1"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;5&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="plain"&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;The second method uses the same remove splash method, but relies on  the built in event management to trigger when the method gets called.&lt;/p&gt; &lt;div class="syntaxhighlighter  " id="highlighter_238193"&gt;&lt;div class="lines"&gt;&lt;div class="line alt1"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;1&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="plain"&gt;[[&lt;/code&gt;&lt;code class="keyword"&gt;NSNotificationCenter&lt;/code&gt; &lt;code class="plain"&gt;defaultCenter] addObserver:&lt;/code&gt;&lt;code class="keyword"&gt;self&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="line alt2"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;2&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="spaces"&gt;      &lt;/code&gt;&lt;code class="plain"&gt;selector:&lt;/code&gt;&lt;code class="keyword"&gt;@selector&lt;/code&gt;&lt;code class="plain"&gt;(saveClaim:)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="line alt1"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;3&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="spaces"&gt;      &lt;/code&gt;&lt;code class="plain"&gt;name:&lt;/code&gt;&lt;code class="string"&gt;@"RemoveSplashScreen"&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="line alt2"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;4&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="spaces"&gt;      &lt;/code&gt;&lt;code class="plain"&gt;object:&lt;/code&gt;&lt;code class="keyword"&gt;nil&lt;/code&gt;&lt;code class="plain"&gt;];&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;Now all that needs to be done is to post the notification from  anywhere. This technique is particularly useful if the reason that the  launch sequence is taking a long time has nothing to do with code that  was implemented in the App Delegate.&lt;/p&gt; &lt;div class="syntaxhighlighter  " id="highlighter_364036"&gt;&lt;div class="lines"&gt;&lt;div class="line alt1"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;1&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="plain"&gt;[[&lt;/code&gt;&lt;code class="keyword"&gt;NSNotificationCenter&lt;/code&gt; &lt;code class="plain"&gt;defaultCenter]&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="line alt2"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;2&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="spaces"&gt;      &lt;/code&gt;&lt;code class="plain"&gt;postNotificationName: &lt;/code&gt;&lt;code class="string"&gt;@"RemoveSplashScreen"&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="line alt1"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="number"&gt;&lt;code&gt;3&lt;/code&gt;&lt;/td&gt;&lt;td class="content"&gt;&lt;code class="spaces"&gt;      &lt;/code&gt;&lt;code class="plain"&gt;object: &lt;/code&gt;&lt;code class="keyword"&gt;nil&lt;/code&gt;&lt;code class="plain"&gt;];&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;This technique can be employed from anywhere within the application.  Removing the observer after the fact may avoid crashes if there is an  opportunity for this notification to be fired multiple times. Releasing  an object when no object it there to be released can lead to troublesome  crashes to track down. The quick and dirty is to use the delay on the &lt;code&gt;performSelector&lt;/code&gt; call.&lt;/p&gt; &lt;h2&gt;Conclusion&lt;/h2&gt; &lt;p&gt;And there it is, a splash screen that conforms to Apple’s guidelines.  No hidden APIs, no hacks, no special sauce. A simple, straight forward  approach to making the initial interaction with the user as pleasant as  possible.&lt;/p&gt; &lt;p&gt;&lt;em&gt;References:&lt;/em&gt;&lt;/p&gt; &lt;ul&gt;&lt;li class="first"&gt;&lt;a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/c/econst/UIStatusBarStyleDefault"&gt;iPhone OS Reference Library UIApplication Class Reference UIStatusBarStyle&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://developer.apple.com/iphone/library/documentation/Xcode/Conceptual/iphone_development/128-Managing_Devices/devices.html#//apple_ref/doc/uid/TP40007959-CH4-SW19"&gt;iPhone OS Reference Library iPhone Development Guide Capturing Screen Shots&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/RunLoopManagement.html#//apple_ref/doc/uid/10000057i-CH16-SW44"&gt;Mac OS X Reference Library Threading Programming Guide Cocoa Perform Selector Sources&lt;/a&gt;&lt;/li&gt;&lt;li class="last"&gt;&lt;a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSNotificationCenter_Class/Reference/Reference.html"&gt;Mac OS X Reference Library NSNotificationsCenter Class Reference&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;   &lt;/div&gt;  &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-1460906648069638244?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/1460906648069638244/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=1460906648069638244' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/1460906648069638244'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/1460906648069638244'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2011/05/iphone-dev-sessions-making-splash.html' title='iPhone Dev Sessions: Making a Splash Screen'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-482793977485830585</id><published>2011-01-17T07:23:00.001-08:00</published><updated>2011-01-17T07:23:49.504-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PlayBook'/><title type='text'>how to set background for container</title><content type='html'>&lt;h1&gt;how to set background for container&lt;/h1&gt;    &lt;span class="lia-message-subject-status"&gt;              &lt;/span&gt;                      &lt;div class="lia-quilt-column lia-quilt-column-04 lia-quilt-column-right"&gt;  &lt;div class="lia-quilt-column-alley lia-quilt-column-alley-right"&gt;              &lt;div class="lia-message-options"&gt;    &lt;div class="lia-menu-navigation-wrapper lia-menu-action message-menu" id="actionMenuDropDown_1"&gt;   &lt;div class="lia-js-click-menu lia-menu-navigation"&gt;   &lt;div class="dropdown-default-item"&gt;&lt;a name="title" class="lia-js-menu-opener default-menu-option lia-link-navigation" rel="nofollow" id="dropDownLink_2" href="http://supportforums.blackberry.com/t5/Tablet-OS-SDK-for-Adobe-AIR/how-to-set-background-for-container/m-p/694409/highlight/true#"&gt;Options&lt;/a&gt;    &lt;div class="dropdown-positioning"&gt;     &lt;div class="dropdown-positioning-static"&gt;        &lt;ul id="dropdownmenuitems_2" class="lia-menu-dropdown-items"&gt;&lt;li&gt;&lt;span class="lia-link-navigation mark-message-unread lia-link-disabled lia-component-forums-action-mark-message-unread" id="markMessageUnread_0"&gt;Mark as New&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="lia-link-navigation addMessageUserBookmark lia-link-disabled lia-component-subscriptions-action-add-message-user-bookmark" id="addMessageUserBookmark_0"&gt;Bookmark&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="lia-link-navigation addMessageUserEmailSubscription lia-link-disabled lia-component-subscriptions-action-add-message-user-email" id="addMessageUserEmailSubscription_0"&gt;Subscribe&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="lia-separator lia-component-common-widget-link-separator"&gt;  &lt;span class="lia-separator-post"&gt;&lt;/span&gt;  &lt;span class="lia-separator-pre"&gt;&lt;/span&gt; &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="lia-link-navigation rss-message-link lia-component-rss-action-message" rel="nofollow" id="rssMessage_0" href="http://supportforums.blackberry.com/rim/rss/message?board.id=tablet&amp;amp;message.id=3050"&gt;Subscribe to RSS Feed&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="lia-separator lia-component-common-widget-link-separator"&gt;  &lt;span class="lia-separator-post"&gt;&lt;/span&gt;  &lt;span class="lia-separator-pre"&gt;&lt;/span&gt; &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="lia-link-navigation highlight-message lia-component-forums-action-highlight-message" id="highlightMessage_0" href="http://supportforums.blackberry.com/t5/Tablet-OS-SDK-for-Adobe-AIR/how-to-set-background-for-container/m-p/694449/highlight/true#M3050"&gt;Highlight&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="lia-link-navigation print-message lia-component-forums-action-print-message" rel="nofollow" id="printMessage_0" href="http://supportforums.blackberry.com/t5/forums/forumtopicprintpage/board-id/tablet/message-id/3050/print-single-message/true/page/1"&gt;Print&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="lia-link-navigation email_friend lia-link-disabled lia-component-forums-action-email-message-to-friend" id="emailMessageToFriend_0"&gt;Email to a Friend&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="lia-separator lia-component-common-widget-link-separator"&gt;  &lt;span class="lia-separator-post"&gt;&lt;/span&gt;  &lt;span class="lia-separator-pre"&gt;&lt;/span&gt; &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="lia-link-navigation report-abuse-link lia-component-forums-action-report-abuse" rel="nofollow" id="reportAbuse_1" href="http://supportforums.blackberry.com/t5/notifications/notifymoderatorpage/message-uid/694449"&gt;Report Inappropriate Content&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;      &lt;/div&gt;    &lt;/div&gt;   &lt;/div&gt;  &lt;/div&gt; &lt;/div&gt;   &lt;/div&gt;           &lt;/div&gt; &lt;/div&gt;                        &lt;p class="lia-message-dates lia-message-post-date lia-component-post-date-last-edited"&gt;          &lt;span class="DateTime lia-message-posted-on lia-component-common-widget-date"&gt;                   &lt;span class="local-date"&gt;12-17-2010&lt;/span&gt;        &lt;span class="local-time"&gt;02:05 PM&lt;/span&gt;         &lt;/span&gt;       &lt;/p&gt;            &lt;div class="lia-message-body lia-component-body"&gt;             &lt;div class="lia-message-body-content"&gt;        &lt;p&gt;hey shethab,&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;dont sweat it we've all be there! here's how you set the background color of your application. Where there are two ways:&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;First set the meta data to a solid background color like this:&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;package&lt;br /&gt;{&lt;br /&gt; import flash.display.Sprite;&lt;br /&gt; &lt;br /&gt;&lt;strong&gt; [SWF(width="1024", height="600", backgroundColor="#CCCCCC", frameRate="30")]&lt;br /&gt;&lt;/strong&gt; public class MyApplication extends Sprite&lt;br /&gt; &lt;br /&gt;  public function MyApplication()&lt;br /&gt;  {&lt;br /&gt;   (...)&lt;br /&gt;   &lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;}&lt;/pre&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;The background is in the same format as HTML coloring. The second way  is by creating a shape object as large as the screen and adding it as  the first child to your program like so:&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;package&lt;br /&gt;{&lt;br /&gt; import flash.display.Shape;&lt;br /&gt; import flash.display.Sprite;&lt;br /&gt;&lt;br /&gt; [SWF(width="1024", height="600", backgroundColor="#CCCCCC", frameRate="30")]&lt;br /&gt; public class MyApplication extends Sprite&lt;br /&gt; { &lt;br /&gt;  public function MyApplication()&lt;br /&gt;  {&lt;br /&gt;   &lt;br /&gt;&lt;strong&gt;   var appBackgroundColor:Shape = new Shape();&lt;br /&gt;   &lt;br /&gt;   appBackgroundColor.graphics.beginFill(0xFF0000);&lt;br /&gt;   appBackgroundColor.graphics.drawRect(0,0,1024,600)&lt;wbr&gt;;&lt;br /&gt;   appBackgroundColor.graphics.endFill();&lt;br /&gt;   &lt;br /&gt;   addChild(appBackgroundColor);&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;   (...)&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;}&lt;/pre&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;To add an image is like the second step only using the Image class like this:&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;package&lt;br /&gt;{&lt;br /&gt; import flash.display.Shape;&lt;br /&gt; import flash.display.Sprite;&lt;br /&gt; import flash.filesystem.File;&lt;br /&gt; &lt;br /&gt; import qnx.ui.display.Image;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt; [SWF(width="1024", height="600", backgroundColor="#CCCCCC", frameRate="30")]&lt;br /&gt; public class MyApplication extends Sprite&lt;br /&gt; { &lt;br /&gt;  public function MyApplication()&lt;br /&gt;  {&lt;br /&gt;   &lt;br /&gt;   var appBackgroundImage:Image = new Image();&lt;br /&gt;   &lt;br /&gt;   appBackgroundImage.setImage(File.applicationDirect&lt;wbr&gt;ory.resolvePath('path/to/image.png').url);&lt;br /&gt;   appBackgroundImage.setSize(1024,600);&lt;br /&gt;   appBackgroundImage.setPosition(0,0);&lt;br /&gt;   &lt;br /&gt;   addChild(appBackgroundImage);&lt;br /&gt;&lt;br /&gt;   (...)&lt;br /&gt;   &lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;}&lt;/pre&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; hope that helps! good luck!&lt;/p&gt; &lt;p&gt; &lt;/p&gt;               &lt;div style="width: 100%; max-height: 100px; overflow: hidden;" class="UserSignature lia-message-signature"&gt;  J. Rab&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-482793977485830585?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/482793977485830585/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=482793977485830585' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/482793977485830585'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/482793977485830585'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2011/01/how-to-set-background-for-container.html' title='how to set background for container'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-3782261281869086619</id><published>2009-11-13T11:02:00.000-08:00</published><updated>2009-11-13T11:04:53.349-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='BlackBerry'/><title type='text'>Blackberry background key event</title><content type='html'>Implement the KeyListener interface and then put your app to the background. Only few key events will send you from foreground.&lt;br /&gt;&lt;br /&gt;Like Red, Green key and the mute.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-3782261281869086619?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/3782261281869086619/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=3782261281869086619' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/3782261281869086619'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/3782261281869086619'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/11/blackberry-background-key-event.html' title='Blackberry background key event'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-5366680085161155909</id><published>2009-09-30T07:44:00.000-07:00</published><updated>2009-09-30T07:45:21.343-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='BlackBerry'/><title type='text'>how to detect application is in foreground</title><content type='html'>&lt;pre&gt;&lt;b&gt;net.rim.device.api.system.Application&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-size:-1;"&gt;&lt;br /&gt;  &lt;code&gt;void&lt;/code&gt;&lt;/span&gt; &lt;code&gt;&lt;b&gt;&lt;a href="file:///D:/Program%20Files/Research%20In%20Motion/BlackBerry%20JDE%204.2.1/docs/api/net/rim/device/api/system/Application.html#activate%28%29"&gt;activate&lt;/a&gt;&lt;/b&gt;()&lt;/code&gt; &lt;br /&gt;          Handles foregrounding event.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-5366680085161155909?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/5366680085161155909/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=5366680085161155909' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/5366680085161155909'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/5366680085161155909'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/09/how-to-detect-application-is-in.html' title='how to detect application is in foreground'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-4460906346809015061</id><published>2009-09-25T11:18:00.001-07:00</published><updated>2009-09-25T11:18:45.856-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><title type='text'>iPhone development short cuts</title><content type='html'>Reorienting the screen. With the Hello World application running, you can&lt;br /&gt;reorient the Simulator using Command-Left arrow and Command-Right arrow.&lt;br /&gt;n Going home. Tap the Home button (Command-Shift-H) to leave the application&lt;br /&gt;and return to the SpringBoard home screen.&lt;br /&gt;n Locking the “phone.” Hardware, Lock (Command-L) simulates locking the&lt;br /&gt;phone.&lt;br /&gt;n Viewing the console. In Xcode, choose Run, Console (Command-Shift-R) to&lt;br /&gt;view the Xcode console window.This window is where your printf, NSLog, and&lt;br /&gt;CFShow messages are sent by default. In the unlikely case where NSLog messages&lt;br /&gt;do not appear, use the Xcode organizer (Window, Organizer, Console) or open&lt;br /&gt;/Applications/Utilities/Console to view NSLog messages instead.&lt;br /&gt;n Running Instruments. Use Run, Start with Performance Tool to select an&lt;br /&gt;Instruments template (such as Object Allocations or CPU Sampler) to use with the&lt;br /&gt;Simulator. Instruments monitors memory and CPU use as your application runs.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-4460906346809015061?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/4460906346809015061/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=4460906346809015061' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/4460906346809015061'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/4460906346809015061'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/09/iphone-development-short-cuts.html' title='iPhone development short cuts'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-255824080537727152</id><published>2009-09-18T06:13:00.001-07:00</published><updated>2009-09-18T06:13:56.634-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='BlackBerry'/><title type='text'>call permission manager</title><content type='html'>&lt;p&gt;The code I am using is as follows:&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;pre&gt;&lt;p&gt;&lt;b style="color: rgb(255, 255, 255); background-color: rgb(5, 146, 212);"&gt;ApplicationPermissionsManager&lt;/b&gt; apm = ApplicationPermissionsManager.getInstance();&lt;br /&gt;       if (apm.getPermission(ApplicationPermissions.PERMISSION_INPUT_SIMULATION) != ApplicationPermissions.VALUE_ALLOW) {&lt;br /&gt;           ApplicationPermissions ap = new ApplicationPermissions();&lt;br /&gt;           ap.addPermission(ApplicationPermissions.PERMISSION_INPUT_SIMULATION);&lt;br /&gt;           ApplicationPermissionsManager.getInstance().invokePermissionsRequest(ap);&lt;br /&gt;       }&lt;/p&gt;&lt;/pre&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt; This brings up the interface for the user to set the permissions. In the Input Simulation options, the only option available is Deny, there is no Allow or Prompt. But on other options, for example Files, all the options are available. Also on the other devices the Input Simulation has all these options available.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-255824080537727152?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/255824080537727152/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=255824080537727152' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/255824080537727152'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/255824080537727152'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/09/call-permission-manager.html' title='call permission manager'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-3829771573759484692</id><published>2009-09-18T06:03:00.000-07:00</published><updated>2009-09-18T06:04:13.792-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='BlackBerry'/><title type='text'>Control the screen orientation</title><content type='html'>&lt;span id="support"&gt;&lt;h3 class="pTitle_Section" id=""&gt;Details&lt;/h3&gt; &lt;div class="section"&gt;&lt;p class="pBody"&gt;BlackBerry smartphones with accelerometer support, such as the touch screen BlackBerry® Storm™ Series, are capable of changing the display orientation between portrait and landscape mode, depending on how the BlackBerry smartphone is held.&lt;/p&gt; &lt;p class="pBody"&gt;It may be desirable for certain applications to limit the possible orientations. For example, a video player application may need to fix the display orientation to landscape mode.&lt;/p&gt; &lt;p class="pBody"&gt;The screen can be oriented in any of four possible directions: north, south, east and west.&lt;/p&gt; &lt;p class="pBody"&gt;To set the allowable screen orientations, MIDlets should use code similar to the following example, prior to calling &lt;code class="cCode"&gt;Display.setCurrent()&lt;/code&gt; from the MIDlet constructor.&lt;/p&gt; &lt;p class="pCodeIndent"&gt;DirectionControl dc =&lt;br /&gt;DirectionControl)((Controllable)Display.getDisplay(this)).getControl("net.rim.device.api.lcdui.control.DirectionControl");&lt;br /&gt;&lt;br /&gt;int directions = DirectionControl.DIRECTION_EAST | DirectionControl.WEST;&lt;br /&gt;&lt;br /&gt;dc.setAcceptableScreenDirections(directions);&lt;br /&gt;&lt;/p&gt; &lt;p class="pBody"&gt;The above example forces the display into landscape mode.&lt;/p&gt; &lt;p class="pBody"&gt;Connected Limited Device Configuration (CLDC) applications should make the following call before any invocation of &lt;code class="cCode"&gt;UiApplication.pushScreen()&lt;/code&gt;.&lt;/p&gt; &lt;p class="pCodeIndent"&gt;int directions = net.rim.device.api.system.Display.DIRECTION_NORTH |&lt;br /&gt;    net.rim.device.api.system.Display.DIRECTION_SOUTH;&lt;br /&gt;&lt;br /&gt;net.rim.device.api.ui.Ui.getUiEngineInstance().setAcceptableDirections(directions);&lt;br /&gt;&lt;/p&gt; &lt;p class="pBody"&gt;In the above example the display is forced into portrait mode once the BlackBerry smartphone user rotates the BlackBerry smartphone.&lt;/p&gt;&lt;p class="pBody"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="pBody"&gt;from&lt;br /&gt;&lt;/p&gt;&lt;p class="pBody"&gt;http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800608/How_To_-_Control_the_screen_orientation.html?nodeid=1487645&amp;amp;vernum=0&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-3829771573759484692?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/3829771573759484692/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=3829771573759484692' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/3829771573759484692'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/3829771573759484692'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/09/control-screen-orientation.html' title='Control the screen orientation'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-1468985964994848289</id><published>2009-09-11T08:51:00.000-07:00</published><updated>2009-09-11T08:52:59.567-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='BlackBerry'/><title type='text'>How to use third part lib in BB project</title><content type='html'>Some related post here&lt;br /&gt;http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&amp;amp;message.id=22240&amp;amp;query.id=82860#M22240&lt;br /&gt;&lt;br /&gt;Basically, preverify the jar, make sure no other missing dependence packages. Import it into your project, or make a separated project to work as lib project.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-1468985964994848289?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/1468985964994848289/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=1468985964994848289' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/1468985964994848289'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/1468985964994848289'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/09/how-to-use-third-part-lib-in-bb-project.html' title='How to use third part lib in BB project'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-2071213829712600841</id><published>2009-09-11T08:49:00.001-07:00</published><updated>2009-09-11T08:54:01.335-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='BlackBerry'/><title type='text'>Blackberry connections</title><content type='html'>Do not understand why BB makes a Http connection so complex, but still need to face it.&lt;br /&gt;&lt;br /&gt;If you were trying these methods, then the preferred order, based on various posts on this forum, seems to be:&lt;br /&gt;1) BIS-B&lt;br /&gt;2) WAP 2&lt;br /&gt;3) Direct TCP&lt;br /&gt;4) WAP 1&lt;br /&gt;&lt;br /&gt;This is the best post talking about this topic&lt;br /&gt;&lt;br /&gt;http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&amp;amp;message.id=29105#M29105&lt;br /&gt;&lt;br /&gt;http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&amp;amp;thread.id=29103&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-2071213829712600841?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/2071213829712600841/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=2071213829712600841' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/2071213829712600841'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/2071213829712600841'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/09/blackberry-connections.html' title='Blackberry connections'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-4536441648990868482</id><published>2009-09-11T08:47:00.000-07:00</published><updated>2009-09-11T08:48:22.866-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='BlackBerry'/><title type='text'>What Is - Network Diagnostic Tool</title><content type='html'>&lt;span id="support"&gt;&lt;h3 class="pTitle_Section" id=""&gt;From RIM&lt;/h3&gt;http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/What_Is_-_Network_Diagnostic_Tool.html?nodeid=1450596&amp;amp;vernum=0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3 class="pTitle_Section" id=""&gt;&lt;br /&gt;&lt;/h3&gt;&lt;h3 class="pTitle_Section" id=""&gt;Details&lt;/h3&gt; &lt;div class="section"&gt;&lt;p class="pBody"&gt;BlackBerry smartphones support many different transports that facilitate reliable data communication between third-party applications and the Internet. The transports available are direct Transmission Control Protocol (TCP), BlackBerry® Mobile Data System (BlackBerry MDS), BlackBerry® Internet Service Browsing (&lt;code class="cCode"&gt;BIS-B&lt;/code&gt;), BlackBerry® Unite!™ software, Wireless Access Protocol (WAP)1.0, WAP2.0 and Wi-Fi® technology. It is important to understand the differences between these transports and how and when to leverage each transport. It is also crucial to determine if a transport is available for use before trying to use it. The Network Diagnostic Tool is essentially a role model that answers all these questions and is a functional diagnostic tool for testing a URL over various transports supported by the BlackBerry solutions, as well as for displaying the values of many network attributes during the test period. &lt;/p&gt; &lt;p class="pBody"&gt;This article refers to the source code of the Network Diagnostic Tool, which can be downloaded &lt;a href="http://www.blackberry.com/knowledgecentersupport/kmsupport/developerknowledgebase/zip/NetworkDiagnosticPublic.zip"&gt;here&lt;/a&gt;.&lt;/p&gt; &lt;p class="pBody"&gt;To better understand how each transport works, see the video &lt;i&gt;Network Transports&lt;/i&gt;  found on &lt;a href="http://www.blackberry.com/DevMediaLibrary/view.do?name=network"&gt;blackberrydeveloper.com&lt;/a&gt;.&lt;/p&gt; &lt;h2 class="pSubHeading" id=""&gt;Determining transport availability&lt;/h2&gt; &lt;p class="pBody"&gt;The first step to determining the availability of a transport is to check if the &lt;code class="cCode"&gt;ServiceRecord&lt;/code&gt; for that transport is available. This can be done programmatically as follows:&lt;/p&gt; &lt;ol class="OrderedList"&gt;&lt;div class="OrderedList1"&gt;&lt;li&gt; Get the &lt;code class="cCode"&gt;ServiceBook&lt;/code&gt; instance by calling the static method &lt;code class="cCode"&gt;ServiceBook.getSB()&lt;/code&gt;.&lt;/li&gt; &lt;li&gt;Get the &lt;code class="cCode"&gt;ServiceRecords&lt;/code&gt; from the &lt;code class="cCode"&gt;ServiceBook&lt;/code&gt; by calling the instance method &lt;code class="cCode"&gt;ServiceBook.getRecords()&lt;/code&gt;.&lt;/li&gt; &lt;li&gt;Iterate through each &lt;code class="cCode"&gt;ServiceRecord&lt;/code&gt; and determine if it is for the transport you are looking for.&lt;/li&gt;&lt;/div&gt;&lt;/ol&gt; &lt;p class="pBody"&gt;This is demonstrated in the Network Diagnostic Tool's &lt;code class="cCode"&gt;IOThread.initializeTransportAvailability()&lt;/code&gt;.&lt;/p&gt; &lt;p class="pBody"&gt;The next step is to determine if the BlackBerry smartphone has network coverage to communicate through the transport. This can be accomplished by calling the application programming interface (API) &lt;code class="cCode"&gt;CoverageInfo.isCoverageSufficient(int coverageType)&lt;/code&gt;.&lt;/p&gt; &lt;p class="pBody"&gt;Refer to the method &lt;code class="cCode"&gt;IOThread.initializeTransportAvailability()&lt;/code&gt;for a sample implementation of this.&lt;/p&gt; &lt;h2 class="pSubHeading" id=""&gt;"&gt;Creating connections&lt;/h2&gt; &lt;p class="pBody"&gt;Developer knowledge base article &lt;a href="http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/What_Is_-_Different_ways_to_make_an_HTTP_or_socket_connection.html?nodeid=826935&amp;amp;vernum=0"&gt;DB-00396&lt;/a&gt; illustrates how to create an Hypertext Transfer Protocol (HTTP) or socket connection.&lt;/p&gt; &lt;p class="pBody"&gt;The &lt;code class="cCode"&gt;IOThread.get*URL()&lt;/code&gt; methods in the source code shows how to construct URLs for each transport.&lt;/p&gt; &lt;p class="pBody"&gt;Once you have the URL you need, you can create an &lt;code class="cCode"&gt;HTTPConnection&lt;/code&gt; instance using the &lt;code class="cCode"&gt;Connector.open(String url)&lt;/code&gt; static method and start communicating with that URL. See the &lt;code class="cCode"&gt;IOThread.do*()&lt;/code&gt;  methods in the Network Diagnostic Tool source code to see a detailed implementation of this. &lt;/p&gt; &lt;p class="Note"&gt;&lt;b&gt;Note: &lt;/b&gt;The &lt;code class="cCode"&gt;BIS-B &lt;/code&gt;transport is available only to partners of the BlackBerry Alliance Program, and therefore is not implemented in the attached source code of the Network Diagnostic Tool. For more information on the BlackBerry Alliance Program, visit &lt;a href="http://na.blackberry.com/eng/partners/why_join.jsp"&gt;http://na.blackberry.com/eng/partners/why_join.jsp&lt;/a&gt;.&lt;/p&gt; &lt;h2 class="pSubHeading" id=""&gt;Displaying network and radio information&lt;/h2&gt; &lt;p class="pBody"&gt;Besides testing the different transports for a given URL, the Network Diagnostic Tool also displays network and radio information such as signal level, network name and type, and available network services. Refer to the method &lt;code class="cCode"&gt;ReportScreen.displayNetworkInfo()&lt;/code&gt; in the Network Diagnostic Tool source code for more information on how to display this information.&lt;/p&gt; &lt;h2 class="pSubHeading" id=""&gt;RadioStatusListener&lt;/h2&gt; &lt;p class="pBody"&gt;It is also possible for an application to listen for changes in the radio such as signal level and available network services. To accomplish this, you must implement the interface &lt;code class="cCode"&gt;RadioStatusListener&lt;/code&gt;. The Network Diagnostic Tool implements this interface in the class named &lt;code class="cCode"&gt;IOThread&lt;/code&gt;.&lt;/p&gt; &lt;h2 class="pSubHeading" id=""&gt;Automatically detecting wireless service providers&lt;/h2&gt; &lt;p class="pBody"&gt;It is very useful to be able to detect wireless service providers, especially for applications using the Direct TCP transport for BlackBerry smartphones that operate using Global System for Mobile communications® (GSM®). For these BlackBerry smartphones, correct access point name (APN) information must be specified by the BlackBerry smartphone user before any application can leverage the Direct TCP transport. &lt;/p&gt; &lt;p class="pBody"&gt;APN information can also be set programmatically, which is demonstrated in the referenced Network Diagnostic Tool source code.  The details are also explained in &lt;a href="http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/How_To_-_Specify_APN_information_for_a_direct_TCP_connection.html?nodeid=1265025&amp;amp;vernum=0"&gt;DB-00532&lt;/a&gt;.  If the current wireless service provider for the BlackBerry smartphone can be determined, then the APN information can be set up programmatically from the application. This improves the BlackBerry smartphone user's experience because the APN does not need to be specified manually. To detect the wireless service provider, use a table that contains the name, mobile country code (MCC), mobile network code (MNC) and the APN details of each wireless service provider. Compare the MCC and MNC values returned by the BlackBerry smartphone against the values in the table. Once a match is found, set the corresponding APN information programmatically. For more information on how to read the MCC and MNC values from the BlackBerry smartphone, see &lt;a href="http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/1467358/How_To_-_Determine_the_MCC_and_MNC_of_the_current_network.html?nodeid=1467359&amp;amp;vernum=0"&gt;DB-00688&lt;/a&gt;. &lt;/p&gt; &lt;p class="pBody"&gt;The complete process to automatically detect wireless service providers is also demonstrated by the Network Diagnostic Tool. The Network Diagnostic Tool stores the wireless service provider table in an Extensible Markup Language (XML) file that can be downloaded from &lt;a href="http://www.blackberry.com/knowledgecentersupport/kmsupport/developerknowledgebase/txt/carrier_info.xml"&gt;here&lt;/a&gt;. This file must be stored on the BlackBerry smartphone in the following location: &lt;code class="cCode"&gt;file:///store/netdiag/carrier_info.xml&lt;/code&gt; unless this path is changed in the source code. You can add details for as many wireless service providers as you want to the XML file.&lt;/p&gt; &lt;h2 class="pSubHeading" id=""&gt;Changes required for earlier versions of the BlackBerry Java Development Environment&lt;/h2&gt; &lt;p class="pBody"&gt;Although this article is targeted for BlackBerry® Java® Development Environment (BlackBerry JDE) 4.5 or later, the source code of the Network Diagnostic Tool can be easily modified and compiled using earlier versions of the BlackBerry JDE. Consider the following changes:&lt;/p&gt; &lt;ol class="OrderedList"&gt;&lt;div class="OrderedList1"&gt;&lt;li&gt; Before BlackBerry JDE 4.3, &lt;code class="cCode"&gt;RadioStatusListener&lt;/code&gt; had an additional method named &lt;code class="cCode"&gt;mobilityManagementEvent(int eventCode, int cause)&lt;/code&gt;. This method must be implemented if you are using BlackBerry JDE 4.2 or earlier.&lt;/li&gt; &lt;li&gt;&lt;code class="cCode"&gt; CoverageInfo.COVERAGE_DIRECT&lt;/code&gt; is not supported until BlackBerry JDE 4.5. For BlackBerry JDE 4.3 or earlier, use &lt;code class="cCode"&gt;CoverageInfo.COVERAGE_CARRIER&lt;/code&gt;.&lt;/li&gt; &lt;li&gt;&lt;code class="cCode"&gt;WLANInfo&lt;/code&gt; class is not available until BlackBerry JDE 4.5. For BlackBerry JDE 4.3 or earlier, use the following logic:&lt;/li&gt; &lt;p class="pCode"&gt;if(CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_CARRIER,RadioInfo.WAF_WLAN, false)){&lt;br /&gt;    coverageWiFi = true;&lt;br /&gt;    wifiLog.addlog("Coverage Status: Online");&lt;br /&gt;}&lt;br /&gt;&lt;/p&gt; &lt;li&gt;&lt;code class="cCode"&gt; RadioInfo.NETWORK_SERVICE_GAN&lt;/code&gt; is not supported in BlackBerry JDE 4.2.1 or earlier. Remove any references to this constant for those versions of the BlackBerry JDE.&lt;/li&gt; &lt;li&gt;&lt;code class="cCode"&gt; RadioInfo.NETWORK_SERVICE_EVDO_ONLY&lt;/code&gt; and &lt;code class="cCode"&gt;RadioInfo.NETWORK_SERVICE_UMTS&lt;/code&gt; are not supported in BlackBerry JDE 4.2.1 or earlier. Remove any references to these constants for those versions of the BlackBerry JDE.&lt;/li&gt; &lt;li&gt; The &lt;code class="cCode"&gt;CoverageInfo&lt;/code&gt; class is introduced in BlackBerry JDE 4.2.0. Remove any references to this class if you are using an earlier version of the BlackBerry JDE to compile this application. However, it is possible to do the following in versions of the BlackBerry JDE earlier than 4.2.0:&lt;/li&gt; &lt;ol class="OrderedList"&gt;&lt;div class="OrderedList2"&gt;&lt;li&gt;&lt;code class="cCode"&gt; if(RadioInfo.getSignalLevel() != RadioInfo.LEVEL_NO_COVERAGE)&lt;/code&gt; the BlackBerry smartphone has radio signal.&lt;/li&gt; &lt;li&gt;&lt;code class="cCode"&gt; if(RadioInfo.getNetworkService() &amp;amp; RadioInfo.NETWORK_SERVICE_DATA)&gt;0&lt;/code&gt;  the BlackBerry smartphone has data connectivity.&lt;/li&gt;&lt;/div&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-4536441648990868482?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/4536441648990868482/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=4536441648990868482' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/4536441648990868482'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/4536441648990868482'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/09/what-is-network-diagnostic-tool.html' title='What Is - Network Diagnostic Tool'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-8470241855497315134</id><published>2009-09-08T14:37:00.000-07:00</published><updated>2009-09-08T14:38:32.693-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='BlackBerry'/><title type='text'>How to get Blackberry device information?</title><content type='html'>&lt;span id="konasapn0"&gt;&lt;pre class="alt2" dir="ltr" style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 500px; height: 34px; text-align: left;"&gt;String userAgent = "Blackberry" + DeviceInfo.getDeviceName() + "/" + getOsVersion() + " Profile/" + System.getProperty( "microedition.profiles" ) + " Configuration/" + System.getProperty( "microedition.configuration" ) + " VendorID/" + Branding.getVendorId();&lt;/pre&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span id="konasapn0"&gt;&lt;pre class="alt2" dir="ltr" style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 500px; height: 194px; text-align: left;"&gt;public static String getOsVersion()&lt;br /&gt;{   String version = "";&lt;br /&gt;   ApplicationDescriptor[] ad = ApplicationManager.getApplicationManager().getVisibleApplications();&lt;br /&gt;   for( int i = 0; i &lt; ad.length; i++)&lt;br /&gt;   {   if( ad[i].getModuleName().trim().equalsIgnoreCase( "net_rim_bb_ribbon_app" ) )&lt;br /&gt;       {   version = ad[i].getVersion();&lt;br /&gt;           break;&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;   return version;&lt;br /&gt;}&lt;/pre&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-8470241855497315134?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/8470241855497315134/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=8470241855497315134' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/8470241855497315134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/8470241855497315134'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/09/how-to-get-blackberry-device.html' title='How to get Blackberry device information?'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-6283581862602716006</id><published>2009-09-01T08:45:00.000-07:00</published><updated>2009-09-01T08:47:00.286-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='BlackBerry'/><title type='text'>How To - Compile a jar file into a BlackBerry Library</title><content type='html'>&lt;span id="support"&gt;&lt;h3 class="pTitle_Section" id=""&gt;come from here&lt;br /&gt;&lt;/h3&gt;http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800901/How_To_-_Compile_a_JAR_file_into_a_BlackBerry_Library.html?nodeid=801017&amp;amp;vernum=0&lt;br /&gt;&lt;br /&gt;&lt;h3 class="pTitle_Section" id=""&gt;&lt;br /&gt;&lt;/h3&gt;&lt;h3 class="pTitle_Section" id=""&gt;Details&lt;/h3&gt; &lt;div class="section"&gt;&lt;p class="pBody"&gt;You can include classes from other compiled JAR files in your application. To include these files, save the JAR file in a new project in the same workspace as your application. Make this new project a library application and make your application dependent on this library. You can then import all of its classes. The following steps make up this procedure.&lt;/p&gt; &lt;p class="pBody"&gt;To create a new project&lt;/p&gt; &lt;ol class="OrderedList"&gt;&lt;div class="OrderedList1"&gt;&lt;li&gt;Open the workspace that contains your application's project.&lt;/li&gt; &lt;li&gt;Create a new project.&lt;/li&gt;&lt;/div&gt;&lt;/ol&gt; &lt;p class="pBody"&gt;To add a compiled JAR file to the project&lt;/p&gt; &lt;ol class="OrderedList"&gt;&lt;div class="OrderedList1"&gt;&lt;li&gt;In the navigation pane, select the project.&lt;/li&gt; &lt;li&gt;On the &lt;b class="bB"&gt;Build&lt;/b&gt; menu, select &lt;b class="bB"&gt;Project&lt;/b&gt; &gt; &lt;b class="bB"&gt;Add File to Project&lt;/b&gt;.&lt;/li&gt; &lt;li&gt;Select the appropriate JAR file and click &lt;b class="bB"&gt;Open&lt;/b&gt;.&lt;/li&gt;&lt;/div&gt;&lt;/ol&gt; &lt;p class="pBody"&gt;To make the project a library&lt;/p&gt; &lt;ol class="OrderedList"&gt;&lt;div class="OrderedList1"&gt;&lt;li&gt;In the navigation pane, select the project.&lt;/li&gt; &lt;li&gt;Right-click and select &lt;b class="bB"&gt;Properties&lt;/b&gt;. The &lt;&lt;i&gt;Project name&lt;/i&gt;&gt; Class Properties window appears.&lt;/li&gt; &lt;li&gt;Click the &lt;b class="bB"&gt;Application&lt;/b&gt; tab.&lt;/li&gt; &lt;li&gt;From the &lt;b class="bB"&gt;Project Type&lt;/b&gt; drop-down list, select &lt;b class="bB"&gt;Library&lt;/b&gt;.&lt;/li&gt;&lt;/div&gt;&lt;/ol&gt; &lt;p class="pBody"&gt;To compile the project&lt;/p&gt; &lt;ol class="OrderedList"&gt;&lt;div class="OrderedList1"&gt;&lt;li&gt;In the navigation pane, select the project.&lt;/li&gt; &lt;li&gt;Right-click and click &lt;b class="bB"&gt;Build Project&lt;/b&gt;.&lt;/li&gt;&lt;/div&gt;&lt;/ol&gt; &lt;p class="pBody"&gt;To make the project dependent on the new library&lt;/p&gt; &lt;ol class="OrderedList"&gt;&lt;div class="OrderedList1"&gt;&lt;li&gt;In the navigation pane, select the project.&lt;/li&gt; &lt;li&gt;Right-click and click &lt;b class="bB"&gt;Project Dependencies&lt;/b&gt;. The Class depends on &lt;&lt;i&gt;Project name:&lt;/i&gt;&gt; window appears.&lt;/li&gt; &lt;li&gt;Select the &lt;b class="bB"&gt;&lt;project&gt;&lt;/b&gt; check box.&lt;/li&gt;&lt;/div&gt;&lt;/ol&gt; &lt;p class="pBody"&gt;Your application can now import the classes in this JAR file with the import “xxx.yyy.*” command.&lt;/p&gt;&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-6283581862602716006?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/6283581862602716006/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=6283581862602716006' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/6283581862602716006'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/6283581862602716006'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/09/how-to-compile-jar-file-into-blackberry.html' title='How To - Compile a jar file into a BlackBerry Library'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-272763882270722203</id><published>2009-08-29T07:33:00.001-07:00</published><updated>2009-08-29T07:33:48.429-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='BlackBerry'/><title type='text'>Displays a route between locations on a map.</title><content type='html'>/**&lt;br /&gt;     * Displays a route between locations on a map.&lt;br /&gt;     */&lt;br /&gt;    private MenuItem viewRouteItem = new MenuItem("View Route" , 3000, 10)&lt;br /&gt;    {&lt;br /&gt;        public void run()&lt;br /&gt;        {&lt;br /&gt;            StringBuffer stringBuffer = new StringBuffer("&lt;location-document&gt;&lt;getroute&gt;");&lt;br /&gt;            stringBuffer.append("&lt;location lon="'-8030000'" lat="'4326000'" label="'Kitchener," description="'Kitchener,"&gt;");&lt;br /&gt;            stringBuffer.append("&lt;location lon="'-7569792'" lat="'4542349'" label="'Ottawa," description="'Ottawa,"&gt;");&lt;br /&gt;            stringBuffer.append("&lt;/getroute&gt;&lt;/location-document&gt;");          &lt;br /&gt;                               &lt;br /&gt;            Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments( MapsArguments.ARG_LOCATION_DOCUMENT, stringBuffer.toString()));&lt;br /&gt;        }&lt;br /&gt;    };&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-272763882270722203?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/272763882270722203/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=272763882270722203' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/272763882270722203'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/272763882270722203'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/08/displays-route-between-locations-on-map.html' title='Displays a route between locations on a map.'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-4562090630119529820</id><published>2009-08-07T06:03:00.000-07:00</published><updated>2009-08-07T06:04:40.207-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technique'/><title type='text'>C# calls command</title><content type='html'>&lt;p&gt;&lt;strong&gt;Example 1.&lt;/strong&gt; Running a command line application, without concern for the results:&lt;/p&gt;&lt;pre&gt;&lt;span style="font-weight: 400; font-size: 12px; color: rgb(0, 0, 255); font-family: Courier New;"&gt;private&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span style="font-weight: 400; font-size: 12px; color: rgb(0, 0, 255); font-family: Courier New;"&gt;void&lt;/span&gt;&lt;span&gt; simpleRun_Click(&lt;/span&gt;&lt;span style="font-weight: 400; font-size: 12px; color: rgb(0, 0, 255); font-family: Courier New;"&gt;object&lt;/span&gt;&lt;span&gt; sender, System.EventArgs e)&lt;/span&gt;&lt;span&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span&gt; System.Diagnostics.Process.Start(@&lt;/span&gt;&lt;span style="font-weight: 400; font-size: 12px; color: rgb(255, 0, 0); font-family: Courier New;"&gt;"C:\listfiles.bat"&lt;/span&gt;&lt;span&gt;);&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt; &lt;p&gt;&lt;strong&gt;Example 2.&lt;/strong&gt; Retrieving the results and waiting until the process stops (running the process synchronously):&lt;/p&gt;&lt;pre&gt;&lt;span style="font-weight: 400; font-size: 12px; color: rgb(0, 0, 255); font-family: Courier New;"&gt;private&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span style="font-weight: 400; font-size: 12px; color: rgb(0, 0, 255); font-family: Courier New;"&gt;void&lt;/span&gt;&lt;span&gt; runSyncAndGetResults_Click(&lt;/span&gt;&lt;span style="font-weight: 400; font-size: 12px; color: rgb(0, 0, 255); font-family: Courier New;"&gt;object&lt;/span&gt;&lt;span&gt; sender, System.EventArgs e){&lt;br /&gt; System.Diagnostics.ProcessStartInfo psi =&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-weight: 400; font-size: 12px; color: rgb(0, 0, 255); font-family: Courier New;"&gt;new&lt;/span&gt;&lt;span&gt; System.Diagnostics.ProcessStartInfo(@&lt;/span&gt;&lt;span style="font-weight: 400; font-size: 12px; color: rgb(255, 0, 0); font-family: Courier New;"&gt;"C:\listfiles.bat"&lt;/span&gt;&lt;span&gt;);&lt;br /&gt; psi.RedirectStandardOutput = &lt;/span&gt;&lt;span style="font-weight: 400; font-size: 12px; color: rgb(0, 0, 255); font-family: Courier New;"&gt;true&lt;/span&gt;&lt;span&gt;;&lt;br /&gt; psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;&lt;br /&gt; psi.UseShellExecute = &lt;/span&gt;&lt;span style="font-weight: 400; font-size: 12px; color: rgb(0, 0, 255); font-family: Courier New;"&gt;false&lt;/span&gt;&lt;span&gt;;&lt;br /&gt; System.Diagnostics.Process listFiles;&lt;br /&gt; listFiles = System.Diagnostics.Process.Start(psi);&lt;br /&gt; System.IO.StreamReader myOutput = listFiles.StandardOutput;&lt;br /&gt; listFiles.WaitForExit(2000);&lt;br /&gt; &lt;/span&gt;&lt;span style="font-weight: 400; font-size: 12px; color: rgb(0, 0, 255); font-family: Courier New;"&gt;if&lt;/span&gt;&lt;span&gt; (listFiles.HasExited)&lt;br /&gt; {&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-weight: 400; font-size: 12px; color: rgb(0, 0, 255); font-family: Courier New;"&gt;string&lt;/span&gt;&lt;span&gt; output = myOutput.ReadToEnd();&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-weight: 400; font-size: 12px; color: rgb(0, 0, 255); font-family: Courier New;"&gt;this&lt;/span&gt;&lt;span&gt;.processResults.Text = output;&lt;br /&gt; }&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt; &lt;p&gt; &lt;strong&gt;Example 3.&lt;/strong&gt; Displaying a URL using the default browser on the user's machine:&lt;/p&gt;&lt;pre&gt;&lt;span style="font-weight: 400; font-size: 12px; color: rgb(0, 0, 255); font-family: Courier New;"&gt;private&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span style="font-weight: 400; font-size: 12px; color: rgb(0, 0, 255); font-family: Courier New;"&gt;void&lt;/span&gt;&lt;span&gt; launchURL_Click(&lt;/span&gt;&lt;span style="font-weight: 400; font-size: 12px; color: rgb(0, 0, 255); font-family: Courier New;"&gt;object&lt;/span&gt;&lt;span&gt; sender, System.EventArgs e){&lt;br /&gt; &lt;/span&gt;&lt;span style="font-weight: 400; font-size: 12px; color: rgb(0, 0, 255); font-family: Courier New;"&gt;string&lt;/span&gt;&lt;span&gt; targetURL = @&lt;/span&gt;&lt;span style="font-weight: 400; font-size: 12px; color: rgb(255, 0, 0); font-family: Courier New;"&gt;&lt;a href="http://www.duncanmackenzie.net/"&gt;http://www.duncanmackenzie.net&lt;/a&gt;&lt;/span&gt;&lt;span&gt;;&lt;br /&gt; System.Diagnostics.Process.Start(targetURL);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;h2&gt;Using the Code&lt;/h2&gt;  &lt;p&gt;The code given below creates a process i.e. a command process and then invokes the command that we want to execute. The result of the command is stored in a &lt;code&gt;&lt;span class="code-SDKkeyword"&gt;string&lt;/span&gt; &lt;/code&gt;variable, which can then be used for further reference. The command execution can happen in two ways, &lt;strong&gt;synchronously&lt;/strong&gt; and &lt;strong&gt;asynchronously&lt;/strong&gt;. In the asynchronous command execution, we just invoke the command execution using a thread that runs independently. The code has enough comments, hence making it self-explanatory.&lt;/p&gt;  &lt;p&gt;Below is the code to execute the command &lt;strong&gt;synchronously&lt;/strong&gt;: &lt;/p&gt;  &lt;div class="SmallText" id="premain0" style="width: 100%; cursor: pointer;"&gt;&lt;img preid="0" src="http://www.codeproject.com/images/minus.gif" id="preimg0" width="9" height="9" /&gt;&lt;span preid="0" style="margin-bottom: 0pt;" id="precollapse0"&gt; Collapse&lt;/span&gt;&lt;/div&gt;&lt;span class="code-SummaryComment"&gt;///&lt;/span&gt;&lt;span class="code-comment"&gt; &lt;span class="code-SummaryComment"&gt;&lt;&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;summary&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class="code-SummaryComment"&gt;///&lt;/span&gt;&lt;span class="code-comment"&gt; Executes a shell command synchronously.&lt;/span&gt; &lt;span class="code-SummaryComment"&gt;///&lt;/span&gt;&lt;span class="code-comment"&gt; &lt;span class="code-SummaryComment"&gt;&lt;&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;/&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;summary&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class="code-SummaryComment"&gt;///&lt;/span&gt;&lt;span class="code-comment"&gt; &lt;span class="code-SummaryComment"&gt;&lt;&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;param&lt;/span&gt; &lt;span class="code-SummaryComment"&gt;name="command"&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;&gt;&lt;/span&gt;string command&lt;span class="code-SummaryComment"&gt;&lt;&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;/&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;param&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class="code-SummaryComment"&gt;///&lt;/span&gt;&lt;span class="code-comment"&gt; &lt;span class="code-SummaryComment"&gt;&lt;&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;returns&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;&gt;&lt;/span&gt;string, as output of the command.&lt;span class="code-SummaryComment"&gt;&lt;&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;/&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;returns&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;void&lt;/span&gt; ExecuteCommandSync(&lt;span class="code-keyword"&gt;object&lt;/span&gt; command) {      &lt;span class="code-keyword"&gt;try&lt;/span&gt;      {          &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; create the ProcessStartInfo using "cmd" as the program to be run,&lt;/span&gt;          &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; and "/c " as the parameters.&lt;/span&gt;          &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Incidentally, /c tells cmd that we want it to execute the command that follows,&lt;/span&gt;          &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; and then exit.&lt;/span&gt;     System.Diagnostics.ProcessStartInfo procStartInfo =         &lt;span class="code-keyword"&gt;new&lt;/span&gt; System.Diagnostics.ProcessStartInfo(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;cmd"&lt;/span&gt;, &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;/c "&lt;/span&gt; + command);      &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; The following commands are needed to redirect the standard output.&lt;/span&gt;     &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; This means that it will be redirected to the Process.StandardOutput StreamReader.&lt;/span&gt;     procStartInfo.RedirectStandardOutput = &lt;span class="code-keyword"&gt;true&lt;/span&gt;;     procStartInfo.UseShellExecute = &lt;span class="code-keyword"&gt;false&lt;/span&gt;;     &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Do not create the black window.&lt;/span&gt;     procStartInfo.CreateNoWindow = &lt;span class="code-keyword"&gt;true&lt;/span&gt;;     &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Now we create a process, assign its ProcessStartInfo and start it&lt;/span&gt;     System.Diagnostics.Process proc = &lt;span class="code-keyword"&gt;new&lt;/span&gt; System.Diagnostics.Process();     proc.StartInfo = procStartInfo;     proc.Start();     &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Get the output into a string&lt;/span&gt;     &lt;span class="code-keyword"&gt;string&lt;/span&gt; result = proc.StandardOutput.ReadToEnd();     &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Display the command output.&lt;/span&gt;     Console.WriteLine(result);       }       &lt;span class="code-keyword"&gt;catch&lt;/span&gt; (Exception objException)       {       &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Log the exception&lt;/span&gt;       } }  &lt;p&gt;The above code invokes the &lt;code&gt;cmd &lt;/code&gt;process specifying the command to be executed. The option &lt;code&gt;procStartInfo.RedirectStandardOutput &lt;/code&gt;is set to &lt;code&gt;&lt;span class="code-keyword"&gt;true&lt;/span&gt;&lt;/code&gt;, since we want the output to be redirected to the &lt;code&gt;StreamReader&lt;/code&gt;. The &lt;code&gt;procStartInfo.CreateNoWindow &lt;/code&gt;property is set to &lt;code&gt;&lt;span class="code-keyword"&gt;true&lt;/span&gt;&lt;/code&gt;, as we don't want the standard black window to appear. This will execute the command silently.&lt;/p&gt;  &lt;p&gt;Below is the code to execute the command &lt;strong&gt;asynchronously&lt;/strong&gt;:&lt;/p&gt;  &lt;div class="SmallText" id="premain1" style="width: 100%; cursor: pointer;"&gt;&lt;img preid="1" src="http://www.codeproject.com/images/minus.gif" id="preimg1" width="9" height="9" /&gt;&lt;span preid="1" style="margin-bottom: 0pt;" id="precollapse1"&gt; Collapse&lt;/span&gt;&lt;/div&gt;&lt;span class="code-SummaryComment"&gt;///&lt;/span&gt;&lt;span class="code-comment"&gt; &lt;span class="code-SummaryComment"&gt;&lt;&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;summary&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class="code-SummaryComment"&gt;///&lt;/span&gt;&lt;span class="code-comment"&gt; Execute the command Asynchronously.&lt;/span&gt; &lt;span class="code-SummaryComment"&gt;///&lt;/span&gt;&lt;span class="code-comment"&gt; &lt;span class="code-SummaryComment"&gt;&lt;&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;/&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;summary&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class="code-SummaryComment"&gt;///&lt;/span&gt;&lt;span class="code-comment"&gt; &lt;span class="code-SummaryComment"&gt;&lt;&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;param&lt;/span&gt; &lt;span class="code-SummaryComment"&gt;name="command"&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;&gt;&lt;/span&gt;string command.&lt;span class="code-SummaryComment"&gt;&lt;&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;/&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;param&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;void&lt;/span&gt; ExecuteCommandAsync(&lt;span class="code-keyword"&gt;string&lt;/span&gt; command) {    &lt;span class="code-keyword"&gt;try&lt;/span&gt;    {     &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;Asynchronously start the Thread to process the Execute command request.&lt;/span&gt;     Thread objThread = &lt;span class="code-keyword"&gt;new&lt;/span&gt; Thread(&lt;span class="code-keyword"&gt;new&lt;/span&gt; ParameterizedThreadStart(ExecuteCommandSync));     &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;Make the thread as background thread.&lt;/span&gt;     objThread.IsBackground = &lt;span class="code-keyword"&gt;true&lt;/span&gt;;     &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;Set the Priority of the thread.&lt;/span&gt;     objThread.Priority = ThreadPriority.AboveNormal;     &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;Start the thread.&lt;/span&gt;     objThread.Start(command);    }    &lt;span class="code-keyword"&gt;catch&lt;/span&gt; (ThreadStartException objException)    {     &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Log the exception&lt;/span&gt;    }    &lt;span class="code-keyword"&gt;catch&lt;/span&gt; (ThreadAbortException objException)    {     &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Log the exception&lt;/span&gt;    }    &lt;span class="code-keyword"&gt;catch&lt;/span&gt; (Exception objException)    {     &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Log the exception&lt;/span&gt;    } }&lt;pre&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-4562090630119529820?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/4562090630119529820/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=4562090630119529820' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/4562090630119529820'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/4562090630119529820'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/08/c-calls-command.html' title='C# calls command'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-2477540645415294054</id><published>2009-07-31T08:50:00.000-07:00</published><updated>2009-07-31T08:52:10.414-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='BlackBerry'/><title type='text'>service book sample</title><content type='html'>import net.rim.device.api.system.*;&lt;br /&gt;import net.rim.device.api.servicebook.*;&lt;br /&gt;&lt;br /&gt;public class ServiceBookExample extends Application {&lt;br /&gt;    ServiceRecord[] _sRecordsArray; // Creates a ServiceRecord array.&lt;br /&gt;    ServiceBook _servicebook; // Creates a ServiceBook variable.&lt;br /&gt;    String cidValue, sbName, sbAPN;&lt;br /&gt;&lt;br /&gt;    public static void main(String[] args) {&lt;br /&gt;        // Create a new instance of the application and&lt;br /&gt;        // start the event thread.&lt;br /&gt;        ServiceBookExample app = new ServiceBookExample();&lt;br /&gt;        app.enterEventDispatcher();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public ServiceBookExample() {&lt;br /&gt;        // Returns a reference to the service book from the factory.&lt;br /&gt;        _servicebook = ServiceBook.getSB();&lt;br /&gt;        // Returns an array of all registered service records.&lt;br /&gt;        _sRecordsArray = _servicebook.getRecords();&lt;br /&gt;        // Loops through the service record array&lt;br /&gt;        // and obtains specific information relating&lt;br /&gt;        // to each item and prints it to the debugging output.&lt;br /&gt;        for (int i = 0; i &lt; _sRecordsArray.length; i++) {&lt;br /&gt;            // Obtains the Service Book CID&lt;br /&gt;            cidValue = _sRecordsArray[i].getCid();&lt;br /&gt;            // Obtains the Name of the Service Book&lt;br /&gt;            sbName = _sRecordsArray[i].getName();&lt;br /&gt;            if (cidValue.equals("BrowserConfig")&lt;br /&gt;                    &amp;amp;&amp;amp; sbName.startsWith("WAP Browser")) {&lt;br /&gt;                // Obtains the Service Book's APN&lt;br /&gt;                // (Associated Access Point Name)&lt;br /&gt;                String sbAPN = _sRecordsArray[i].getAPN();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-2477540645415294054?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/2477540645415294054/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=2477540645415294054' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/2477540645415294054'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/2477540645415294054'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/07/service-book-sample.html' title='service book sample'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-683436171711427400</id><published>2009-07-21T10:55:00.000-07:00</published><updated>2009-07-21T11:15:45.966-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technique'/><title type='text'>About pushing for iPhone and Blackberry</title><content type='html'>I must say apple did it a neat and easier way, BB is not :(&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;BB&lt;/span&gt;&lt;br /&gt;http://na.blackberry.com/eng/developers/javaappdev/pushapi.jsp#tab_tab_works&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;iPhone&lt;/span&gt;&lt;br /&gt;A nice guide to setup your server:&lt;br /&gt;&lt;br /&gt;http://www.macoscoders.com/2009/05/17/iphone-apple-push-notification-service-apns/&lt;br /&gt;another good one:&lt;br /&gt;&lt;br /&gt;http://blog.boxedice.com/2009/07/10/how-to-build-an-apple-push-notification-provider-server-tutorial/&lt;br /&gt;&lt;br /&gt;basically you need a developer's id, then apply for the iPhone Push Notification Server (PNS) service. After got the certificate, you just put it on your Apache server. Or you may write a Java or .Net program to load the certificate and send out your testing data.&lt;br /&gt;&lt;br /&gt;package com.demo.samples;&lt;br /&gt;import java.io.ByteArrayOutputStream;&lt;br /&gt;import java.io.FileInputStream;&lt;br /&gt;import java.io.InputStream;&lt;br /&gt;import java.io.OutputStream;&lt;br /&gt;import java.security.KeyStore;&lt;br /&gt;&lt;br /&gt;import javax.net.ssl.KeyManagerFactory;&lt;br /&gt;import javax.net.ssl.SSLContext;&lt;br /&gt;import javax.net.ssl.SSLSocket;&lt;br /&gt;import javax.net.ssl.SSLSocketFactory;&lt;br /&gt;&lt;br /&gt;import java.awt.image.RenderedImage;&lt;br /&gt;import java.io.IOException;&lt;br /&gt;&lt;br /&gt;public class pushdemo {&lt;br /&gt;&lt;br /&gt;   /**&lt;br /&gt;    * @param args&lt;br /&gt;    */&lt;br /&gt;   public static void main(String[] args) {&lt;br /&gt;       System.out.println(args[0]);&lt;br /&gt;       if (args.length != 2) {&lt;br /&gt;           System.out.println("Usage: KeGenerator phonenumber ExpireDate(yyyy-MM-dd)");&lt;br /&gt;           System.exit(0);&lt;br /&gt;       }&lt;br /&gt;     &lt;br /&gt;       // TODO Auto-generated method stub&lt;br /&gt;       try {&lt;br /&gt;       int port = 2195;&lt;br /&gt;       String hostname = "gateway.sandbox.push.apple.com";&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;       char []passwKey = "keypassword".toCharArray();&lt;br /&gt;       KeyStore ts = KeyStore.getInstance("PKCS12");&lt;br /&gt;       ts.load(new FileInputStream("devCert.p12"), passwKey);&lt;br /&gt;&lt;br /&gt;       KeyManagerFactory tmf = KeyManagerFactory.getInstance("SunX509");&lt;br /&gt;       tmf.init(ts,passwKey);&lt;br /&gt;       SSLContext sslContext = SSLContext.getInstance("TLS");&lt;br /&gt;       sslContext.init(tmf.getKeyManagers(), null, null);&lt;br /&gt;       SSLSocketFactory factory =sslContext.getSocketFactory();&lt;br /&gt;       SSLSocket socket = (SSLSocket) factory.createSocket(hostname,port); // Create the ServerSocket&lt;br /&gt;       String[] suites = socket.getSupportedCipherSuites();&lt;br /&gt;       socket.setEnabledCipherSuites(suites);&lt;br /&gt;       //start handshake&lt;br /&gt;&lt;br /&gt;       socket.startHandshake();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;       // Create streams to securely send and receive data to the server&lt;br /&gt;       InputStream in = socket.getInputStream();&lt;br /&gt;       OutputStream out = socket.getOutputStream();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;       // Read from in and write to out...&lt;br /&gt;       ByteArrayOutputStream baos = new ByteArrayOutputStream();&lt;br /&gt;       baos.write(0); //The command&lt;br /&gt;       System.out.println("First byte Current size: " + baos.size());&lt;br /&gt;&lt;br /&gt;       baos.write(0); //The first byte of the deviceId length  &lt;br /&gt;       baos.write(32); //The deviceId length&lt;br /&gt;&lt;br /&gt;       System.out.println("Second byte Current size: " + baos.size());&lt;br /&gt;&lt;br /&gt;       String deviceId = "02da851db4f2b5bfce1982700d3dac72bc87cd60";&lt;br /&gt;       baos.write(hexStringToByteArray(deviceId.toUpperCase()));&lt;br /&gt;       System.out.println("Device ID: Current size: " + baos.size());&lt;br /&gt;&lt;br /&gt;//{     "aps" : {         "alert" : { "body" : "Bob wants to play poker", "action-loc-key" : "PLAY" },         "badge" : 5,     },     "acme1" : "bar",     "acme2" : [ "bang",  "whiz" ] }&lt;br /&gt;       String payload = "{\"aps\":{\"alert\":\"I like spoons also\",\"badge\":14}}";&lt;br /&gt;       System.out.println("Sending payload: " + payload);&lt;br /&gt;       baos.write(0); //First byte of payload length;&lt;br /&gt;       baos.write(payload.length());&lt;br /&gt;       baos.write(payload.getBytes());&lt;br /&gt;&lt;br /&gt;       out.write(baos.toByteArray());&lt;br /&gt;       out.flush();&lt;br /&gt;&lt;br /&gt;       System.out.println("Closing socket.." + in.read());&lt;br /&gt;       // Close the socket&lt;br /&gt;       in.close();&lt;br /&gt;       out.close();&lt;br /&gt;       } catch (Exception e) {&lt;br /&gt;           e.printStackTrace();&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;   public static byte[] hexStringToByteArray(String s) {&lt;br /&gt;       byte[] b = new byte[s.length() / 2];&lt;br /&gt;       for (int i = 0; i &lt; b.length; i++){&lt;br /&gt;         int index = i * 2;&lt;br /&gt;         int v = Integer.parseInt(s.substring(index, index + 2), 16);&lt;br /&gt;         b[i] = (byte)v;&lt;br /&gt;       }&lt;br /&gt;       return b;&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-683436171711427400?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/683436171711427400/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=683436171711427400' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/683436171711427400'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/683436171711427400'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/07/about-pushing-for-iphone-and-blackberry.html' title='About pushing for iPhone and Blackberry'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-3694393082021661052</id><published>2009-07-16T14:18:00.000-07:00</published><updated>2009-07-16T14:20:33.719-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='BlackBerry'/><title type='text'>monitor Blackberry BackLight</title><content type='html'>SystemListener2&lt;br /&gt;backlightStateChange&lt;br /&gt;&lt;br /&gt;You need to implement the SystemListener2 interface and will be called when light changes. .&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:-1;"&gt;  &lt;code&gt;void&lt;/code&gt;&lt;/span&gt; &lt;code&gt;&lt;b&gt;&lt;a href="http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/system/SystemListener2.html#backlightStateChange%28boolean%29"&gt;backlightStateChange&lt;/a&gt;&lt;/b&gt;(boolean on)&lt;/code&gt; &lt;br /&gt;          Invoked when the backlight state changes.&lt;br /&gt;&lt;br /&gt;http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/system/SystemListener2.html&lt;a id="publishButton" class="cssButton" href="javascript:void(0)" target="" onclick="if (this.className.indexOf(&amp;quot;ubtn-disabled&amp;quot;) == -1) {var e = document['stuffform'].publish;(e.length) ? e[0].click() : e.click(); if (window.event) window.event.cancelBubble = true; return false;}"&gt;&lt;div class="cssButtonOuter"&gt;&lt;div class="cssButtonMiddle"&gt;&lt;div class="cssButtonInner"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-3694393082021661052?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/3694393082021661052/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=3694393082021661052' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/3694393082021661052'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/3694393082021661052'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/07/monitor-blackberry-backlight.html' title='monitor Blackberry BackLight'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-4827216153023912978</id><published>2009-07-16T09:31:00.000-07:00</published><updated>2009-07-16T09:39:38.273-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technique'/><title type='text'>Free tools</title><content type='html'>SVG Anti-Virus Free&lt;br /&gt;WINScp ftp client&lt;br /&gt;SciTE edit tool&lt;br /&gt;Actual Multiple Monitors&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-4827216153023912978?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/4827216153023912978/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=4827216153023912978' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/4827216153023912978'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/4827216153023912978'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/07/free-tools.html' title='Free tools'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-3319169478179583142</id><published>2009-07-10T21:01:00.001-07:00</published><updated>2009-07-10T21:01:27.297-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technique'/><title type='text'>Setting up a Subversion Server under Windows</title><content type='html'>&lt;h2&gt;Setting up a Subversion Server under Windows&lt;/h2&gt;                     &lt;p&gt;I talked a little bit about what Subversion is in &lt;a href="http://blogs.vertigosoftware.com/teamsystem/archive/2006/01/16/1873.aspx"&gt;my previous post&lt;/a&gt;. Now, let's get it set it up in Windows.&lt;/p&gt; &lt;p&gt;Luckily for us, Joe White has done most of the work already; he has a &lt;a href="http://excastle.com/blog/archive/2005/05/31/1048.aspx"&gt;tremendously helpful post&lt;/a&gt; that documents how to set up Subversion. I'll see if I can streamline his excellent post a bit further, and illustrate it with screenshots.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;A) Download Subversion&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;You'll need the latest version of..&lt;/p&gt; &lt;ul&gt;&lt;li&gt;the &lt;a href="http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91"&gt;Windows binaries&lt;/a&gt;  &lt;/li&gt;&lt;li&gt;the &lt;a href="http://dark.clansoft.dk/%7Embn/svnservice/"&gt;"run Subversion as a windows service" wrapper&lt;/a&gt;  &lt;/li&gt;&lt;li&gt;the TortoiseSVN &lt;a href="http://tortoisesvn.tigris.org/download.html"&gt;shell integration utility&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;B) Install Subversion&lt;/strong&gt;&lt;/p&gt; &lt;ol&gt;&lt;li&gt;Unzip the Windows binaries to a folder of your choice. I chose &lt;em&gt;c:\program files\subversion\&lt;/em&gt; as my path.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Now, add the subversion binaries to the path environment variable for the machine. I used &lt;em&gt;%programfiles%\subversion\bin\&lt;/em&gt;&lt;br /&gt;&lt;img src="http://blogs.vertigosoftware.com/photos/jatwood/images/1877/original.aspx" /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;You'll also need another environment variable, SVN_EDITOR, set to the text editor of your choice. I used &lt;em&gt;c:\windows\notepad.exe&lt;/em&gt;&lt;br /&gt;&lt;img src="http://blogs.vertigosoftware.com/photos/jatwood/images/1876/original.aspx" /&gt;&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;strong&gt;C) Create a Repository&lt;/strong&gt;&lt;/p&gt; &lt;ol&gt;&lt;li&gt;Open a command prompt and type&lt;pre&gt;svnadmin create "c:\Documents and Settings\Subversion Repository"&lt;/pre&gt; &lt;/li&gt;&lt;li&gt;Navigate to the folder we just created. Within that folder, uncomment the following lines in the &lt;em&gt;/conf/svnserve.conf&lt;/em&gt; file:  &lt;pre&gt;[general]&lt;br /&gt;anon-access = read&lt;br /&gt;auth-access = write&lt;br /&gt;password-db = passwd&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;Next, uncomment these lines in the &lt;em&gt;/conf/passwd&lt;/em&gt; file:&lt;/p&gt; &lt;pre&gt;[users]&lt;br /&gt;harry = harryssecret&lt;br /&gt;sally = sallyssecret&lt;/pre&gt;&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;strong&gt;D) Verify that everything is working&lt;/strong&gt;&lt;/p&gt; &lt;ol&gt;&lt;li&gt;Start the subversion server by issuing this command in the command window:  &lt;pre&gt;svnserve --daemon --root "C:\Documents and Settings\Subversion Repository"&lt;br /&gt;&lt;/pre&gt;  &lt;/li&gt;&lt;li&gt; &lt;p&gt;Create a project by opening a second command window and entering this command:&lt;/p&gt;&lt;pre&gt;svn mkdir svn://localhost/myproject&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;It's a standard Subversion convention to have three folders at the root of a project:  &lt;/p&gt;&lt;blockquote dir="ltr"&gt; &lt;p&gt;&lt;i&gt;/trunk&lt;/i&gt;&lt;br /&gt;&lt;i&gt;/branches&lt;/i&gt;&lt;br /&gt;&lt;i&gt;/tags&lt;/i&gt;&lt;br /&gt;&lt;/p&gt; &lt;/blockquote&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;At this point, Notepad should launch:&lt;/p&gt; &lt;p&gt;&lt;img src="http://blogs.vertigosoftware.com/photos/jatwood/images/1882/original.aspx" /&gt;  &lt;/p&gt;Enter any comment you want at the top of the file, then save and exit.   &lt;/li&gt;&lt;li&gt; &lt;p&gt;You'll now be prompted for credentials. In my case I was prompted for the administrator credentials as well:&lt;/p&gt;&lt;pre&gt;Authentication realm:  0f1a8b11-d50b-344d-9dc7-0d9ba12e22df&lt;br /&gt;Password for 'Administrator': *********&lt;br /&gt;Authentication realm:  0f1a8b11-d50b-344d-9dc7-0d9ba12e22df&lt;br /&gt;Username: sally&lt;br /&gt;Password for 'sally': ************&lt;br /&gt;&lt;br /&gt;Committed revision 1.&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;Congratulations! You just checked a change into Subversion!&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;strong&gt;E) Start the server as a service&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt; &lt;ol&gt;&lt;li&gt;Stop the existing command window that's running svnserve by pressing CTRL+C.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Copy the file &lt;em&gt;SVNService.exe&lt;/em&gt; from the zip file of the same name to the &lt;em&gt;subversion\bin&lt;/em&gt; folder.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Install the service by issuing the following commands:  &lt;pre&gt;svnservice -install --daemon --root "C:\Documents and Settings\Subversion Repository"&lt;br /&gt;sc config svnservice start= auto&lt;br /&gt;net start svnservice&lt;/pre&gt; &lt;/li&gt;&lt;li&gt;Test the new service by listing all the files in the repository:  &lt;pre&gt;svn ls svn://localhost/&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;You should see the single project we created earlier, &lt;i&gt;myproject/ &lt;/i&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;strong&gt;F) Set up the shell extension&lt;/strong&gt;&lt;/p&gt; &lt;ol&gt;&lt;li&gt;Run the TortoiseSVN installer. It will tell you to restart, but you don't need to.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Create a project folder somewhere on your hard drive. Right click in that folder and select "SVN Checkout..."&lt;br /&gt;&lt;br /&gt;&lt;img src="http://blogs.vertigosoftware.com/photos/jatwood/images/1892/original.aspx" /&gt;&lt;br /&gt;&lt;br /&gt;type &lt;em&gt;svn://localhost/myproject/&lt;/em&gt; for the repository URL and click OK.&lt;br /&gt;&lt;br /&gt;&lt;img src="http://blogs.vertigosoftware.com/photos/jatwood/images/1891/original.aspx" /&gt;&lt;br /&gt; &lt;/li&gt;&lt;li&gt;Create a new file in that directory. Right click the file and select "TortoiseSVN, Add"&lt;br /&gt;&lt;br /&gt;&lt;img src="http://blogs.vertigosoftware.com/photos/jatwood/images/1893/original.aspx" /&gt;&lt;br /&gt; &lt;/li&gt;&lt;li&gt;The file hasn't actually been checked in yet. Subversion batches any changes and commits them as one atomic operation. To send all your changes to the server, right click and select "SVN Commit":&lt;br /&gt;&lt;br /&gt;&lt;img src="http://blogs.vertigosoftware.com/photos/jatwood/images/1895/original.aspx" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;And we're done! &lt;strong&gt;You now have a networked Subversion server and client set up on your machine&lt;/strong&gt;. Note that the default port for svnserve is 3690.&lt;/p&gt; &lt;p&gt;For more tips on using subversion, take a look at &lt;a href="http://svnbook.red-bean.com/"&gt;the free O'Reilly Subversion book&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-3319169478179583142?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/3319169478179583142/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=3319169478179583142' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/3319169478179583142'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/3319169478179583142'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/07/setting-up-subversion-server-under.html' title='Setting up a Subversion Server under Windows'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-1468888887423477547</id><published>2009-07-10T14:12:00.000-07:00</published><updated>2009-07-10T14:14:04.297-07:00</updated><title type='text'>good J2me UI framework</title><content type='html'>&lt;a href="http://javabyexample.wisdomplug.com/component/content/article/44-libraries/73-great-user-interface-libraries-for-j2me-developers.html" class="contentpagetitle"&gt;Great User Interface Libraries for J2ME Developers&lt;/a&gt;                     &lt;table class="contentpaneopen"&gt; &lt;tbody&gt;&lt;tr&gt;  &lt;td&gt;     &lt;span&gt;        &lt;a href="http://javabyexample.wisdomplug.com/component/content/section/12.html"&gt;      J2ME       &lt;/a&gt;         &lt;/span&gt;      &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td colspan="2" valign="top" width="70%"&gt;   &lt;span class="small"&gt;    Written by Vimal  &lt;/span&gt;       &lt;/td&gt; &lt;/tr&gt;  &lt;tr&gt;  &lt;td colspan="2" class="createdate" valign="top"&gt;   Wednesday, 23 July 2008 09:12 &lt;/td&gt; &lt;/tr&gt;   &lt;tr&gt; &lt;td colspan="2" valign="top"&gt; &lt;div class="ultimatesbplugin_top"&gt; &lt;script type="text/javascript"&gt;digg_url = 'http://javabyexample.wisdomplug.com/component/content/article/44-libraries/73-great-user-interface-libraries-for-j2me-developers.html'; digg_title = 'Great User Interface Libraries for J2ME Developers'; digg_bodytext = 'List of User Interface Libraries for J2ME'; digg_bgcolor = '#ffffff'; digg_window = 'new';&lt;/script&gt;&lt;script src="http://digg.com/tools/diggthis.js" type="text/javascript"&gt;&lt;/script&gt;&lt;iframe src="http://digg.com/tools/diggthis.php?u=http%3A//javabyexample.wisdomplug.com/component/content/article/44-libraries/73-great-user-interface-libraries-for-j2me-developers.html&amp;amp;t=Great%20User%20Interface%20Libraries%20for%20J2ME%20Developers&amp;amp;w=new&amp;amp;b=List%20of%20User%20Interface%20Libraries%20for%20J2ME&amp;amp;k=%23ffffff" scrolling="no" width="52" frameborder="0" height="80"&gt;&lt;/iframe&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ratingblock"&gt;&lt;div id="unit_long73"&gt;&lt;div class="ratingbar"&gt;  &lt;ul id="unit_ul73" class="unit-rating" style="width: 80px;"&gt;&lt;li class="current-rating" style="width: 44.8px;"&gt;Currently 2.80/5&lt;/li&gt;&lt;li class="current-rating" style="width: 44.8px;"&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://javabyexample.wisdomplug.com/components/com_alphacontent/alphacontent.db.php?j=1&amp;amp;q=73&amp;amp;t=216.7.201.3&amp;amp;c=5&amp;amp;u=16&amp;amp;p=com_content&amp;amp;lang=english&amp;amp;user=0&amp;amp;url=http://javabyexample.wisdomplug.com" title="1 out of 5" class="r1-unit rater" rel="nofollow"&gt;1&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://javabyexample.wisdomplug.com/components/com_alphacontent/alphacontent.db.php?j=2&amp;amp;q=73&amp;amp;t=216.7.201.3&amp;amp;c=5&amp;amp;u=16&amp;amp;p=com_content&amp;amp;lang=english&amp;amp;user=0&amp;amp;url=http://javabyexample.wisdomplug.com" title="2 out of 5" class="r2-unit rater" rel="nofollow"&gt;2&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://javabyexample.wisdomplug.com/components/com_alphacontent/alphacontent.db.php?j=3&amp;amp;q=73&amp;amp;t=216.7.201.3&amp;amp;c=5&amp;amp;u=16&amp;amp;p=com_content&amp;amp;lang=english&amp;amp;user=0&amp;amp;url=http://javabyexample.wisdomplug.com" title="3 out of 5" class="r3-unit rater" rel="nofollow"&gt;3&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://javabyexample.wisdomplug.com/components/com_alphacontent/alphacontent.db.php?j=4&amp;amp;q=73&amp;amp;t=216.7.201.3&amp;amp;c=5&amp;amp;u=16&amp;amp;p=com_content&amp;amp;lang=english&amp;amp;user=0&amp;amp;url=http://javabyexample.wisdomplug.com" title="4 out of 5" class="r4-unit rater" rel="nofollow"&gt;4&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://javabyexample.wisdomplug.com/components/com_alphacontent/alphacontent.db.php?j=5&amp;amp;q=73&amp;amp;t=216.7.201.3&amp;amp;c=5&amp;amp;u=16&amp;amp;p=com_content&amp;amp;lang=english&amp;amp;user=0&amp;amp;url=http://javabyexample.wisdomplug.com" title="5 out of 5" class="r5-unit rater" rel="nofollow"&gt;5&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;/div&gt;  &lt;p&gt;Rating &lt;strong&gt; 2.8&lt;/strong&gt;/5 (10 votes)  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;J2ME is a primitive but powerful development platform for devloping applications for mobile devices. A serious issue with J2ME is the lack of built in libraries to accomplish several common tasks. There are several free and commercial libraries availbale that can be used to provide more functionality in our J2ME applications. In this article I shall list down several famous User Interface libraries for J2ME. &lt;/p&gt;&lt;br /&gt;&lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;a href="http://www.java4ever.com/index.php?section=j2me&amp;amp;project=apime&amp;amp;menu=main&amp;amp;lang=_en"&gt;Apime&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;License: GPL&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Category: User Interfaces&lt;/em&gt;&lt;/p&gt; &lt;p&gt;Apime is a framework to offer more funcionality to J2ME/MIDP. The core is the user interface, with basics components to make applications with swing structure.&lt;br /&gt;Also it includes classes for file manage and customization (skins, internacionalization, keyboards for differents languages and mobiles, ...)&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;a href="http://sourceforge.net/projects/openbasemovil/"&gt;BaseMovil&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;License: GPL&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Category: User Interfaces&lt;/em&gt;&lt;/p&gt; &lt;p&gt;BaseMovil is a framework for fast development of J2ME applications: a powerful J2ME database engine, a scripting engine and an ui toolkit which is fully integrated with both and allows xml view definition. The framework handles device differences/bugs.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;a href="http://sourceforge.net/projects/fire-j2me"&gt;Fire&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;License: LGPL&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Category: User Interfaces&lt;/em&gt;&lt;/p&gt; &lt;p&gt;Fire (Flexible Interface Rendering Engine)is a lightweight themable GUI engine for j2me MIDP2 applications. It is designed to be an eye-candy replacement to the traditional midp GUI components. It provides more than the forms and items functionality and its not kvm-implementation depended.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;a href="http://www.lwvcl.com/j2me.php"&gt;LwVCL&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;License: GPL&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Category: User Interfaces&lt;/em&gt;&lt;/p&gt; &lt;p&gt;Another User Interfaces library for the J2ME platform providing many UI components like Buttons, Checkbox, Radio Box, Progreess Bars, Tabbed Panes etc.. It is designed as a replacement to the traditional J2ME Widgets.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;a href="http://code.google.com/p/j4me/"&gt;J4ME&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;License: Apache License 2.0&lt;br /&gt;&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Category: User Interfaces, Utilities&lt;br /&gt;&lt;/em&gt;&lt;/p&gt; &lt;p&gt;J4ME is an open source library to help build J2ME applications. It solves many of J2ME's shortcomings including: Uese Interfaces, Logging, GPS and various other utility classes and methods.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;a href="http://jmobilecore.sourceforge.net/"&gt;jMobileCore&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;License: LGPL&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Category: User Interfaces , Utilities&lt;br /&gt;&lt;/em&gt;&lt;/p&gt; &lt;p&gt;jMobileCore library is powerful tool for creating J2ME applications. jMobileCore provides support for developing compact and rich Canvas-based GUI, fast data access, reliable communications and simplifies creation of multithreading midlet applications.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;a href="http://www.kobjects.org/kui/index.php"&gt;kUI&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;License: GPL, Commerical&lt;br /&gt;&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Category: User Interfaces &lt;/em&gt;&lt;/p&gt; &lt;p&gt;kUI is a Canvas based replacement for the high level LCDUI classes. It can be styled to meet your own branding requirements,avoids problems with implicit close commands, does not require a preprocessing step and offers a consistent behaviour and user interface experience among different devices, simplifying your development and documentation process.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;a href="http://www.kalmeo.org/projects/kuix"&gt;Kuix&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;License: GPL&lt;br /&gt;&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Category: User Interfaces &lt;/em&gt;&lt;/p&gt; &lt;p&gt;Kuix (Kalmeo User Interface eXtensions) is a development framework that allows to create easily high end J2ME applications. It provides most graphical elements (buttons, textfields, lists, menus, etc.) needed to create advanced user graphical interfaces and uses an XML/CSS approach to describe the screens and the user actions in the application.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;a href="https://lwuit.dev.java.net/"&gt;LWUIT&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;License: GPL&lt;br /&gt;&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Category: User Interfaces &lt;/em&gt;&lt;/p&gt; &lt;p&gt;LWUIT is a UI library that is bundled together with applications and helps content developers in creating compelling and consistent Java ME applications. LWUIT supports visual components and other UI goodies such as theming, transitions, animation and more.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;a href="http://sourceforge.net/projects/mewt/"&gt;Mewt&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;License: GPL&lt;br /&gt;&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Category: User Interfaces &lt;/em&gt;&lt;/p&gt; &lt;p&gt;An advanced widget toolkit for J2ME devices, supporting cross-platform components such as tables, trees, graphical buttons, theming etc.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;a href="http://ngphone.com/j2me/opensource/ui.htm"&gt;MWT (Micro Window Toolkit)&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;License: GPL&lt;br /&gt;&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Category: User Interfaces &lt;/em&gt;&lt;/p&gt; &lt;p&gt;Inspired by its UI big brothers as AWT, Swing and SWT, MWT comes into the scene providing an UI framework designed and optimized for small devices.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;a href="http://nextel.sourceforge.net/"&gt;Nextel's Open Source J2ME Toolkits&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;License: GPL&lt;br /&gt;&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Category: User Interfaces &lt;/em&gt;&lt;/p&gt; &lt;p&gt;Nextel's Open Source J2ME Toolkits contain libraries for user interface and RMS development on J2ME handsets.&lt;br /&gt;&lt;br /&gt;The windowing toolkit, OWT (Open Windowing Toolkit), employs a container/component model, and provides interfaces to permit developers to create their own user interface components. The toolkit is designed specifically for MIDP handsets with a small amount of screen real estate. It is built on top of MIDP's Canvas class.&lt;br /&gt;&lt;br /&gt;The RMS toolkit provides classes that simplify record management on MIDP devices.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;a href="http://www.thinlet.com/index.html"&gt;Thinlet&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;License: GPL&lt;br /&gt;&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Category: User Interfaces &lt;/em&gt;&lt;/p&gt; &lt;p&gt;Thinlet is a GUI toolkit, a single Java class, parses the hierarchy and properties of the GUI, handles user interaction, and calls business logic. Separates the graphic presentation (described in an XML file) and the application methods (written as Java code).&lt;br /&gt;&lt;br /&gt;Thinlet runs with Java 1.1 to 1.4, Personal Java, and Personal (Basis) Profile. Its MIDP version was dropped, but you still can find the last MIDP version at&lt;a href="http://thinlet.sourceforge.net/download.html"&gt; Thinlet Download page&lt;/a&gt;.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;a href="http://www.synclast.com/ui_api.jsp"&gt;Synclast UI API&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;License: GPL&lt;br /&gt;&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Category: User Interfaces &lt;/em&gt;&lt;/p&gt; &lt;p&gt;The Synclast UI API is an extensible toolkit for creating colorful custom user interfaces on MIDP devices in an intuitive yet efficient manner, It provides several Widgets, Layouts, Backgrounds, Powerful Forms and Menus.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-1468888887423477547?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/1468888887423477547/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=1468888887423477547' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/1468888887423477547'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/1468888887423477547'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/07/good-j2me-ui-framework.html' title='good J2me UI framework'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-256425185956342008</id><published>2009-07-09T14:50:00.000-07:00</published><updated>2009-07-09T14:55:04.525-07:00</updated><title type='text'>ant build for your blackberry</title><content type='html'>configure the eclipse for BB&lt;br /&gt;&lt;br /&gt;http://www.blackberryforums.com/developer-forum/138210-setup-up-eclipse-blackberry-development.html&lt;br /&gt;&lt;br /&gt;Blackberry ant tool&lt;br /&gt;http://bb-ant-tools.sourceforge.net/docs&lt;br /&gt;&lt;br /&gt;Apache ant here&lt;br /&gt;&lt;br /&gt;&lt;a class="ext-link" href="http://gulus.usherbrooke.ca/pub/appl/apache/ant/binaries/apache-ant-1.7.1-bin.zip"&gt;&lt;span class="icon"&gt;&lt;/span&gt;http://gulus.usherbrooke.ca/pub/appl/apache/ant/binaries/apache-ant-1.7.1-bin.zip&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;project name="build" default="buildSEL" basedir="."&gt;&lt;taskdef resource="bb-ant-defs.xml" classpath="lib/bb-ant-tools.jar"&gt;&lt;property name="jdehome" value="C:\Program Files\Research In Motion\BlackBerry JDE 4.5.0"&gt;&lt;property name="javahome" value="C:\Program Files\Java\jdk1.6.0_07"&gt;&lt;property name="simulator" value="${jdehome}\simulator"&gt;&lt;property name="bin" value="${jdehome}\bin"&gt;&lt;property name="output" value="SmartEye_Live"&gt;&lt;property name="title" value="SmartEye Live"&gt;&lt;property name="vendor" value="company name"&gt;&lt;property name="version" value="0.1"&gt;&lt;property name="description" value="my BlackBerry program"&gt;&lt;target name="buildSEL" description="Composes RIM" depends="clean"&gt;&lt;rapc jdehome="${jdehome}" jdkhome="${javahome}" output="${output}"&gt;&lt;jdp title="${title}" vendor="${vendor}" version="${version}" description="${description}" runonstartup="false" type="cldc"&gt;&lt;src&gt;&lt;copy todir="C:\temp\h\sel\release" overwrite="true"&gt;&lt;fileset dir="."&gt;&lt;target name="clean"&gt;&lt;delete&gt;&lt;fileset dir="." includes="**/*.class"&gt;&lt;fileset dir="."&gt;&lt;include name="*.cod"&gt;&lt;include name="*.cso"&gt;&lt;project name="build" default="buildSEL" basedir="."&gt;&lt;taskdef resource="bb-ant-defs.xml" classpath="lib/bb-ant-tools.jar"&gt;&lt;property name="jdehome" value="C:\Program Files\Research In Motion\BlackBerry JDE 4.5.0"&gt;&lt;property name="javahome" value="C:\Program Files\Java\jdk1.6.0_07"&gt;&lt;property name="simulator" value="${jdehome}\simulator"&gt;&lt;property name="bin" value="${jdehome}\bin"&gt;&lt;property name="output" value="SmartEye_Live"&gt;&lt;property name="title" value="SmartEye Live"&gt;&lt;property name="vendor" value="company name"&gt;&lt;property name="version" value="0.1"&gt;&lt;property name="description" value="my BlackBerry program"&gt;&lt;target name="buildSEL" description="Composes RIM" depends="clean"&gt;&lt;rapc jdehome="${jdehome}" jdkhome="${javahome}" output="${output}"&gt;&lt;jdp title="${title}" vendor="${vendor}" version="${version}" description="${description}" runonstartup="false" type="cldc"&gt;&lt;src&gt;&lt;copy todir="C:\temp\h\sel\release" overwrite="true"&gt;&lt;fileset dir="."&gt;&lt;target name="clean"&gt;&lt;delete&gt;&lt;fileset dir="." includes="**/*.class"&gt;&lt;fileset dir="."&gt;&lt;/fileset&gt;&lt;/fileset&gt;&lt;/delete&gt;&lt;/target&gt;&lt;/fileset&gt;&lt;/copy&gt;&lt;/src&gt;&lt;/jdp&gt;&lt;/rapc&gt;&lt;/target&gt;&lt;/property&gt;&lt;/property&gt;&lt;/property&gt;&lt;/property&gt;&lt;/property&gt;&lt;/property&gt;&lt;/property&gt;&lt;/property&gt;&lt;/property&gt;&lt;/taskdef&gt;&lt;/project&gt;&lt;/include&gt;&lt;/include&gt;&lt;/fileset&gt;&lt;/fileset&gt;&lt;/delete&gt;&lt;/target&gt;&lt;/fileset&gt;&lt;/copy&gt;&lt;/src&gt;&lt;/jdp&gt;&lt;/rapc&gt;&lt;/target&gt;&lt;/property&gt;&lt;/property&gt;&lt;/property&gt;&lt;/property&gt;&lt;/property&gt;&lt;/property&gt;&lt;/property&gt;&lt;/property&gt;&lt;/property&gt;&lt;/taskdef&gt;&lt;/project&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-256425185956342008?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/256425185956342008/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=256425185956342008' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/256425185956342008'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/256425185956342008'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/07/ant-build-for-your-blackberry.html' title='ant build for your blackberry'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-5874171315934732527</id><published>2009-07-09T08:03:00.000-07:00</published><updated>2009-07-09T08:04:06.897-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='BlackBerry'/><title type='text'>How To - Format the electronic serial number (ESN)</title><content type='html'>&lt;h3 class="pTitle_Section" id=""&gt;Details&lt;/h3&gt; &lt;p class="pBody"&gt;The following code can be used to format the ESN of a BlackBerry smartphone to match the format that is shown under &lt;b class="bB"&gt;Options &lt;/b&gt;&gt; &lt;b class="bB"&gt;Status &lt;/b&gt;on the BlackBerry smartphone.&lt;/p&gt; &lt;p class="Note"&gt;&lt;b&gt;Note: &lt;/b&gt;ESNs are only present on BlackBerry smartphones that operate on the Code Division Multiple Access (CDMA) network.&lt;/p&gt; &lt;p class="pCodeIndent"&gt;public String getDecimalSerialNumber()&lt;br /&gt;{&lt;br /&gt;    StringBuffer esnStringBuffer = new StringBuffer();&lt;br /&gt;&lt;br /&gt;    //Determine if the BlackBerry operates on the CDMA network.&lt;br /&gt;    if( RadioInfo.getNetworkType() == RadioInfo.NETWORK_CDMA )&lt;br /&gt;    {&lt;br /&gt;        //It does, so we'll format the ESN number.&lt;br /&gt;        int sn = CDMAInfo.getESN();&lt;br /&gt;        int firstPart = (sn &gt;&gt; 24) &amp;amp; 0xff;&lt;br /&gt;        int secondPart = sn &amp;amp; 0xffffff;&lt;br /&gt;&lt;br /&gt;        String firstPartString = String.valueOf( firstPart );&lt;br /&gt;        String secondPartString = String.valueOf( secondPart );&lt;br /&gt;        padESN( esnStringBuffer, 3 - firstPartString.length() );&lt;br /&gt;        esnStringBuffer.append( firstPartString );&lt;br /&gt;        padESN( esnStringBuffer, 8 - secondPartString.length() );&lt;br /&gt;        esnStringBuffer.append( secondPartString );&lt;br /&gt;           &lt;br /&gt;        return esnStringBuffer.toString();&lt;br /&gt;    }&lt;br /&gt;    else&lt;br /&gt;    {&lt;br /&gt;        //This BlackBerry does not operate on the CDMA network,&lt;br /&gt;        //return 0.&lt;br /&gt;        esnStringBuffer.append(0);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    return esnStringBuffer.toString();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//Inserts zeros into the ESN string.&lt;br /&gt;private void padESN(StringBuffer esnStringBuffer, int padCount)&lt;br /&gt;{&lt;br /&gt;    for (int i = 0; i &lt; padCount; ++i) {&lt;br /&gt;         esnStringBuffer.append('0');&lt;br /&gt;    }&lt;br /&gt;}&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-5874171315934732527?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/5874171315934732527/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=5874171315934732527' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/5874171315934732527'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/5874171315934732527'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/07/how-to-format-electronic-serial-number.html' title='How To - Format the electronic serial number (ESN)'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-7932397298997363420</id><published>2009-05-28T21:04:00.000-07:00</published><updated>2009-05-28T21:05:41.291-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='BlackBerry'/><title type='text'>How To - Define a rollover icon for an application</title><content type='html'>How To - Define a rollover icon for an application&lt;br /&gt;Last Updated: 14 November 2008&lt;br /&gt;Article Number: DB-00467&lt;br /&gt;Summary&lt;br /&gt;&lt;br /&gt;This article applies to the following:&lt;br /&gt;&lt;br /&gt;    * BlackBerry® smartphones based on Java® technology&lt;br /&gt;    * BlackBerry® Device Software 4.1 and later&lt;br /&gt;    * BlackBerry® Java® Development Environment (BlackBerry JDE) 4.1 and later&lt;br /&gt;&lt;br /&gt;Description&lt;br /&gt;BlackBerry JDE4.7 and later&lt;br /&gt;&lt;br /&gt;BlackBerry JDE 4.7 and BlackBerry JDE Component Package simplify the creation of a rollover icon. Rollover icons can now be specified in a project's properties.&lt;br /&gt;&lt;br /&gt;Specifying a rollover icon in BlackBerry JDE 4.7&lt;br /&gt;&lt;br /&gt;Complete the following steps:&lt;br /&gt;&lt;br /&gt;   1. In BlackBerry JDE, right-click the project.&lt;br /&gt;   2. Select Properties.&lt;br /&gt;   3. Select the Resources tab.&lt;br /&gt;   4. Add the non rollover/unfocused application icon in the Icon Files field and add the rollover/focused icon in the Focus Icon Files field.&lt;br /&gt;&lt;br /&gt;Specifying a rollover icon in BlackBerry JDE Plug-in for Eclipse&lt;br /&gt;&lt;br /&gt;Note: While this option is always present in the BlackBerry® JDE Plug-in for Eclipse™ it will only take effect when the application is built using the BlackBerry JDE Component Package 4.7.0 or later.&lt;br /&gt;&lt;br /&gt;Complete the following:&lt;br /&gt;&lt;br /&gt;   1. In the Eclipse™ Package Explorer, right-click the project.&lt;br /&gt;   2. Select Properties.&lt;br /&gt;   3. Select BlackBerry Project Properties.&lt;br /&gt;   4. Select the Resources tab.&lt;br /&gt;   5. Add the non-rollover/unfocused application icon in the Icon Files field and add the rollover/focused icon in the Focus Icon Files field.&lt;br /&gt;&lt;br /&gt;Before BlackBerry JDE 4.7&lt;br /&gt;&lt;br /&gt;A new application programming interface (API), introduced in the BlackBerry API 4.1 set, grants the ability to add a rollover icon to an application. To leverage this new API correctly, the application must run on startup so the call is executed, and can thus take effect before the BlackBerry smartphone user scrolls to the application. The application itself should not run on startup, but an alternate entry point to the application should be defined to do so. The main entry point should be configured to pass in an argument to the main() method so that the application can identify a startup launch from a BlackBerry smartphone user launching the application from the ribbon.&lt;br /&gt;&lt;br /&gt;The rollover icon application’s main() method will now resemble the following:&lt;br /&gt;&lt;br /&gt;public static void main(String[] args)&lt;br /&gt;{&lt;br /&gt;   if ( args != null &amp;amp;&amp;amp; args.length &gt; 0 &amp;amp;&amp;amp; args[0].equals("gui") ){&lt;br /&gt;      //main entry point&lt;br /&gt;      Test theApp = new Test();&lt;br /&gt;      theApp.enterEventDispatcher();&lt;br /&gt;   } else {&lt;br /&gt;      //alternate entry point&lt;br /&gt;      Bitmap icon = Bitmap.getBitmapResource("2.png");&lt;br /&gt;      HomeScreen.setRolloverIcon(icon);&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Due to an issue in BlackBerry Device Software 4.1, the HomeScreen.setRolloverIcon(Bitmap image)method can throw an IllegalArgumentException. This issue has been resolved in BlackBerry Device Software 4.2. The following code sample shows how to work around this issue:&lt;br /&gt;&lt;br /&gt;public class HomeScreenIcon extends UiApplication&lt;br /&gt;{&lt;br /&gt;    public static void main(String[] args)&lt;br /&gt;    {&lt;br /&gt;        //Check for the argument defined in the project properties.&lt;br /&gt;        if (args != null &amp;amp;&amp;amp; args.length &gt; 0 &amp;amp;&amp;amp; args[0].equals("gui"))&lt;br /&gt;        {&lt;br /&gt;           HomeScreenIcon theApp = new HomeScreenIcon(false);&lt;br /&gt;            theApp.enterEventDispatcher();&lt;br /&gt;        }&lt;br /&gt;        else&lt;br /&gt;        {&lt;br /&gt;            HomeScreenIcon theApp = new HomeScreenIcon(true);&lt;br /&gt;            theApp.enterEventDispatcher();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    public HomeScreenIcon(boolean autoStart)&lt;br /&gt;    {&lt;br /&gt;        if (autoStart)&lt;br /&gt;        {&lt;br /&gt;        //The application started using the auto start entry point.&lt;br /&gt;        //Setup the rollover icons.&lt;br /&gt;        final Bitmap regIcon = Bitmap.getBitmapResource("1.png");&lt;br /&gt;        final Bitmap icon = Bitmap.getBitmapResource("2.png");&lt;br /&gt;&lt;br /&gt;        invokeLater(new Runnable()&lt;br /&gt;        {&lt;br /&gt;            public void run()&lt;br /&gt;            {&lt;br /&gt;                ApplicationManager myApp =&lt;br /&gt;                  ApplicationManager.getApplicationManager();&lt;br /&gt;                boolean keepGoing = true;&lt;br /&gt;&lt;br /&gt;                while (keepGoing)&lt;br /&gt;                {&lt;br /&gt;                    //Check if the BlackBerry has completed its&lt;br /&gt;                        startup process.&lt;br /&gt;                    if (myApp.inStartup())&lt;br /&gt;                    {&lt;br /&gt;                        //The BlackBerry is still starting up,&lt;br /&gt;                             sleep for 1 second.&lt;br /&gt;                        try&lt;br /&gt;                        {&lt;br /&gt;                            Thread.sleep(1000);&lt;br /&gt;                        }&lt;br /&gt;                        catch (Exception ex)&lt;br /&gt;                        {&lt;br /&gt;                          //Couldn't sleep, handle exception.&lt;br /&gt;                        }&lt;br /&gt;                    }&lt;br /&gt;                    else&lt;br /&gt;                    {&lt;br /&gt;                        //The BlackBerry has finished its&lt;br /&gt;                             startup process.&lt;br /&gt;                        //Set the rollover icons.&lt;br /&gt;                        HomeScreen.updateIcon(regIcon, 0);&lt;br /&gt;                        HomeScreen.setRolloverIcon(icon, 0);&lt;br /&gt;                        keepGoing = false;&lt;br /&gt;                    }&lt;br /&gt;                 }&lt;br /&gt;                 //Exit the application.&lt;br /&gt;                 System.exit(0);&lt;br /&gt;            }&lt;br /&gt;        });&lt;br /&gt;            &lt;br /&gt;    }&lt;br /&gt;    else&lt;br /&gt;    {&lt;br /&gt;         //The application was started by the user.&lt;br /&gt;         //Start the application and display a GUI.&lt;br /&gt;         MainScreen ms = new MainScreen();&lt;br /&gt;         ms.setTitle(new LabelField("Hello there."));&lt;br /&gt;         pushScreen(ms);&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Note: After running on startup to define the rollover icon, the application exits so that it does not run needlessly in the background.&lt;br /&gt;Additional Information&lt;br /&gt;&lt;br /&gt;For more information, see DB-00008 regarding alternate entry point applications and DB-00126 on defining an application icon.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-7932397298997363420?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/7932397298997363420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=7932397298997363420' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/7932397298997363420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/7932397298997363420'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/05/how-to-define-rollover-icon-for.html' title='How To - Define a rollover icon for an application'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-8096437133250390610</id><published>2009-03-26T19:48:00.000-07:00</published><updated>2009-03-26T19:51:39.920-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technique'/><title type='text'>Upgrade existing Eclipse to 3.4.2</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Download the latest version 3.4.2 from eclipse site &lt;/span&gt;&lt;br /&gt;http://www.eclipse.org/downloads/&lt;br /&gt;http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/ganymede/SR2/eclipse-jee-ganymede-SR2-win32.zip&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Download Jboss or other plug-ins you want to install&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Extract new Eclipse version to the old eclipse folder&lt;/span&gt;&lt;br /&gt;Overwrite everything in the old folder&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Run eclipse&lt;/span&gt;&lt;br /&gt;first time should have error, no matter, just close the environment and run it again. Then should success.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-8096437133250390610?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/8096437133250390610/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=8096437133250390610' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/8096437133250390610'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/8096437133250390610'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/03/upgrade-existing-eclipse-to-342.html' title='Upgrade existing Eclipse to 3.4.2'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-9015649685373496608</id><published>2009-03-26T05:49:00.000-07:00</published><updated>2009-03-26T05:52:03.018-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technique'/><title type='text'>How to - Leverage pattern matching in BlackBerry smartphone applications to provide an integrated user experience</title><content type='html'>Summary&lt;br /&gt;&lt;br /&gt;This article applies to the following:&lt;br /&gt;&lt;br /&gt;    * BlackBerry® Device Software 4.0 and later&lt;br /&gt;    * BlackBerry smartphones&lt;br /&gt;&lt;br /&gt;Description&lt;br /&gt;Background&lt;br /&gt;&lt;br /&gt;You may have noticed how certain strings are underlined in native BlackBerry smartphone applications. For example, phone numbers are underlined or highlighted when composing or reading messages. Once selected, these special strings are assigned a context-sensitive menu item, for example call a phone number. Third-party applications can take advantage of this functionality to add custom context-sensitive menu items to standard BlackBerry smartphone applications. These menu items can be used to launch a custom application, open the BlackBerry® Browser to a specific URL, send a message, or do any number of other things.&lt;br /&gt;&lt;br /&gt;This functionality can be achieved by using one of two application programming interfaces (APIs):&lt;br /&gt;&lt;br /&gt;   1. net.rim.device.api.util.StringPattern - This API was introduced in BlackBerry Device Software 4.0 and requires you to implement your own string matching algorithm.&lt;br /&gt;   2. net.rim.blackberry.api.stringpattern.PatternRepository - This API was introduced in BlackBerry Device Software 4.3.0, and allows the use of Perl style regular expressions.&lt;br /&gt;&lt;br /&gt;The samples provided in this article match a United States zip code and allow the BlackBerry smartphone user to lookup more information on the zip code.&lt;br /&gt;Procedure&lt;br /&gt;net.rim.device.api.util.StringPattern&lt;br /&gt;&lt;br /&gt;The StringPattern source code example uses the string pattern matching that was introduced in BlackBerry Device Software 4.0. It requires implementing another string matching algorithm.&lt;br /&gt;&lt;br /&gt;There are four major components required for this implementation&lt;br /&gt;&lt;br /&gt;net.rim.device.api.util.StringPattern - This class represents the pattern that you want to recognize. It can be as simple as a zip code, or as complex as an address in its various forms. To write an effective StringPattern, remember that each character typed into the applicable field will be parsed by your implementation. As such, efficiency is important in this class.&lt;br /&gt;&lt;br /&gt;net.rim.device.api.ui.component.MenuItem - The MenuItem includes the majority of the implementation for this capability. The MenuItem typically includes or references the action that will occur once a match is found and invoked by the BlackBerry smartphone user. For example, the run method for the MenuItem is invoked when a zip code has been recognized and the BlackBerry smartphone user selects the Lookup Zipcode menu item.&lt;br /&gt;&lt;br /&gt;net.rim.device.api.ui.component.ActiveFieldCookie - The ActiveFieldCookie is a container object that allows the StringPattern class to transfer the context-sensitive information to the MenuItem. It also allows the implementation to add the appropriate menu item, or multiple menu items, when a string pattern match is found.&lt;br /&gt;&lt;br /&gt;net.rim.device.api.util.Factory - The implementation of the Factory class links the StringPattern to the ActiveFieldCookie when a match is recorded in the StringPattern implementation. Typically, the Factory implementation is quite compact but a necessary requirement for the system.&lt;br /&gt;&lt;br /&gt;The ZipCodeLookupSample class provides the starting point for the application. The application is configured as an auto-start system module so that all of the components can be registered upon start up. It is important to note that the main class initializes all of the required components described above, and has been implemented carefully to only initialize these components once.&lt;br /&gt;net.rim.blackberry.api.stringpattern.PatternRepository&lt;br /&gt;&lt;br /&gt;The PatternRepository source code sample uses the API that was introduced in BlackBerry Device Software 4.3.0 and allows the use of regular expressions for string matching, which makes the sample much simpler than the prior sample.&lt;br /&gt;&lt;br /&gt;There are two major components required for this implementation&lt;br /&gt;&lt;br /&gt;net.rim.blackberry.api.stringpattern.PatternRepository - This class will register a Perl-style regular expression or a specific string with the systems pattern repository. When a match is found the ApplicationMenuItem(s) associated with the pattern will appear in the current application's menu.&lt;br /&gt;&lt;br /&gt;net.rim.blackberry.api.menuitem.ApplicationMenuItem- The ApplicationMenuItem includes the action that will occur once a match is found and is invoked by the BlackBerry smartphone user.&lt;br /&gt;&lt;br /&gt;The application is once again configured as an auto-start system module. This is done to register the regular expression and menu item with the systems pattern repository upon system start up.&lt;br /&gt;&lt;br /&gt;To access the sample code, download the attached ZipCodeLookupSamples.zip file.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-9015649685373496608?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/9015649685373496608/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=9015649685373496608' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/9015649685373496608'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/9015649685373496608'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/03/how-to-leverage-pattern-matching-in.html' title='How to - Leverage pattern matching in BlackBerry smartphone applications to provide an integrated user experience'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-8016976051501855832</id><published>2009-03-24T10:22:00.001-07:00</published><updated>2009-03-24T10:22:51.302-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technique'/><title type='text'>Integer (computer science)</title><content type='html'>&lt;h1 id="firstHeading" class="firstHeading"&gt;Integer (computer science)&lt;/h1&gt;       &lt;h3 id="siteSub"&gt;From Wikipedia, the free encyclopedia&lt;/h3&gt;              &lt;div id="jump-to-nav"&gt;Jump to: &lt;a href="http://en.wikipedia.org/w/index.php?title=Integer_%28computer_science%29&amp;amp;printable=yes#column-one"&gt;navigation&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/w/index.php?title=Integer_%28computer_science%29&amp;amp;printable=yes#searchInput"&gt;search&lt;/a&gt;&lt;/div&gt;   &lt;!-- start content --&gt;    &lt;table class="metadata plainlinks ambox ambox-content" style=""&gt; &lt;tbody&gt;&lt;tr&gt; &lt;td class="mbox-image"&gt; &lt;div style="width: 52px;"&gt;&lt;a href="http://en.wikipedia.org/wiki/File:Question_book-new.svg" class="image" title="Question book-new.svg"&gt;&lt;img alt="" src="http://upload.wikimedia.org/wikipedia/en/thumb/9/99/Question_book-new.svg/50px-Question_book-new.svg.png" border="0" width="50" height="39" /&gt;&lt;/a&gt;&lt;/div&gt; &lt;/td&gt; &lt;td class="mbox-text" style=""&gt;This article &lt;b&gt;needs additional &lt;a href="http://en.wikipedia.org/wiki/Wikipedia:Citing_sources" title="Wikipedia:Citing sources"&gt;citations&lt;/a&gt; for &lt;a href="http://en.wikipedia.org/wiki/Wikipedia:Verifiability" title="Wikipedia:Verifiability"&gt;verification&lt;/a&gt;.&lt;/b&gt; Please help &lt;a href="http://en.wikipedia.org/w/index.php?title=Integer_%28computer_science%29&amp;amp;action=edit" class="external text" title="http://en.wikipedia.org/w/index.php?title=Integer_(computer_science)&amp;amp;action=edit" rel="nofollow"&gt;improve this article&lt;/a&gt; by adding &lt;a href="http://en.wikipedia.org/wiki/Wikipedia:Reliable_sources" title="Wikipedia:Reliable sources"&gt;reliable references&lt;/a&gt; (ideally, using &lt;i&gt;&lt;a href="http://en.wikipedia.org/wiki/Wikipedia:Footnotes" title="Wikipedia:Footnotes"&gt;inline citations&lt;/a&gt;&lt;/i&gt;). Unsourced material may be &lt;a href="http://en.wikipedia.org/wiki/Template:Fact" title="Template:Fact"&gt;challenged&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Wikipedia:BURDEN" title="Wikipedia:BURDEN" class="mw-redirect"&gt;removed&lt;/a&gt;. &lt;small&gt;&lt;i&gt;(January 2008)&lt;/i&gt;&lt;/small&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;In computer science, the term &lt;b&gt;integer&lt;/b&gt; is used to refer to a &lt;a href="http://en.wikipedia.org/wiki/Data_type" title="Data type"&gt;data type&lt;/a&gt; which represents some finite subset of the mathematical &lt;a href="http://en.wikipedia.org/wiki/Integer" title="Integer"&gt;integers&lt;/a&gt;. These are also known as &lt;b&gt;integral data types&lt;/b&gt;.&lt;/p&gt; &lt;table id="toc" class="toc" summary="Contents"&gt; &lt;tbody&gt;&lt;tr&gt; &lt;td&gt; &lt;div id="toctitle"&gt; &lt;h2&gt;Contents&lt;/h2&gt;  &lt;span class="toctoggle"&gt;[&lt;a href="javascript:toggleToc()" class="internal" id="togglelink"&gt;hide&lt;/a&gt;]&lt;/span&gt;&lt;/div&gt; &lt;ul&gt;&lt;li class="toclevel-1"&gt;&lt;a href="http://en.wikipedia.org/w/index.php?title=Integer_%28computer_science%29&amp;amp;printable=yes#Value_and_representation"&gt;&lt;span class="tocnumber"&gt;1&lt;/span&gt; &lt;span class="toctext"&gt;Value and representation&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li class="toclevel-1"&gt;&lt;a href="http://en.wikipedia.org/w/index.php?title=Integer_%28computer_science%29&amp;amp;printable=yes#Common_integral_data_types"&gt;&lt;span class="tocnumber"&gt;2&lt;/span&gt; &lt;span class="toctext"&gt;Common integral data types&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li class="toclevel-1"&gt;&lt;a href="http://en.wikipedia.org/w/index.php?title=Integer_%28computer_science%29&amp;amp;printable=yes#Bytes_and_octets"&gt;&lt;span class="tocnumber"&gt;3&lt;/span&gt; &lt;span class="toctext"&gt;Bytes and octets&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li class="toclevel-1"&gt;&lt;a href="http://en.wikipedia.org/w/index.php?title=Integer_%28computer_science%29&amp;amp;printable=yes#Words"&gt;&lt;span class="tocnumber"&gt;4&lt;/span&gt; &lt;span class="toctext"&gt;Words&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li class="toclevel-1"&gt;&lt;a href="http://en.wikipedia.org/w/index.php?title=Integer_%28computer_science%29&amp;amp;printable=yes#See_also"&gt;&lt;span class="tocnumber"&gt;5&lt;/span&gt; &lt;span class="toctext"&gt;See also&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li class="toclevel-1"&gt;&lt;a href="http://en.wikipedia.org/w/index.php?title=Integer_%28computer_science%29&amp;amp;printable=yes#Notes"&gt;&lt;span class="tocnumber"&gt;6&lt;/span&gt; &lt;span class="toctext"&gt;Notes&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;script type="text/javascript"&gt; //&lt;![CDATA[  if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); }  //]]&gt; &lt;/script&gt; &lt;p&gt;&lt;a name="Value_and_representation" id="Value_and_representation"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;&lt;span class="editsection"&gt;[&lt;a href="http://en.wikipedia.org/w/index.php?title=Integer_%28computer_science%29&amp;amp;action=edit&amp;amp;section=1" title="Edit section: Value and representation"&gt;edit&lt;/a&gt;]&lt;/span&gt; &lt;span class="mw-headline"&gt;Value and representation&lt;/span&gt;&lt;/h2&gt; &lt;p&gt;The &lt;i&gt;value&lt;/i&gt; of a &lt;a href="http://en.wikipedia.org/wiki/Data" title="Data"&gt;datum&lt;/a&gt; with an integral type is the mathematical integer that it corresponds to. The &lt;i&gt;representation&lt;/i&gt; of this datum is the way the value is stored in the computer’s memory. Integral types may be &lt;i&gt;unsigned&lt;/i&gt; (capable of representing only non-negative integers) or &lt;i&gt;signed&lt;/i&gt; (capable of representing negative integers as well).&lt;/p&gt; &lt;p&gt;The most common representation of a positive integer is a string of &lt;a href="http://en.wikipedia.org/wiki/Bit" title="Bit"&gt;bits&lt;/a&gt;, using the &lt;a href="http://en.wikipedia.org/wiki/Binary_numeral_system" title="Binary numeral system"&gt;binary numeral system&lt;/a&gt;. The order of the bits varies; see &lt;a href="http://en.wikipedia.org/wiki/Endianness" title="Endianness"&gt;endianness&lt;/a&gt;. The &lt;i&gt;width&lt;/i&gt; or &lt;i&gt;precision&lt;/i&gt; of an integral type is the number of bits in its representation. An integral type with &lt;i&gt;n&lt;/i&gt; bits can encode 2&lt;sup&gt;&lt;i&gt;n&lt;/i&gt;&lt;/sup&gt; numbers; for example an unsigned type typically represents the non-negative values 0 through 2&lt;sup&gt;&lt;i&gt;n&lt;/i&gt;&lt;/sup&gt;−1.&lt;/p&gt; &lt;p&gt;There are three different ways to represent negative numbers in a binary numeral system. The most common is &lt;a href="http://en.wikipedia.org/wiki/Two%27s_complement" title="Two's complement"&gt;two’s complement&lt;/a&gt;, which allows a signed integral type with &lt;i&gt;n&lt;/i&gt; bits to represent numbers from −2&lt;sup&gt;(n−1)&lt;/sup&gt; through 2&lt;sup&gt;(n−1)&lt;/sup&gt;−1. Two’s complement arithmetic is convenient because there is a perfect &lt;a href="http://en.wikipedia.org/wiki/Bijection" title="Bijection"&gt;one-to-one correspondence&lt;/a&gt; between representations and values, and because &lt;a href="http://en.wikipedia.org/wiki/Addition" title="Addition"&gt;addition&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Subtraction" title="Subtraction"&gt;subtraction&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Multiplication" title="Multiplication"&gt;multiplication&lt;/a&gt; do not need to distinguish between signed and unsigned types. The other possibilities are sign-magnitude and ones' complement. See &lt;a href="http://en.wikipedia.org/wiki/Signed_number_representations" title="Signed number representations"&gt;Signed number representations&lt;/a&gt; for details.&lt;/p&gt; &lt;p&gt;Another, rather different, representation for integers is &lt;a href="http://en.wikipedia.org/wiki/Binary-coded_decimal" title="Binary-coded decimal"&gt;binary-coded decimal&lt;/a&gt;, which is still commonly used in &lt;a href="http://en.wikipedia.org/wiki/Mainframe_computer" title="Mainframe computer"&gt;mainframe&lt;/a&gt; financial applications and in databases.&lt;/p&gt; &lt;p&gt;&lt;a name="Common_integral_data_types" id="Common_integral_data_types"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;&lt;span class="editsection"&gt;[&lt;a href="http://en.wikipedia.org/w/index.php?title=Integer_%28computer_science%29&amp;amp;action=edit&amp;amp;section=2" title="Edit section: Common integral data types"&gt;edit&lt;/a&gt;]&lt;/span&gt; &lt;span class="mw-headline"&gt;Common integral data types&lt;/span&gt;&lt;/h2&gt; &lt;table class="wikitable"&gt; &lt;tbody&gt;&lt;tr&gt; &lt;th&gt;Bits&lt;/th&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Range&lt;/th&gt; &lt;th&gt;Decimal digits&lt;/th&gt; &lt;th&gt;Uses&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;8&lt;/td&gt; &lt;td rowspan="2"&gt;&lt;a href="http://en.wikipedia.org/wiki/Byte" title="Byte"&gt;byte&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Octet_%28computing%29" title="Octet (computing)"&gt;octet&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;i&gt;Signed:&lt;/i&gt; −128 to +&lt;a href="http://en.wikipedia.org/wiki/127_%28number%29" title="127 (number)"&gt;127&lt;/a&gt;&lt;/td&gt; &lt;td&gt;3&lt;/td&gt; &lt;td rowspan="2"&gt;&lt;a href="http://en.wikipedia.org/wiki/ASCII" title="ASCII"&gt;ASCII&lt;/a&gt; characters, &lt;a href="http://en.wikipedia.org/wiki/C_%28programming_language%29" title="C (programming language)"&gt;C&lt;/a&gt;/C++ char, C/C++ int8_t, Java byte, C# byte&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;i&gt;Unsigned:&lt;/i&gt; 0 to +255&lt;/td&gt; &lt;td&gt;3&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;16&lt;/td&gt; &lt;td rowspan="2"&gt;halfword, &lt;a href="http://en.wikipedia.org/wiki/Word_%28computing%29" title="Word (computing)"&gt;word&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;i&gt;Signed:&lt;/i&gt; −32,768 to +&lt;a href="http://en.wikipedia.org/wiki/32767_%28number%29" title="32767 (number)" class="mw-redirect"&gt;32,767&lt;/a&gt;&lt;/td&gt; &lt;td&gt;5&lt;/td&gt; &lt;td rowspan="2"&gt;&lt;a href="http://en.wikipedia.org/wiki/UCS-2" title="UCS-2" class="mw-redirect"&gt;UCS-2&lt;/a&gt; characters, C/C++ short, C/C++ int16_t, Java short, C# short, Java char&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;i&gt;Unsigned:&lt;/i&gt; 0 to +65,535&lt;/td&gt; &lt;td&gt;5&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;32&lt;/td&gt; &lt;td rowspan="2"&gt;word, long, doubleword, longword&lt;/td&gt; &lt;td&gt;&lt;i&gt;Signed:&lt;/i&gt; −2,147,483,648 to +2,147,483,647&lt;/td&gt; &lt;td&gt;10&lt;/td&gt; &lt;td rowspan="2"&gt;&lt;a href="http://en.wikipedia.org/wiki/UCS-4" title="UCS-4" class="mw-redirect"&gt;UCS-4&lt;/a&gt; characters, &lt;a href="http://en.wikipedia.org/wiki/Truecolor" title="Truecolor"&gt;Truecolor&lt;/a&gt; with alpha, C/C++ long (on Windows and 32-bit Unix), C/C++ int32_t, Java int, C# int, &lt;a href="http://en.wikipedia.org/wiki/FourCC" title="FourCC"&gt;FourCC&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;i&gt;Unsigned:&lt;/i&gt; 0 to +4,294,967,295&lt;/td&gt; &lt;td&gt;10&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;64&lt;/td&gt; &lt;td rowspan="2"&gt;doubleword, longword, long long, quad, quadword&lt;/td&gt; &lt;td&gt;&lt;i&gt;Signed:&lt;/i&gt; −9,223,372,036,854,775,808 to +9,223,372,036,854,775,807&lt;/td&gt; &lt;td&gt;19&lt;/td&gt; &lt;td rowspan="2"&gt;C/C++ long (on 64-bit Unix), C/C++ long long, C/C++ int64_t, Java long, C# long&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;i&gt;Unsigned:&lt;/i&gt; 0 to +18,446,744,073,709,551,615&lt;/td&gt; &lt;td&gt;20&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;128&lt;/td&gt; &lt;td rowspan="2"&gt;octaword&lt;/td&gt; &lt;td&gt;&lt;i&gt;Signed:&lt;/i&gt; −170,141,183,460,469,231,731,687,303,715,884,105,728 to +170,141,183,460,469,231,731,687,303,715,884,105,727&lt;/td&gt; &lt;td&gt;39&lt;/td&gt; &lt;td rowspan="2"&gt;C only available as non-standard compiler-specific extension&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;i&gt;Unsigned:&lt;/i&gt; 0 to +340,282,366,920,938,463,463,374,607,431,768,211,455&lt;/td&gt; &lt;td&gt;39&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;&lt;i&gt;n&lt;/i&gt;&lt;/td&gt; &lt;td rowspan="2"&gt;&lt;i&gt;n&lt;/i&gt;-bit integer&lt;br /&gt;(general case)&lt;/td&gt; &lt;td&gt;&lt;i&gt;Signed:&lt;/i&gt; &lt;span class="texhtml"&gt;( − 2&lt;sup&gt;&lt;i&gt;n&lt;/i&gt; − 1&lt;/sup&gt;)&lt;/span&gt; to &lt;span class="texhtml"&gt;(2&lt;sup&gt;&lt;i&gt;n&lt;/i&gt; − 1&lt;/sup&gt; − 1)&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;img class="tex" alt="\lceil (n-1) \log_{10}{2} \rceil" src="http://upload.wikimedia.org/math/3/f/e/3fe07e2bc38cbca2becd8d3374287730.png" /&gt;&lt;/td&gt; &lt;td&gt;&lt;a href="http://en.wikipedia.org/wiki/Ada_%28programming_language%29" title="Ada (programming language)"&gt;Ada&lt;/a&gt; &lt;code&gt;range 2**(n-1) .. 2**n;&lt;/code&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;i&gt;Unsigned:&lt;/i&gt; 0 to &lt;span class="texhtml"&gt;(2&lt;sup&gt;&lt;i&gt;n&lt;/i&gt;&lt;/sup&gt; − 1)&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;img class="tex" alt="\lceil n \log_{10}{2} \rceil" src="http://upload.wikimedia.org/math/6/8/f/68f7b9359c8ae074dbfefe3577f6f64f.png" /&gt;&lt;/td&gt; &lt;td&gt;Ada &lt;code&gt;mod 2**n;&lt;/code&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;Different &lt;a href="http://en.wikipedia.org/wiki/Central_processing_unit" title="Central processing unit"&gt;CPUs&lt;/a&gt; support different integral data types. Typically, hardware will support both signed and unsigned types but only a small, fixed set of widths.&lt;/p&gt; &lt;p&gt;The table above lists integral type widths that are supported in hardware by common processors. High level programming languages provide more possibilities. It is common to have a ‘double width’ integral type that has twice as many bits as the biggest hardware-supported type. Many languages also have &lt;i&gt;bit-field&lt;/i&gt; types (a specified number of bits, usually constrained to be less than the maximum hardware-supported width) and &lt;i&gt;range&lt;/i&gt; types (which can represent only the integers in a specified range).&lt;/p&gt; &lt;p&gt;Some languages, such as &lt;a href="http://en.wikipedia.org/wiki/Lisp_programming_language" title="Lisp programming language" class="mw-redirect"&gt;Lisp&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/REXX" title="REXX"&gt;REXX&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Haskell_%28programming_language%29" title="Haskell (programming language)"&gt;Haskell&lt;/a&gt;, support &lt;i&gt;arbitrary precision&lt;/i&gt; integers (also known as &lt;i&gt;infinite precision integers&lt;/i&gt; or &lt;i&gt;&lt;a href="http://en.wikipedia.org/wiki/Bignum" title="Bignum" class="mw-redirect"&gt;bignums&lt;/a&gt;&lt;/i&gt;). Other languages which do not support this concept as a top-level construct may have libraries available to represent very large numbers using arrays of smaller variables, such as Java's &lt;code&gt;&lt;a href="http://en.wikipedia.org/w/index.php?title=BigInteger&amp;amp;action=edit&amp;amp;redlink=1" class="new" title="BigInteger (page does not exist)"&gt;BigInteger&lt;/a&gt;&lt;/code&gt; class or &lt;a href="http://en.wikipedia.org/wiki/Perl" title="Perl"&gt;Perl&lt;/a&gt;'s "&lt;code&gt;bigint&lt;/code&gt;" package. These use as much of the computer’s memory as is necessary to store the numbers; however, a computer has only a finite amount of storage, so they too can only represent a finite subset of the mathematical integers. These schemes support very large numbers, for example one kilobyte of memory could be used to store numbers up to 2466 digits long.&lt;/p&gt; &lt;p&gt;A &lt;a href="http://en.wikipedia.org/wiki/Boolean_datatype" title="Boolean datatype"&gt;Boolean&lt;/a&gt; or &lt;a href="http://en.wikipedia.org/wiki/Flag_%28computing%29" title="Flag (computing)"&gt;Flag&lt;/a&gt; type is a type which can represent only two values: 0 and 1, usually identified with &lt;i&gt;false&lt;/i&gt; and &lt;i&gt;true&lt;/i&gt; respectively. This type can be stored in memory using a single bit, but is often given a full byte for convenience of addressing and speed of access.&lt;/p&gt; &lt;p&gt;A four-bit quantity is known as a &lt;i&gt;&lt;a href="http://en.wikipedia.org/wiki/Nibble" title="Nibble"&gt;nibble&lt;/a&gt;&lt;/i&gt; (when eating, being smaller than a &lt;i&gt;bite&lt;/i&gt;) or &lt;i&gt;nybble&lt;/i&gt; (being a pun on the form of the word &lt;i&gt;byte&lt;/i&gt;). One nibble corresponds to one digit in &lt;a href="http://en.wikipedia.org/wiki/Hexadecimal" title="Hexadecimal"&gt;hexadecimal&lt;/a&gt; and holds one digit or a sign code in binary-coded decimal.&lt;/p&gt; &lt;p&gt;&lt;a name="Bytes_and_octets" id="Bytes_and_octets"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;&lt;span class="editsection"&gt;[&lt;a href="http://en.wikipedia.org/w/index.php?title=Integer_%28computer_science%29&amp;amp;action=edit&amp;amp;section=3" title="Edit section: Bytes and octets"&gt;edit&lt;/a&gt;]&lt;/span&gt; &lt;span class="mw-headline"&gt;Bytes and octets&lt;/span&gt;&lt;/h2&gt; &lt;div class="rellink noprint relarticle mainarticle" style="font-style: italic; padding-left: 2em;"&gt;Main article: &lt;a href="http://en.wikipedia.org/wiki/Byte" title="Byte"&gt;Byte&lt;/a&gt;&lt;/div&gt; &lt;p&gt;The term &lt;i&gt;byte&lt;/i&gt; initially meant ‘the smallest addressable unit of memory’. In the past, 5-, 6-, 7-, 8-, and 9-bit bytes have all been used. There have also been computers that could address individual bits (‘bit-addressed machine’), or that could only address 16- or 32-bit quantities (‘word-addressed machine’). The term &lt;i&gt;byte&lt;/i&gt; was usually not used at all in connection with bit- and word-addressed machines.&lt;/p&gt; &lt;p&gt;The term &lt;i&gt;octet&lt;/i&gt; always refers to an 8-bit quantity. It is mostly used in the field of &lt;a href="http://en.wikipedia.org/wiki/Computer_network" title="Computer network"&gt;computer networking&lt;/a&gt;, where computers with different byte widths might have to communicate.&lt;/p&gt; &lt;p&gt;In modern usage &lt;i&gt;byte&lt;/i&gt; almost invariably means eight bits, since all other sizes have fallen into disuse; thus &lt;i&gt;byte&lt;/i&gt; has come to be synonymous with &lt;i&gt;octet&lt;/i&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name="Words" id="Words"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;&lt;span class="editsection"&gt;[&lt;a href="http://en.wikipedia.org/w/index.php?title=Integer_%28computer_science%29&amp;amp;action=edit&amp;amp;section=4" title="Edit section: Words"&gt;edit&lt;/a&gt;]&lt;/span&gt; &lt;span class="mw-headline"&gt;Words&lt;/span&gt;&lt;/h2&gt; &lt;div class="rellink noprint relarticle mainarticle" style="font-style: italic; padding-left: 2em;"&gt;Main article: &lt;a href="http://en.wikipedia.org/wiki/Word_%28computing%29" title="Word (computing)"&gt;Word (computing)&lt;/a&gt;&lt;/div&gt; &lt;p&gt;The term &lt;i&gt;word&lt;/i&gt; is used for a small group of bits which are handled simultaneously by processors of a particular &lt;a href="http://en.wikipedia.org/wiki/Computer_architecture" title="Computer architecture"&gt;architecture&lt;/a&gt;. The size of a word is thus CPU-specific. Many different word sizes have been used, including 6-, 8-, 12-, 16-, 18-, 24-, 32-, 36-, 39-, 48-, 60-, and 64-bit. Since it is architectural, the size of a &lt;i&gt;word&lt;/i&gt; is usually set by the first CPU in a family, rather than the characteristics of a later compatible CPU. The meanings of terms derived from &lt;i&gt;word&lt;/i&gt;, such as &lt;i&gt;longword&lt;/i&gt;, &lt;i&gt;doubleword&lt;/i&gt;, &lt;i&gt;quadword&lt;/i&gt;, and &lt;i&gt;halfword&lt;/i&gt;, also vary with the CPU and OS.&lt;/p&gt; &lt;p&gt;As of 2008 practically all new desktop processors are of the &lt;a href="http://en.wikipedia.org/wiki/X86-64" title="X86-64"&gt;x86-64&lt;/a&gt; family and capable of using 64-bit words, they are however often used in &lt;a href="http://en.wikipedia.org/wiki/X86#32-bit" title="X86"&gt;32-bit mode&lt;/a&gt;. &lt;a href="http://en.wikipedia.org/wiki/Embedded_system" title="Embedded system"&gt;Embedded processors&lt;/a&gt; with 8- and 16-bit word size are still common. The &lt;a href="http://en.wikipedia.org/wiki/36-bit_word_length" title="36-bit word length"&gt;36-bit word length&lt;/a&gt; was common in the early days of computers.&lt;/p&gt; &lt;p&gt;One important cause of non-portability of software is the incorrect assumption that all computers have the same word size as the computer used by the programmer. For example, if a programmer using the C language incorrectly declares as &lt;code&gt;int&lt;/code&gt; a variable that will be used to store values greater than &lt;span class="texhtml"&gt;2&lt;sup&gt;16&lt;/sup&gt; − 1&lt;/span&gt;, the program will fail on computers with 16-bit integers. That variable should have been declared as &lt;code&gt;long&lt;/code&gt;, which has at least 32 bits on any computer. Programmers may also incorrectly assume that a pointer can be converted to an integer without loss of information, which may work on (some) 32-bit computers, but fail on 64-bit computers with 64-bit pointers and 32-bit integers.&lt;/p&gt; &lt;p&gt;&lt;a name="See_also" id="See_also"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;&lt;span class="editsection"&gt;[&lt;a href="http://en.wikipedia.org/w/index.php?title=Integer_%28computer_science%29&amp;amp;action=edit&amp;amp;section=5" title="Edit section: See also"&gt;edit&lt;/a&gt;]&lt;/span&gt; &lt;span class="mw-headline"&gt;See also&lt;/span&gt;&lt;/h2&gt; &lt;ul&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Signed_number_representations" title="Signed number representations"&gt;Signed number representations&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Integer" title="Integer"&gt;Integer&lt;/a&gt; (the mathematical concept)&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name="Notes" id="Notes"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;&lt;span class="editsection"&gt;[&lt;a href="http://en.wikipedia.org/w/index.php?title=Integer_%28computer_science%29&amp;amp;action=edit&amp;amp;section=6" title="Edit section: Notes"&gt;edit&lt;/a&gt;]&lt;/span&gt; &lt;span class="mw-headline"&gt;Notes&lt;/span&gt;&lt;/h2&gt;    &lt;!--  NewPP limit report Preprocessor node count: 291/1000000 Post-expand include size: 4311/2048000 bytes Template argument size: 1484/2048000 bytes Expensive parser function count: 1/500 --&gt;  &lt;!-- Saved in parser cache with key enwiki:pcache:idhash:14794-0!1!0!default!!en!2 and timestamp 20090322134328 --&gt; &lt;div class="printfooter"&gt; Retrieved from "&lt;a href="http://en.wikipedia.org/wiki/Integer_%28computer_science%29"&gt;http://en.wikipedia.org/wiki/Integer_(computer_science)&lt;/a&gt;"&lt;/div&gt;    &lt;div id="catlinks" class="catlinks"&gt;&lt;div id="mw-normal-catlinks"&gt;&lt;a href="http://en.wikipedia.org/wiki/Special:Categories" title="Special:Categories"&gt;Categories&lt;/a&gt;: &lt;span dir="ltr"&gt;&lt;a href="http://en.wikipedia.org/wiki/Category:Data_types" title="Category:Data types"&gt;Data types&lt;/a&gt;&lt;/span&gt; | &lt;span dir="ltr"&gt;&lt;a href="http://en.wikipedia.org/wiki/Category:Computer_arithmetic" title="Category:Computer arithmetic"&gt;Computer arithmetic&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div id="mw-hidden-catlinks" class="mw-hidden-cats-hidden"&gt;Hidden categories: &lt;span dir="ltr"&gt;&lt;a href="http://en.wikipedia.org/wiki/Category:Articles_needing_additional_references_from_January_2008" title="Category:Articles needing additional references from January 2008"&gt;Articles needing additional references from January 2008&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-8016976051501855832?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/8016976051501855832/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=8016976051501855832' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/8016976051501855832'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/8016976051501855832'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/03/integer-computer-science.html' title='Integer (computer science)'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-2144105644409136261</id><published>2009-03-18T07:52:00.000-07:00</published><updated>2009-03-18T07:53:01.819-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technique'/><title type='text'>Media types supported on the BlackBerry smartphone</title><content type='html'>&lt;div&gt;&lt;h1&gt;Media types supported on the BlackBerry smartphone&lt;/h1&gt;&lt;hr class="section"&gt;&lt;div class="DocInformation"&gt;&lt;strong&gt;Doc ID : &lt;/strong&gt;KB05482&lt;br /&gt;&lt;strong&gt;Last Modified : &lt;/strong&gt;01-20-2009&lt;br /&gt;&lt;strong&gt;Document Type : &lt;/strong&gt;Support&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="screen"&gt;&lt;a href="javascript:window.print()"&gt;&lt;img src="http://www.blackberry.com/btsc/articles/resources/printicon.gif" border="0" /&gt;&lt;img src="http://www.blackberry.com/btsc/img/sp.gif" border="0" width="5" /&gt;Print this page &lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;h2&gt;Environment&lt;/h2&gt;&lt;content&gt; &lt;ul&gt;&lt;li&gt;BlackBerry® smartphones &lt;/li&gt;&lt;/ul&gt;  &lt;/content&gt;&lt;br /&gt;&lt;hr class="section"&gt;&lt;br /&gt;&lt;h2&gt;Overview&lt;/h2&gt;&lt;content&gt; &lt;p&gt;In the Media application on the BlackBerry smartphone, you can open media files such as videos, ring tones, pictures, and songs that are stored in the BlackBerry smartphone memory or on a media card.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; For instructions on how to transcode audio and video files for the Media application, see &lt;a href="http://www.blackberry.com/btsc/KB05419" target="_blank"&gt;KB05419&lt;/a&gt;.&lt;/p&gt; &lt;hr /&gt;  &lt;p&gt;The following tables list what codecs are recommended and supported for each specific file format for video and audio on the different BlackBerry smartphones, as well as whether Real Time Streaming Protocol (RTSP) streaming is supported using that file format.&lt;/p&gt; &lt;p&gt;&lt;span class="subHeading"&gt;BlackBerry® Storm™ 9500 smartphone and BlackBerry® Storm™ 9530 smartphone&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;span class="subHeading"&gt;Supported formats&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt; &lt;table class="borders" style="width: 90%; border-collapse: collapse;"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="Header"&gt;File Format / Extension&lt;/td&gt; &lt;td class="Header"&gt;Component&lt;/td&gt; &lt;td class="Header"&gt;Codec&lt;/td&gt; &lt;td class="Header"&gt;Notes&lt;/td&gt; &lt;td class="Header"&gt;RTSP Streaming&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="6"&gt; &lt;p&gt;MP4&lt;br /&gt;&lt;br /&gt;M4A&lt;br /&gt;&lt;br /&gt;3GP&lt;br /&gt;&lt;br /&gt;3GP2&lt;/p&gt;&lt;/td&gt; &lt;td rowspan="3"&gt;Video&lt;/td&gt; &lt;td class="noBorder"&gt;H.264&lt;/td&gt; &lt;td&gt;Baseline Profile, 480x360 pixels, up to 2 Mbps, 30 frames per second&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;MPEG4&lt;/td&gt; &lt;td&gt;Simple Profile Level 3, 480x360 pixels, up to 2 Mbps, 30 frames per second&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;H.263&lt;/td&gt; &lt;td&gt;Profile 0 and 3, Level 30&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="3"&gt;Audio&lt;/td&gt; &lt;td&gt;AAC-LC, AAC+, eAAC+&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;AMR-NB&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;QCELP EVRC&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;AVI&lt;/td&gt; &lt;td&gt;Video&lt;/td&gt; &lt;td&gt;MPEG4&lt;/td&gt; &lt;td&gt;Simple Profile Level 3, 480x360 pixels, up to 2 Mbps, 30 frames per second&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Audio&lt;/td&gt; &lt;td&gt;MP3&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="3"&gt; &lt;p&gt;ASF&lt;br /&gt;&lt;br /&gt;WMV&lt;br /&gt;&lt;br /&gt;WMA&lt;/p&gt;&lt;/td&gt; &lt;td&gt;Video&lt;/td&gt; &lt;td&gt;Windows® Media Video 9&lt;/td&gt; &lt;td&gt;WMV3, Simple Profile, 480x360 pixels, 30 frames per second&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;Audio&lt;/td&gt; &lt;td&gt;Windows Media Audio 9&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Windows Media 10 Standard/Professional&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;MP3&lt;/td&gt; &lt;td&gt;Audio&lt;/td&gt; &lt;td&gt;MP3&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span class="subHeading"&gt;Recommended video format for local playback&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt; &lt;table class="borders" style="width: 90%; border-collapse: collapse;"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="Header"&gt;File Format / Extension&lt;/td&gt; &lt;td class="Header"&gt;Component&lt;/td&gt; &lt;td class="Header"&gt;Codec&lt;/td&gt; &lt;td class="Header"&gt;Notes&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;MP4&lt;/td&gt; &lt;td&gt;Video&lt;/td&gt; &lt;td&gt;H.264&lt;/td&gt; &lt;td&gt;Baseline Profile, 480x360 pixels, up to 2 Mbps, 30 frames per second&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Audio&lt;/td&gt; &lt;td&gt;AAC-LC&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;  &lt;h3&gt; &lt;/h3&gt;&lt;h3&gt;BlackBerry® Curve™ 8900 smartphone&lt;/h3&gt; &lt;p&gt;&lt;strong&gt;&lt;span class="subHeading"&gt;Supported formats&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt; &lt;table class="borders" style="width: 90%; border-collapse: collapse;"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="Header"&gt;File Format / Extension&lt;/td&gt; &lt;td class="Header"&gt;Component&lt;/td&gt; &lt;td class="Header"&gt;Codec&lt;/td&gt; &lt;td class="Header"&gt;Notes&lt;/td&gt; &lt;td class="Header"&gt;RTSP Streaming&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="5"&gt;MP4&lt;br /&gt;&lt;br /&gt;M4A&lt;br /&gt;&lt;br /&gt;MOV&lt;br /&gt;&lt;br /&gt;3GP&lt;/td&gt; &lt;td rowspan="3"&gt;Video&lt;/td&gt; &lt;td&gt;H.264&lt;/td&gt; &lt;td&gt;Baseline Profile, 480x360 pixels, up to 1500 kbps, 24 frames per second&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;MPEG4&lt;/td&gt; &lt;td&gt;Simple and Advance Simple Profile, 480x360 pixels, up to 1500 kbps, 24 frames per second&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;H.263&lt;/td&gt; &lt;td&gt;Profile 0 and 3, Level 45&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;Audio&lt;/td&gt; &lt;td&gt;AAC-LC, AAC+, eAAC+&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;AMR-NB&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;AVI&lt;/td&gt; &lt;td&gt;Video&lt;/td&gt; &lt;td&gt;MPEG4&lt;/td&gt; &lt;td&gt;Simple and Advance Simple Profile, 480x360 pixels, up to 1500 kbps, 24 frames per second&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Audio&lt;/td&gt; &lt;td&gt;MP3&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="3"&gt;ASF&lt;br /&gt;&lt;br /&gt;WMV&lt;br /&gt;&lt;br /&gt;WMA&lt;/td&gt; &lt;td&gt;Video&lt;/td&gt; &lt;td&gt;Windows Media Video 9&lt;/td&gt; &lt;td&gt;WMV3, Simple and Main Profile, 480x360 pixels, 24 frames per second&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;Audio&lt;/td&gt; &lt;td&gt;Windows Media Audio 9 Standard/Professional&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Windows Media 10 Standard/Professional&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;MP3&lt;/td&gt; &lt;td&gt;Audio&lt;/td&gt; &lt;td&gt;MP3&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span class="subHeading"&gt;Recommended video format for local playback&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt; &lt;table class="borders" style="width: 90%; border-collapse: collapse;"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="Header"&gt;File Format / Extension&lt;/td&gt; &lt;td class="Header"&gt;Component&lt;/td&gt; &lt;td class="Header"&gt;Codec&lt;/td&gt; &lt;td class="Header"&gt;Notes&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;MP4&lt;/td&gt; &lt;td&gt;Video&lt;/td&gt; &lt;td&gt;MPEG4&lt;/td&gt; &lt;td&gt;Advance Simple Profile, 480x360 pixels, up to 1500 kbps, 24 frames per second&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Audio&lt;/td&gt; &lt;td&gt;AAC-LC&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;  &lt;h3&gt;BlackBerry® Bold™ 9000 smartphone&lt;/h3&gt; &lt;p&gt;&lt;strong&gt;&lt;span class="subHeading"&gt;Supported formats&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt; &lt;table class="borders" style="width: 90%; border-collapse: collapse;"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="Header"&gt;File Format / Extension&lt;/td&gt; &lt;td class="Header"&gt;Component&lt;/td&gt; &lt;td class="Header"&gt;Codec&lt;/td&gt; &lt;td class="Header"&gt;Notes&lt;/td&gt; &lt;td class="Header"&gt;RTSP Streaming&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="5"&gt;MP4&lt;br /&gt;&lt;br /&gt;M4A&lt;br /&gt;&lt;br /&gt;MOV&lt;br /&gt;&lt;br /&gt;3GP&lt;/td&gt; &lt;td rowspan="3"&gt;Video&lt;/td&gt; &lt;td&gt;H.264&lt;/td&gt; &lt;td&gt;Baseline Profile, 480x320 pixels, up to 1500 kbps, 24 frames per second&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;MPEG4&lt;/td&gt; &lt;td&gt;Simple and Advance Simple Profile, 480x320 pixels, up to 1500 kbps, 24 frames per second&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;H.263&lt;/td&gt; &lt;td&gt;Profile 0 and 3, Level 45&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;Audio&lt;/td&gt; &lt;td&gt;AAC-LC, AAC+, eAAC+&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;AMR-NB&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;AVI&lt;/td&gt; &lt;td&gt;Video&lt;/td&gt; &lt;td&gt;MPEG4&lt;/td&gt; &lt;td&gt;Simple and Advance Simple Profile, 480x320 pixels, up to 1500 kbps, 24 frames per second&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Audio&lt;/td&gt; &lt;td&gt;MP3&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="3"&gt;ASF&lt;br /&gt;&lt;br /&gt;WMV&lt;br /&gt;&lt;br /&gt;WMA&lt;/td&gt; &lt;td&gt;Video&lt;/td&gt; &lt;td&gt;Windows Media Video 9&lt;/td&gt; &lt;td&gt;WMV3, Simple and Main Profile, 480x320 pixels, 24 frames per second&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;Audio&lt;/td&gt; &lt;td&gt;Windows Media Audio 9 Standard/Professional&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Windows Media 10 Standard/Professional&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;MP3&lt;/td&gt; &lt;td&gt;Audio&lt;/td&gt; &lt;td&gt;MP3&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span class="subHeading"&gt;Recommended video format for local playback&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt; &lt;table class="borders" style="width: 90%; border-collapse: collapse;"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="Header"&gt;File Format / Extension&lt;/td&gt; &lt;td class="Header"&gt;Component&lt;/td&gt; &lt;td class="Header"&gt;Codec&lt;/td&gt; &lt;td class="Header"&gt;Notes&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;MP4&lt;/td&gt; &lt;td&gt;Video&lt;/td&gt; &lt;td&gt;MPEG4&lt;/td&gt; &lt;td&gt;Advance Simple Profile, 480x320 pixels, up to 1500 kbps, 24 frames per second&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Audio&lt;/td&gt; &lt;td&gt;AAC-LC&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;  &lt;h3&gt;BlackBerry® Pearl™ 8100, BlackBerry® Pearl™ 8110, BlackBerry® Pearl™ 8120, and BlackBerry® Pearl™ 8220 smartphones (Global System for Mobile communications (GSM®), General Packet Radio Service (GPRS), and Enhanced Data Rates for Global Evolution (EDGE) networks)&lt;/h3&gt; &lt;p&gt;&lt;strong&gt;&lt;span class="subHeading"&gt;Supported formats&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt; &lt;table class="borders" style="width: 90%; border-collapse: collapse;"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="Header"&gt;File Format / Extension&lt;/td&gt; &lt;td class="Header"&gt;Component&lt;/td&gt; &lt;td class="Header"&gt;Codec&lt;/td&gt; &lt;td class="Header"&gt;Notes&lt;/td&gt; &lt;td class="Header"&gt;RTSP Streaming&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="4"&gt;MP4&lt;br /&gt;&lt;br /&gt;M4A&lt;br /&gt;&lt;br /&gt;MOV&lt;br /&gt;&lt;br /&gt;3GP&lt;/td&gt; &lt;td rowspan="2"&gt;Video&lt;/td&gt; &lt;td&gt;MPEG4&lt;/td&gt; &lt;td&gt;Simple Profile, 240x320 pixels, up to 768 kbps, 24 frames per second&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;H.263&lt;/td&gt; &lt;td&gt;Profile 0 and 3, Level 45&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;Audio&lt;/td&gt; &lt;td&gt;AAC-LC, AAC+, eAAC+&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;AMR-NB&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;AVI&lt;/td&gt; &lt;td&gt;Video&lt;/td&gt; &lt;td&gt;MPEG4&lt;/td&gt; &lt;td&gt;Simple and Advance Simple Profile, 240x320 pixels, up to 768 kbps, 24 frames per second&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Audio&lt;/td&gt; &lt;td&gt;MP3&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="3"&gt;ASF&lt;br /&gt;&lt;br /&gt;WMV&lt;br /&gt;&lt;br /&gt;WMA&lt;/td&gt; &lt;td&gt;Video&lt;/td&gt; &lt;td&gt;Windows Media Video 9&lt;/td&gt; &lt;td&gt;WMV3, Simple Profile, 240x320 pixels, 24 frames per second&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;Audio&lt;/td&gt; &lt;td&gt;Windows Media Audio 9 Standard/Professional&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Windows Media 10 Standard/Professional&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;MP3&lt;/td&gt; &lt;td&gt;Audio&lt;/td&gt; &lt;td&gt;MP3&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Recommended video format for local playback (BlackBerry® Device Software 4.5)&lt;/strong&gt;&lt;/p&gt; &lt;table class="borders" style="width: 90%; border-collapse: collapse;"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="Header"&gt;File Format / Extension&lt;/td&gt; &lt;td class="Header"&gt;Component&lt;/td&gt; &lt;td class="Header"&gt;Codec&lt;/td&gt; &lt;td class="Header"&gt;Notes&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;MP4&lt;/td&gt; &lt;td&gt;Video&lt;/td&gt; &lt;td&gt;MPEG4&lt;/td&gt; &lt;td&gt;Simple Profile, 240x320 pixels, up to 768 kbps, 24 frames per second&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Audio&lt;/td&gt; &lt;td&gt;AAC-LC&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Recommended video format for local playback (BlackBerry Device Software 4.2 and 4.3)&lt;/strong&gt;&lt;/p&gt; &lt;table class="borders" style="width: 90%; border-collapse: collapse;"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="Header"&gt;File Format / Extension&lt;/td&gt; &lt;td class="Header"&gt;Component&lt;/td&gt; &lt;td class="Header"&gt;Codec&lt;/td&gt; &lt;td class="Header"&gt;Notes&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;AVI&lt;/td&gt; &lt;td&gt;Video&lt;/td&gt; &lt;td&gt;MPEG4&lt;/td&gt; &lt;td&gt;Simple Profile, 240x320 pixels, up to 768 kbps, 24 frames per second&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Audio&lt;/td&gt; &lt;td&gt;MP3&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;  &lt;h3&gt;BlackBerry® Curve™ 8300, BlackBerry® Curve™ 8310, BlackBerry® Curve™ 8320, and BlackBerry® Curve™ 8350i smartphones, and BlackBerry® 8800 and BlackBerry® 8820 smartphones (GSM/GPRS/EDGE networks)&lt;/h3&gt; &lt;p&gt;&lt;strong&gt;Supported formats&lt;/strong&gt;&lt;/p&gt; &lt;table class="borders" style="width: 90%; border-collapse: collapse;"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="Header"&gt;File Format / Extension&lt;/td&gt; &lt;td class="Header"&gt;Component&lt;/td&gt; &lt;td class="Header"&gt;Codec&lt;/td&gt; &lt;td class="Header"&gt;Notes&lt;/td&gt; &lt;td class="Header"&gt;RTSP Streaming&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="4"&gt; &lt;p&gt;MP4&lt;br /&gt;&lt;br /&gt;M4A&lt;br /&gt;&lt;br /&gt;MOV&lt;br /&gt;&lt;br /&gt;3GP&lt;/p&gt;&lt;/td&gt; &lt;td rowspan="2"&gt;Video&lt;/td&gt; &lt;td&gt;MPEG4&lt;/td&gt; &lt;td&gt;Simple Profile, 320x240 pixels, up to 768 kbps, 24 frames per second&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;H.263&lt;/td&gt; &lt;td&gt;Profile 0 and 3, Level 45&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;Audio&lt;/td&gt; &lt;td&gt;AAC-LC, AAC+, eAAC+&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;AMR-NB&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt; &lt;p&gt;AVI&lt;/p&gt;&lt;/td&gt; &lt;td&gt;Video&lt;/td&gt; &lt;td&gt;MPEG4&lt;/td&gt; &lt;td&gt;Simple and Advance Simple Profile, 320x240 pixels, up to 768 kbps, 24 frames per second&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Audio&lt;/td&gt; &lt;td&gt;MP3&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="3"&gt; &lt;p&gt;ASF&lt;br /&gt;&lt;br /&gt;WMV&lt;br /&gt;&lt;br /&gt;WMA&lt;/p&gt;&lt;/td&gt; &lt;td&gt;Video&lt;/td&gt; &lt;td&gt;Windows Media Video 9&lt;/td&gt; &lt;td&gt;WMV3, Simple Profile, 320x240 pixels, 24 frames per second&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;Audio&lt;/td&gt; &lt;td&gt;Windows Media Audio 9 Standard/Professional&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Windows Media 10 Standard/Professional&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;p&gt;MP3&lt;/p&gt;&lt;/td&gt; &lt;td&gt;Audio&lt;/td&gt; &lt;td&gt;MP3&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Recommended video format for local playback (BlackBerry Device Software 4.5)&lt;/strong&gt;&lt;/p&gt; &lt;table class="borders" style="width: 90%; border-collapse: collapse;"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="Header"&gt;File Format / Extension&lt;/td&gt; &lt;td class="Header"&gt;Component&lt;/td&gt; &lt;td class="Header"&gt;Codec&lt;/td&gt; &lt;td class="Header"&gt;Notes&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt; &lt;p&gt;MP4&lt;/p&gt;&lt;/td&gt; &lt;td&gt;Video&lt;/td&gt; &lt;td&gt;MPEG4&lt;/td&gt; &lt;td&gt;Simple Profile, 320x240 pixels, up to 768 kbps, 24 frames per second&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Audio&lt;/td&gt; &lt;td&gt;AAC-LC&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Recommended video format for local playback (BlackBerry Device Software 4.2 and 4.3)&lt;/strong&gt;&lt;/p&gt; &lt;table class="borders" style="width: 90%; border-collapse: collapse;"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="Header"&gt;File Format / Extension&lt;/td&gt; &lt;td class="Header"&gt;Component&lt;/td&gt; &lt;td class="Header"&gt;Codec&lt;/td&gt; &lt;td class="Header"&gt;Notes&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;AVI&lt;/td&gt; &lt;td&gt;Video&lt;/td&gt; &lt;td&gt;MPEG4&lt;/td&gt; &lt;td&gt;Simple Profile, 320x240 pixels, up to 768 kbps, 24 frames per second&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Audio&lt;/td&gt; &lt;td&gt;MP3&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;  &lt;h3&gt;BlackBerry® Pearl™ 8130 smartphone (Code Division Multiple Access (CDMA) network)&lt;/h3&gt; &lt;p&gt;&lt;strong&gt;Supported formats&lt;/strong&gt;&lt;/p&gt; &lt;table class="borders" style="width: 90%; border-collapse: collapse;"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="Header"&gt;File Format / Extension&lt;/td&gt; &lt;td class="Header"&gt;Component&lt;/td&gt; &lt;td class="Header"&gt;Codec&lt;/td&gt; &lt;td class="Header"&gt;Notes&lt;/td&gt; &lt;td class="Header"&gt;RTSP Streaming&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="4"&gt; &lt;p&gt;MP4&lt;br /&gt;&lt;br /&gt;3GP&lt;/p&gt;&lt;/td&gt; &lt;td rowspan="2"&gt;Video&lt;/td&gt; &lt;td&gt;MPEG4&lt;/td&gt; &lt;td&gt;Simple Profile, 240x320 pixels, up to 768 kbps, 24 frames per second&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;H.263&lt;/td&gt; &lt;td&gt;Profile 0 and 3, Level 45&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;Audio&lt;/td&gt; &lt;td&gt;AAC-LC, AAC+, eAAC+&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;AMR-NB&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="3"&gt; &lt;p&gt;ASF&lt;br /&gt;&lt;br /&gt;WMV&lt;br /&gt;&lt;br /&gt;WMA&lt;/p&gt;&lt;/td&gt; &lt;td&gt;Video&lt;/td&gt; &lt;td&gt;Windows Media Video 9&lt;/td&gt; &lt;td&gt;WMV3, Simple Profile, 240x320 pixels, 24 frames per second&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;Audio&lt;/td&gt; &lt;td&gt;Windows Media Audio 9 Standard/Professional&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Windows Media 10 Standard/Professional&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;p&gt;MP3&lt;/p&gt;&lt;/td&gt; &lt;td&gt;Audio&lt;/td&gt; &lt;td&gt;MP3&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Recommended video format for local playback&lt;/strong&gt;&lt;/p&gt; &lt;table class="borders" style="width: 90%; border-collapse: collapse;"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="Header"&gt;File Format / Extension&lt;/td&gt; &lt;td class="Header"&gt;Component&lt;/td&gt; &lt;td class="Header"&gt;Codec&lt;/td&gt; &lt;td class="Header"&gt;Notes&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt; &lt;p&gt;MP4&lt;/p&gt;&lt;/td&gt; &lt;td&gt;Video&lt;/td&gt; &lt;td&gt;MPEG4&lt;/td&gt; &lt;td&gt;Simple Profile, 240x320 pixels, up to 384 kbps, 24 frames per second&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Audio&lt;/td&gt; &lt;td&gt;AAC-LC&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;  &lt;h3&gt;BlackBerry® Curve™ 8330 smartphone and BlackBerry™ 8830 smartphone (CDMA network)&lt;/h3&gt; &lt;p&gt;&lt;strong&gt;Supported formats&lt;/strong&gt;&lt;/p&gt; &lt;table class="borders" style="width: 90%; border-collapse: collapse;"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="Header"&gt;File Format / Extension&lt;/td&gt; &lt;td class="Header"&gt;Component&lt;/td&gt; &lt;td class="Header"&gt;Codec&lt;/td&gt; &lt;td class="Header"&gt;Notes&lt;/td&gt; &lt;td class="Header"&gt;RTSP Streaming&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="4"&gt;MP4&lt;br /&gt;&lt;br /&gt;3GP&lt;/td&gt; &lt;td rowspan="2"&gt;Video&lt;/td&gt; &lt;td&gt;MPEG4&lt;/td&gt; &lt;td&gt;Simple Profile, 320x240 pixels, up to 768 kbps, 24 frames per second&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;H.263&lt;/td&gt; &lt;td&gt;Profile 0 and 3, Level 45&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;Audio&lt;/td&gt; &lt;td&gt;AAC-LC, AAC+, eAAC+&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;AMR-NB&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;Supported&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="3"&gt;ASF&lt;br /&gt;&lt;br /&gt;WMV&lt;br /&gt;&lt;br /&gt;WMA&lt;/td&gt; &lt;td&gt;Video&lt;/td&gt; &lt;td&gt;Windows Media Video 9&lt;/td&gt; &lt;td&gt;WMV3, Simple Profile, 320x240 pixels, 24 frames per second&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;Audio&lt;/td&gt; &lt;td&gt;Windows Media Audio 9 Standard/Professional&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Windows Media 10 Standard/Professional&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;MP3&lt;/td&gt; &lt;td&gt;Audio&lt;/td&gt; &lt;td&gt;MP3&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Recommended video format for local playback&lt;/strong&gt;&lt;/p&gt; &lt;table class="borders" style="width: 90%; border-collapse: collapse;"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="Header"&gt;File Format / Extension&lt;/td&gt; &lt;td class="Header"&gt;Component&lt;/td&gt; &lt;td class="Header"&gt;Codec&lt;/td&gt; &lt;td class="Header"&gt;Notes&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;MP4&lt;/td&gt; &lt;td&gt;Video&lt;/td&gt; &lt;td&gt;MPEG4&lt;/td&gt; &lt;td&gt;Simple Profile, 320x240 pixels, up to 768 kbps, 24 frames per second&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Audio&lt;/td&gt; &lt;td&gt;AAC-LC&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt; &lt;/content&gt;&lt;br /&gt;&lt;hr class="section"&gt;&lt;br /&gt;&lt;h2&gt;Additional Information&lt;/h2&gt;&lt;content&gt; &lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Streaming requires BlackBerry Device Software 4.3 or later.&lt;/p&gt;  &lt;/content&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-2144105644409136261?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/2144105644409136261/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=2144105644409136261' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/2144105644409136261'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/2144105644409136261'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/03/media-types-supported-on-blackberry.html' title='Media types supported on the BlackBerry smartphone'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-1723496893600624118</id><published>2009-03-16T15:01:00.000-07:00</published><updated>2009-03-16T15:02:20.480-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technique'/><title type='text'>Mobile Media API Overview</title><content type='html'>&lt;div id="sharepage" class="smallpagetitle"&gt;&lt;h1&gt;Mobile Media API Overview&lt;/h1&gt;&lt;div class="sharepage"&gt;  &lt;div class="sharepagew1 share-mailto"&gt;  &lt;table summary="layout" cellpadding="0" cellspacing="0"&gt;&lt;tbody&gt;&lt;tr&gt;  &lt;td id="share-mailto"&gt;&lt;br /&gt;&lt;/td&gt;  &lt;td id="share-technorati"&gt;&lt;br /&gt;&lt;/td&gt;  &lt;td id="share-delicious"&gt;&lt;br /&gt;&lt;/td&gt;  &lt;td id="share-digg"&gt;&lt;br /&gt;&lt;/td&gt;  &lt;td id="share-slashdot"&gt;&lt;br /&gt;&lt;/td&gt;  &lt;td id="share-blank"&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;!-- END PAGETITLE --&gt; &lt;!-- BEGIN WRAPPER TABLE, 2 COLUMN, MAIN/RIGHT --&gt;   &lt;!-- BEGIN CENTRAL COLUMN COMPONENTS --&gt; &lt;!--startindex--&gt; &lt;!-- ============ --&gt; &lt;!-- MAIN CONTENT --&gt; &lt;!-- ============ --&gt; &lt;a name="skip2content"&gt;&lt;/a&gt; &lt;!--  BEGIN VCD4 PFV  --&gt;&lt;!--  END VCD4 PFV --&gt; &lt;!-- ================== --&gt; &lt;!-- Start Main Content --&gt; &lt;!-- ================== --&gt;&lt;br /&gt;&lt;span class="byline"&gt; by Jonathan Knudsen&lt;br /&gt;June 2002 &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt; The Mobile Media API (MMAPI) provides a powerful, flexible, and simple interface to multimedia capabilities. It exposes a clean interface for playing and recording audio and video data. This article provides an overview of the concepts of the MMAPI and a quick tour of its classes and interfaces. &lt;/p&gt; &lt;!-- subhead --&gt; &lt;p&gt;&lt;b&gt;Mobile Media API Architecture&lt;/b&gt;&lt;/p&gt; &lt;p&gt; The Mobile Media API is based on four fundamental concepts: &lt;/p&gt; &lt;ol&gt;&lt;li&gt; A &lt;i&gt;player&lt;/i&gt; knows how to interpret media data. One type of player, for example, might know how to produce sound based on MP3 audio data. Another type of player might be capable of showing a QuickTime movie. Players are represented by implementations of the &lt;code&gt;javax.microedition.media.Player&lt;/code&gt; interface. &lt;/li&gt;&lt;li&gt; You can use one or more &lt;i&gt;controls&lt;/i&gt; to modify the behavior of a player. You can get the controls from a &lt;code&gt;Player&lt;/code&gt; instance and use them while the player is rendering data from media. For example, you can use a &lt;code&gt;VolumeControl&lt;/code&gt; to modify the volume of a sampled audio &lt;code&gt;Player&lt;/code&gt;. Controls are represented by implementations of the &lt;code&gt;javax.microedition.media.Control&lt;/code&gt; interface; specific control subinterfaces are in the &lt;code&gt;javax.microedition.media.control&lt;/code&gt; package. &lt;/li&gt;&lt;li&gt; A &lt;i&gt;data source&lt;/i&gt; knows how to get media data from its original location to a player. Media data can be stored in a variety of locations, from remote servers to resource files or RMS databases. Media data may be transported from its original location to the player using HTTP, a streaming protocol like RTP, or some other mechanism. &lt;code&gt;javax.microedition.media.protocol.DataSource&lt;/code&gt; is the abstract parent class for all data sources in the Mobile Media API. &lt;/li&gt;&lt;li&gt; Finally, a &lt;i&gt;manager&lt;/i&gt; ties everything together and serves as the entry point to the API. The &lt;code&gt;javax.microedition.media.Manager&lt;/code&gt; class contains static methods for obtaining &lt;code&gt;Player&lt;/code&gt;s or &lt;code&gt;DataSource&lt;/code&gt;s. &lt;/li&gt;&lt;/ol&gt; &lt;!-- subhead --&gt; &lt;p&gt;&lt;b&gt;Using the Mobile Media API&lt;/b&gt;&lt;/p&gt; &lt;p&gt; The simplest thing you can do with &lt;code&gt;Manager&lt;/code&gt; is play tones using the following method: &lt;/p&gt; &lt;blockquote&gt;&lt;pre&gt;public static void playTone(int note,&lt;br /&gt;int duration, int volume) throws MediaException&lt;br /&gt;&lt;/pre&gt;&lt;/blockquote&gt; &lt;p&gt; The duration is specified in milliseconds and the volume ranges from 0 (silent) to 100 (loud). The note is specified as a number, as in MIDI, where 60 is middle C and 69 is a 440 Hz A. The note can range from 0 to 127. The &lt;code&gt;playTone()&lt;/code&gt; method is appropriate for playing a single tone or a very short sequence. For longer monotonic sequences, you'll use the default tone player, which is capable of playing an entire sequence of tones. &lt;/p&gt; &lt;p&gt; The real magic of the Mobile Media API is exposed through &lt;code&gt;Manager&lt;/code&gt;'s &lt;code&gt;createPlayer()&lt;/code&gt; method. There are three different versions of this method as follows: &lt;/p&gt; &lt;blockquote&gt; &lt;!-- BEGIN VCD7 CODE SAMPLE COMPONENT  --&gt; &lt;table class="grey4" border="0" cellpadding="10" cellspacing="0" width="100%"&gt; &lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;public static Player createPlayer(String locator)&lt;br /&gt;throws IOException, MediaException&lt;br /&gt;public static Player createPlayer(DataSource source)&lt;br /&gt;throws IOException, MediaException&lt;br /&gt;public static Player createPlayer(InputStream stream, String type)&lt;br /&gt;throws IOException, MediaException&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;span class="sp20"&gt; &lt;/span&gt;&lt;br /&gt;&lt;!-- END VCD7 CODE SAMPLE COMPONENT  --&gt; &lt;/blockquote&gt; &lt;p&gt; The simplest way to obtain a &lt;code&gt;Player&lt;/code&gt; is to use the first version of &lt;code&gt;createPlayer()&lt;/code&gt; and just pass in a string that represents media data. For instance, you might specify an audio file on a web server: &lt;/p&gt; &lt;blockquote&gt;&lt;pre&gt;Player p = Manager.createPlayer("http://webserver/music.mp3");&lt;br /&gt;&lt;/pre&gt;&lt;/blockquote&gt; &lt;p&gt; The other &lt;code&gt;createPlayer()&lt;/code&gt; methods allow you to create a &lt;code&gt;Player&lt;/code&gt; from a &lt;code&gt;DataSource&lt;/code&gt; or an &lt;code&gt;InputStream&lt;/code&gt;, whatever you happen to have available. If you think about it, these three methods are really just three different ways of getting at the media data, the actual bits. An &lt;code&gt;InputStream&lt;/code&gt; is the simplest object, just a byte stream. The &lt;code&gt;DataSource&lt;/code&gt; is the next level up, an object that speaks a protocol to get access to media data. And passing a locator string is the ultimate shortcut: the MMAPI figures out which protocol to use and gets the media data to the &lt;code&gt;Player&lt;/code&gt;. &lt;/p&gt; &lt;!-- subhead --&gt; &lt;p&gt;&lt;b&gt;Using a &lt;code&gt;Player&lt;/code&gt;&lt;/b&gt;&lt;/p&gt; &lt;p&gt; Once you've successfully created a &lt;code&gt;Player&lt;/code&gt;, what do you do next? The simplest action is to begin playback with the &lt;code&gt;start()&lt;/code&gt; method. For anything beyond the rudiments, however, it helps to understand the life cycle of a &lt;code&gt;Player&lt;/code&gt;. This consists of four states. &lt;/p&gt; &lt;p&gt; When a &lt;code&gt;Player&lt;/code&gt; is first created, it is in the &lt;code&gt;UNREALIZED&lt;/code&gt; state. After a &lt;code&gt;Player&lt;/code&gt; has located its data, it is in the &lt;code&gt;REALIZED&lt;/code&gt; state. If a &lt;code&gt;Player&lt;/code&gt; is rendering an audio file from an HTTP connection to a server, for example, the &lt;code&gt;Player&lt;/code&gt; reaches &lt;code&gt;REALIZED&lt;/code&gt; after the HTTP request is sent to the server, the HTTP response is received, and the &lt;code&gt;DataSource&lt;/code&gt; is ready to begin retrieving audio data. The next state is &lt;code&gt;PREFETCHED&lt;/code&gt;, and is achieved when the &lt;code&gt;Player&lt;/code&gt; has read enough data to begin rendering. Finally, when the data is being rendered, the &lt;code&gt;Player&lt;/code&gt;'s state is &lt;code&gt;STARTED&lt;/code&gt;. &lt;/p&gt; &lt;p&gt; The &lt;code&gt;Player&lt;/code&gt; interface provides methods for state transitions, both forwards and backwards through the cycle described above. The reason is to provide the application with control over operations that might take a long time. You might, for example, want to push a &lt;code&gt;Player&lt;/code&gt; through the &lt;code&gt;REALIZED&lt;/code&gt; and &lt;code&gt;PREFETCHED&lt;/code&gt; states so that a sound can be played immediately in response to a user action. &lt;/p&gt; &lt;!-- subhead --&gt; &lt;p&gt;&lt;b&gt;The Mobile Media API in the Java Platform&lt;/b&gt;&lt;/p&gt; &lt;p&gt; Where exactly does the MMAPI fit in the Java 2 platform? The answer is just about anywhere. Although the MMAPI was designed with the contraints of the CLDC in mind, it will work just fine alongside either CLDC or CDC software stacks. As a matter of fact, the MMAPI can be implemented with J2SE as a lightweight alternative to the &lt;a href="http://java.sun.com/products/java-media/jmf/index.jsp" target="_blank"&gt; Java Media Framework&lt;/a&gt;. &lt;/p&gt; &lt;!-- subhead --&gt; &lt;p&gt;&lt;b&gt;What Media Types are Supported?&lt;/b&gt;&lt;/p&gt; &lt;p&gt; If you get a device that supports the Mobile Media API, what kinds of data can it play? What data transfer protocols are supported?  The Mobile Media API doesn't require any specific content types or protocols, but you can find out at runtime what is supported by calling &lt;code&gt;Manager&lt;/code&gt;'s &lt;code&gt;getSupportedContentTypes()&lt;/code&gt; and &lt;code&gt;getSupportedProtocols()&lt;/code&gt; methods. &lt;/p&gt; &lt;p&gt; What's the worst that can happen? If you ask &lt;code&gt;Manager&lt;/code&gt; to give you a &lt;code&gt;Player&lt;/code&gt; for a content type or protocol that is not supported, it will throw an exception. Your application should attempt to recover gracefully from such an exception, perhaps by using a different content type or displaying a polite message to the user. &lt;/p&gt; &lt;!-- subhead --&gt; &lt;p&gt;&lt;b&gt;Media in MIDP 2.0&lt;/b&gt;&lt;/p&gt; &lt;p&gt; The MIDP 2.0 specification includes a subset of the Mobile Media API. It is upwardly compatible with the full API. The MIDP 2.0 subset has the following characteristics: &lt;/p&gt; &lt;ul&gt;&lt;li&gt; Only audio playback (and possibly recording) is supported. No video-specific control interfaces are included. &lt;/li&gt;&lt;li&gt; Multiple players cannot be synchronized. &lt;/li&gt;&lt;li&gt; The &lt;code&gt;DataSource&lt;/code&gt; class and the rest of the &lt;code&gt;javax.microedition.media.protocol&lt;/code&gt; package are excluded; applications cannot provide their own protocol implementations. &lt;/li&gt;&lt;li&gt; The &lt;code&gt;Manager&lt;/code&gt; class is simplified. &lt;/li&gt;&lt;/ul&gt; &lt;p&gt; MIDP 2.0 requires support for tone generation and sampled &lt;i&gt;.wav&lt;/i&gt; audio playback. &lt;/p&gt; &lt;!-- subhead --&gt; &lt;p&gt;&lt;b&gt;Summary&lt;/b&gt;&lt;/p&gt; &lt;p&gt; The Mobile Media API provides a compact, flexible, and clean API for using multimedia capabilities from a Java application running on a mobile device. At the time of this writing, the Mobile Media API is finished with its public review in the &lt;a href="http://jcp.org/jsr/detail/135.jsp" target="_blank"&gt;Java Community Process&lt;/a&gt;; expect a reference implementation release in the summer of 2002. &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-1723496893600624118?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/1723496893600624118/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=1723496893600624118' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/1723496893600624118'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/1723496893600624118'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/03/mobile-media-api-overview.html' title='Mobile Media API Overview'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-9016938065119761688</id><published>2009-03-12T09:07:00.000-07:00</published><updated>2009-03-12T10:33:02.526-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technique'/><title type='text'>J2ME</title><content type='html'>&lt;p&gt; &lt;/p&gt;&lt;p&gt; &lt;b&gt;1. What is J2ME &lt;/b&gt; &lt;/p&gt; &lt;p&gt; Java 2 Micro Edition is a group of specifications and technologies that pertain to Java on small devices. The J2ME moniker  covers a wide range of devices, from pagers and mobile telephones through set-top boxes and car navigation systems. The J2ME  world is divided into configurations and profiles, specifications that describe a Java environment for a specific class of  device. &lt;/p&gt;&lt;p&gt;&lt;b&gt;2. What is J2ME WTK &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The J2ME Wireless Toolkit is a set of tools that provides developers with an emulation environment, documentation and  examples for developing Java applications for small devices. The J2ME WTK is based on the Connected Limited Device  Configuration (CLDC) and Mobile Information Device Profile (MIDP) reference implementations, and can be tightly integrated  with Forte for Java&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;6.  What is CDC &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The Connected Device Configuration (CDC) is a specification for a J2ME configuration. Conceptually, CDC deals with devices  with more memory and processing power than CLDC; it is for devices with an always-on network connection and a minimum of 2 MB  of memory available for the Java system.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;11.  What is cHTML &lt;/b&gt; &lt;/p&gt; &lt;p&gt; Compact HTML (cHTML) is a subset of HTML which is designed for small devices. The major features of HTML that are excluded  from cHTML are: JPEG image, Table, Image map, Multiple character fonts and styles, Background color and image, Frame and  Style sheet.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;12.  What is CLDC &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The Connected, Limited Device Configuration (CLDC) is a specification for a J2ME configuration. The CLDC is for devices with  less than 512 KB or RAM available for the Java system and an intermittent (limited) network connection. It specifies a  stripped-down Java virtual machine1 called the KVM as well as several APIs for fundamental application services. Three  packages are minimalist versions of the J2SE java.lang, java.io, and java.util packages. A fourth package,  javax.microedition.io, implements the Generic Connection Framework, a generalized API for making network connections.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;13.  What is configuration &lt;/b&gt; &lt;/p&gt; &lt;p&gt; In J2ME, a configuration defines the minimum Java runtime environment for a family of devices: the combination of a Java  virtual machine (either the standard J2SE virtual machine or a much more limited version called the CLDC VM) and a core set  of APIs. CDC and CLDC are configurations. See also profile, optional package. &lt;/p&gt;  &lt;script type="text/javascript"&gt;writeAds_bannerBottom("")&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;script&gt;window.google_render_ad();&lt;/script&gt;&lt;p&gt; &lt;b&gt;14.  What is CVM &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The Compact Virtual Machine (CVM) is an optimized Java virtual machine1 (JVM) that is used by the CDC.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;16.  What is EDGE &lt;/b&gt; &lt;/p&gt; &lt;p&gt; Enhanced Data GSM Environment (EDGE) is a new, faster version of GSM. EDGE is designed to support transfer rates up to  384Kbps and enable the delivery of video and other high-bandwidth applications. EDGE is the result of a joint effort between  TDMA operators, vendors and carriers and the GSM Alliance.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;20. What is Generic Connection Framework &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The Generic Connection Framework (GCF) makes it easy for wireless devices to make network connections. It is part of CLDC and  CDC and resides in the javax.microedition.io package.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;21. What is GPRS &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The General Packet Radio System (GPRS) is the next generation of GSM. It will be the basis of 3G networks in Europe and  elsewhere.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;22. What is GSM &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The Global System for Mobile Communications (GSM) is a wireless network system that is widely used in Europe, Asia, and  Australia. GSM is used at three different frequencies: GSM900 and GSM1800 are used in Europe, Asia, and Australia, while  GSM1900 is deployed in North America and other parts of the world.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;30.  What is 3GPP &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The 3rd Generation Partnership Project (3GPP) is a global collaboration between 6 partners: ARIB, CWTS, ETSI, T1, TTA, and  TTC. The group aims to develop a globally accepted 3rd-generation mobile system based on GSM.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;37. What is KJava &lt;/b&gt; &lt;/p&gt; &lt;p&gt; KJava is an outdated term for J2ME. It comes from an early package of Java software for PalmOS, released at the 2000 JavaOne  show. The classes for that release were packaged in the com.sun.kjava package.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;33. What is JCP &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The Java Community Process (JCP) an open organization of international Java developers and licensees who develop and revise  Java technology specifications, reference implementations, and technology compatibility kits through a formal process.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;34. What is JDBC for CDC/FP &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The JDBC Optional Package for CDC/Foundation Profile (JDBCOP for CDC/FP) is an API that enables mobile Java applications to  communicate with relational database servers using a subset of J2SE's Java Database Connectivity. This optional package is a  strict subset of JDBC 3.0 that excludes some of JDBC's advanced and server-oriented features, such as pooled connections and  array types. It's meant for use with the Foundation Profile or its supersets.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;35. What is JSR &lt;/b&gt; &lt;/p&gt; &lt;p&gt; Java Specification Request (JSR) is the actual description of proposed and final specifications for the Java platform. JSRs  are reviewed by the JCP and the public before a final release of a specification is made.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;38. What is kSOAP &lt;/b&gt; &lt;/p&gt; &lt;p&gt; kSOAP is a SOAP API suitable for the J2ME, based on kXML.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;39. What is kXML &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The kXML project provides a small footprint XML parser that can be used with J2ME.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;40. What is KVM &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The KVM is a compact Java virtual machine (JVM) that is designed for small devices. It supports a subset of the features of  the JVM. For example, the KVM does not support floating-point operations and object finalization. The CLDC specifies use of  the KVM. According to folklore, the 'K' in KVM stands for kilobyte, signifying that the KVM runs in kilobytes of memory as  opposed to megabytes.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;42. What is LCDUI &lt;/b&gt; &lt;/p&gt; &lt;p&gt; LCDUI is a shorthand way of referring to the MIDP user interface APIs, contained in the javax.microedition.lcdui package.  Strictly speaking, LCDUI stands for Liquid Crystal Display User Interface. It's a user interface toolkit for small device  screens which are commonly LCD screens. &lt;/p&gt;&lt;p&gt; &lt;b&gt;43. What is MExE &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The Mobile Execution Environment (MExE) is a specification created by the 3GPP which details an applicatio n environment for  next generation mobile devices. MExE consists of a variety of technologies including WAP, J2ME, CLDC and MIDP.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;44. What is MIDlet &lt;/b&gt; &lt;/p&gt; &lt;p&gt; A MIDlet is an application written for MIDP. MIDlet applications are subclasses of the javax.microedition.midlet.MIDlet class  that is defined by MIDP.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;45. What is MIDlet suite &lt;/b&gt; &lt;/p&gt; &lt;p&gt;  MIDlets are packaged and distributed as MIDlet suites. A MIDlet suite can contain one or more MIDlets. The MIDlet suite  consists of two files, an application descriptor file with a .jad extension and an archive file with a .jar file. The  descriptor lists the archive file name, the names and class names for each MIDlet in the suite, and other information. The  archive file contains the MIDlet classes and resource files.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;46. What is MIDP &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The Mobile Information Device Profile (MIDP) is a specification for a J2ME profile. It is layered on top of CLDC and adds  APIs for application life cycle, user interface, networking, and persistent storage.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;47. What is MIDP-NG &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The Next Generation MIDP specification is currently under development by the Java Community Process. Planned improvements  include XML parsing and cryptographic support.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;48. What is Mobitex &lt;/b&gt; &lt;/p&gt; &lt;p&gt; Mobitex is a packet-switched, narrowband PCS network, designed for wide-area wireless data communications. It was developed  in 1984 by Eritel, an Ericsson subsidiary, a nd there are now over 30 Mobitex networks in operation worldwide.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;50. What is MSC &lt;/b&gt; &lt;/p&gt; &lt;p&gt; A Mobile Switching Center (MSC) is a unit within a cellular phone network that automatically coordinates and switches calls  in a given cell. It monitors each caller's signal strength, and when a signal begins to fade, it hands off the call to  another MSC that's better positioned to manage the call.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;52. What is optional package &lt;/b&gt; &lt;/p&gt; &lt;p&gt; An optional package is a set of J2ME APIs providing services in a specific area, such as database access or multimedia.  Unlike a profile, it does not define a complete application environment, but rather is used in conjunction with a  configuration or a profile. It extends the runtime environment to support device capabilities that are not universal enough  to be defined as part of a profile or that need to be shared by different profiles. J2ME RMI and the Mobile Media RMI are  examples of optional packages.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;53. What is OTA &lt;/b&gt; &lt;/p&gt; &lt;p&gt; Over The Air (OTA) refers to any wireless networking technology.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;54. What is PCS &lt;/b&gt; &lt;/p&gt; &lt;p&gt; Personal Communications Service (PCS) is a suite of second-generation, digitally modulated mobile-communications interfaces  that includes TDMA, CDMA, and GSM. PCS serves as an umbrella term for second-generation wireless technologies operating in  the 1900MHz range&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;55. What is PDAP &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The Personal Digital Assistant Profile (PDAP) is a J2ME profile specification designed for small platforms such as PalmOS  devices. You can think of PDAs as being larger than mobile phones but smaller than set-top boxes. PDAP is built on top of  CLDC and will specify user interface and persistent storage APIs. PDAP is currently being developed using the Java Community  Process (JCP).&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;57. What is PDCP &lt;/b&gt; &lt;/p&gt; &lt;p&gt;  Parallel and Distributed Computing Practices (PDCP) are often used to describe computer systems that are spread over many  devices on a network (wired or wireless) where many nodes process data simultaneously.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;58. What is Personal Profile &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The Personal Profile is a J2ME profile specification. Layered on the Foundation Profile and CDC, the Personal Profile will be  the next generation of PersonalJava technology. The specification is currently in development under the Java Community  Process (JCP).&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;59. What is PersonalJava &lt;/b&gt; &lt;/p&gt; &lt;p&gt; PersonalJava is a Java environment based on the Java virtual machine1 (JVM) and a set of APIs similar to a JDK 1.1  environment. It includes the Touchable Look and Feel (also called Truffle), a graphic toolkit that is optimized for consumer  devices with a touch sensitive screen. PersonalJava will be included in J2ME in the upcoming Personal Profile, which is built  on CDC.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;60. What is PNG &lt;/b&gt; &lt;/p&gt; &lt;p&gt; Portable Network Graphics (PNG) is an image format offering lossless compression and storage flexibility. The MIDP  specification requires implementations to recognize certain types of PNG images.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;63. What is preverification &lt;/b&gt; &lt;/p&gt; &lt;p&gt; Due to memory and processing power available on a device, the verification process of classes are split into two processes.  The first process is the preverification which is off-device and done using the preverify tool. The second process is  verification which is done on-device.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;64. What is profile &lt;/b&gt; &lt;/p&gt; &lt;p&gt; A profile is a set of APIs added to a configuration to support specific uses of a mobile device. Along with its underlying  configuration, a profile defines a complete, and usually self-contained, general-purpose application environment. Profiles  often, but not always, define APIs for user interface and persistence; the MIDP profile, based on the CLDC configuration,  fits this pattern. Profiles may be supersets or subsets of other profiles; the Personal Basis Profile is a subset of the  Personal Profile and a superset of the Foundation Profile. See also configuration, optional package.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;67. What is PSTN &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The public service telephone network (PSTN) is the traditional, land-line based system for exchanging phone calls.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;68. What is RMI &lt;/b&gt; &lt;/p&gt; &lt;p&gt; Remote method invocation (RMI) is a feature of J2SE that enables Java objects running in one virtual machine to invoke  methods of Java objects running in another virtual machine, seamlessly.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;69. What is RMI OP &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The RMI Optional Package (RMI OP) is a subset of J2SE 1.3's RMI functionality used in CDC-based profiles that incorporate the  Foundation Profile, such as the Personal Basis Profile and the Personal Profile. The RMIOP cannot be used with CLDC-based  profiles because they lack object serialization and other important features found only in CDC-based profiles. RMIOP supports  most of the J2SE RMI functionality, including the Java Remote Method Protocol, marshalled objects, distributed garbage  collection, registry-based object lookup, and network class loading, but not HTTP tunneling or the Java 1.1 stub protocol.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;70. What is RMI Profile &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The RMI Profile is a J2ME profile specification designed to support Java's Remote Method Invocation (RMI) distributed object  system. Devices implementing the RMI Profile will be able to interoperate via RMI with other Java devices, including Java 2,  Standard Edition. The RMI Profile is based on the Foundation Profile, which in turn is based on CDC.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;71. What is RMS &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The Record Management System (RMS) is a simple record-oriented database that allows a MIDlet to persistently store  information and retrieve it later. Different MIDlets can also use the RMS to share data.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;73. What is SIM &lt;/b&gt; &lt;/p&gt; &lt;p&gt; A Subscriber Identity Module (SIM) is a stripped-down smart card containing information about the identity of a cell-phone  subscriber, and subscriber authentication and service information. Because the SIM uniquely identifies the subscriber and is  portable among handsets, the user can move it from one kind of phone to another, facilitating international roaming.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;74. What is SMS &lt;/b&gt; &lt;/p&gt; &lt;p&gt; Short Message Service (SMS) is a point-to-point service similar to paging for sending text messages of up to 160 characters  to mobile phones.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;75. What is SOAP &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The Simple Object Access Protocol (SOAP) is an XML- based protocol that allows objects of any type to communicated in a  distributed environment. SOAP is used in developing Web Services.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;77. What is T9 &lt;/b&gt; &lt;/p&gt; &lt;p&gt; T9 is a text input method for mobile phones and other small devices. It replaces the "multi-tap" input method by guessing the  word that you are trying to enter. T9 may be embedded in a device by the manufacturer. Note that even if the device supports  T9, the Java implementation may or may not use it. Check your documentation for details.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;79. What is Telematics &lt;/b&gt; &lt;/p&gt; &lt;p&gt; Telematics is a location-based service that routes event notification and control data over wireless networks to and from  mobile devices installed in automobiles. Telematics makes use of GPS technology to track vehicle latitude and longitude, and  displays maps in LED consoles mounted in dashboards. It connects to remote processing centers that turn provide server-side  Internet and voice services, as well as access to database resources.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;81. What is UDDI &lt;/b&gt; &lt;/p&gt; &lt;p&gt; Universal Description, Discovery, and Integration (UDDI) is an XML-based standard for describing, publishing, and finding Web  services. UDDI is a specification for a distributed registry of Web services.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;85. What is WAP &lt;/b&gt; &lt;/p&gt; &lt;p&gt;  Wireless Application Protocol (WAP) is a protocol for transmitting data between servers and clients (usually small wireless  devices like mobile phones). WAP is analogous to HTTP in the World Wide Web. Many mobile phones include WAP browser software  to allow users access to Internet WAP sites.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;86. What is WAP Gateway &lt;/b&gt; &lt;/p&gt; &lt;p&gt; A WAP Gateway acts as a bridge allowing WAP devices to communicate with other networks (namely the Internet).&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;87. What is W-CDMA &lt;/b&gt; &lt;/p&gt; &lt;p&gt; Wideband Code-Division Multiple Access (W-CDMA), also known as IMT-2000, is a 3rd generation wireless technology. Supports  speeds up to 384Kbps on a wide-area network, or 2Mbps locally.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;88. What is WDP &lt;/b&gt; &lt;/p&gt; &lt;p&gt; Wireless Datagram Protocol (WDP) works as the transport layer of WAP. WDP processes datagrams from upper layers to formats  required by different physical datapaths, bearers, that may be for example GSM SMS or CDMA Packet Data. WDP is adapted to the  bearers available in the device so upper layers don't need to care about the physical level.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;89. What is WMA &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The Wireless Messaging API (WMA) is a set of classes for sending and receiving Short Message Service messages. See also SMS.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;90. What is WML &lt;/b&gt; &lt;/p&gt; &lt;p&gt; The Wireless Markup Language (WML) is a simple language used to create applications for small wireless devices like mobile  phones. WML is analogous to HTML in the World Wide Web.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;91. What is WMLScript &lt;/b&gt; &lt;/p&gt; &lt;p&gt; WMLScript is a subset of the JavaScript scripting language designed as part of the WAP standard to provide a convenient  mechanism to access mobile phone's peripheral functions.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;92. What is WSP &lt;/b&gt; &lt;/p&gt; &lt;p&gt; Wireless Session Protocol (WSP) implements session services of WAP. Sessions can be connection-oriented and connectionless  and they may be suspended and resumed at will.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;93. What is WTLS &lt;/b&gt; &lt;/p&gt; &lt;p&gt; Wireless Transport Layer Security protocal (WTLS) does all cryptography oriented features of WAP. WTLS handles  encryption/decryption, user authentication and data integrity. WTLS is based on the fixed network Transport Layer Security  protocal (TLS), formerly known as Secure Sockets Layer (SSL).&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;95. What is WTP &lt;/b&gt; &lt;/p&gt; &lt;p&gt; Wireless Transaction Protocol (WTP) is WAP's transaction protocol that works between the session protocol WSP and security  protocol WTLS. WTP chops data packets into lower level datagrams and concatenates received datagrams into useful data. WTP  also keeps track of received and sent packets and does re-transmissions and acknowledgment sending when needed.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-9016938065119761688?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/9016938065119761688/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=9016938065119761688' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/9016938065119761688'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/9016938065119761688'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/03/j2me.html' title='J2ME'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-3992981296261872807</id><published>2009-03-09T15:11:00.000-07:00</published><updated>2009-03-09T15:12:05.872-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technique'/><title type='text'>C/C++ software memory corruption types:  There are two forms of Linux Memory accessible to the programmer:     1. User's virtual memory space in which</title><content type='html'>&lt;b&gt;&lt;big&gt;C/C++ software memory corruption types:&lt;/big&gt;&lt;/b&gt;                                    &lt;p&gt; There are two forms of Linux Memory accessible to the programmer:        &lt;/p&gt;       &lt;ol&gt;&lt;li&gt;User's virtual memory space in which application is run.         &lt;/li&gt;&lt;li&gt;Register memory.         &lt;/li&gt;&lt;/ol&gt;        &lt;p&gt; The most obvious memory errors result in a "Segmentation violation" message. This may alert the programmer to the location of the memory error when the program is run in gdb.  The following errors discussed are the not so obvious errors.       &lt;/p&gt;       &lt;p&gt; Memory errors:       &lt;/p&gt;       &lt;ul&gt;&lt;li&gt;Heap memory errors:           &lt;ul&gt;&lt;li&gt;Attempting to free memory already freed.             &lt;/li&gt;&lt;li&gt;Freeing memory that was not allocated.             &lt;/li&gt;&lt;li&gt;Attempting to write to memory already freed.             &lt;/li&gt;&lt;li&gt;Attempting to write to memory which was never allocated.             &lt;/li&gt;&lt;li&gt;Memory allocation error.              &lt;/li&gt;&lt;li&gt;Reading/writing to memory out of the bounds of a dynamically allocated array             &lt;/li&gt;&lt;/ul&gt;            &lt;p&gt;           &lt;/p&gt;         &lt;/li&gt;&lt;li&gt;stack (local variables) memory errors:           &lt;ul&gt;&lt;li&gt;Reading/writing to memory out of the bounds of a static array.     (array index overflow - index too large/underflow - negative index)             &lt;/li&gt;&lt;li&gt;Function pointer corruption: Invalid passing of function pointer and thus     a bad call to a function.             &lt;/li&gt;&lt;/ul&gt;          &lt;/li&gt;&lt;/ul&gt;        &lt;p&gt;       &lt;a name="MEMORYLEAKS"&gt;&lt;/a&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;table border="0" cellpadding="2" cellspacing="0" width="100%"&gt;          &lt;tbody&gt;           &lt;tr bgcolor="#ffcc33"&gt;             &lt;td&gt;&lt;b&gt;&lt;big&gt;Memory Leaks:&lt;/big&gt;&lt;/b&gt;&lt;/td&gt;           &lt;/tr&gt;          &lt;/tbody&gt;       &lt;/table&gt;        &lt;p&gt;       &lt;b&gt;Memory leak description:&lt;/b&gt; Memory is allocated but not released causing an application to  consume memory reducing the available memory for other applications and eventually causing the system to page virtual memory to the hard drive slowing the application or crashing the application when than the computer memory resource limits are reached. The system may stop working as these limits are approached.       &lt;/p&gt;       &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;p&gt;       &lt;b&gt;Many C library functions malloc's memory which MUST be freed:&lt;/b&gt; i.e.: strdup(),         &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt;           &lt;table bgcolor="#000000" border="1" cellpadding="4" cellspacing="1" width="100%"&gt;              &lt;tbody&gt;               &lt;tr bgcolor="#c0c0c0"&gt;                 &lt;td&gt;                 &lt;pre&gt;#include &lt;stdlib.h&gt;&lt;br /&gt;#include &lt;string.h&gt;&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;char *oldString = "Old String";&lt;br /&gt;char newStrig = strdup(oldString);&lt;br /&gt;if(newString == ENOMEM) ... // Fail!!!!&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;free(newString);&lt;br /&gt;&lt;/pre&gt;                 &lt;/td&gt;               &lt;/tr&gt;             &lt;/tbody&gt;           &lt;/table&gt;          &lt;/dd&gt;&lt;/dl&gt;  Note: You can NOT use the C++ delete call. The strdup() function is part of the C library and you must use free().       &lt;p&gt; Any routine which is supplied by the C libraries or ones written within an application which allocate memory must have the memory freed. Comments on this need should be included in the include file to make users of the function aware of their duties to free the memory and the  mechanism by which it is to be freed (free() or delete).       &lt;/p&gt;       &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;p&gt;       &lt;b&gt;Programmer must free() malloc()'ed memory:&lt;/b&gt;       &lt;/p&gt;       &lt;p&gt; Also for calloc(), malloc() and realloc();        &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt;           &lt;table bgcolor="#000000" border="1" cellpadding="4" cellspacing="1" width="100%"&gt;              &lt;tbody&gt;               &lt;tr bgcolor="#c0c0c0"&gt;                 &lt;td&gt;                 &lt;pre&gt;#include &lt;stdlib.h&gt;&lt;br /&gt;&lt;br /&gt;char *textString = malloc(128*sizeof(char));&lt;br /&gt;if(textString == ENOMEM) ... // Fail!!!!&lt;br /&gt;...&lt;br /&gt;free(textString);  // Don't free if allocation failed&lt;br /&gt;&lt;/pre&gt;                 &lt;/td&gt;               &lt;/tr&gt;             &lt;/tbody&gt;           &lt;/table&gt;          &lt;/dd&gt;&lt;/dl&gt;        &lt;p&gt; Check for memory allocation errors. Can't free it if it didn't get allocated.       &lt;/p&gt;       &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;p&gt;       &lt;b&gt;Programmer must &lt;tt&gt;delete&lt;/tt&gt; &lt;tt&gt;new&lt;/tt&gt;'ed memory:&lt;/b&gt;        &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt;           &lt;table bgcolor="#000000" border="1" cellpadding="4" cellspacing="1" width="100%"&gt;              &lt;tbody&gt;               &lt;tr bgcolor="#c0c0c0"&gt;                 &lt;td&gt;                 &lt;pre&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;ptr = new ClassTypeA;&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;delete ClassTypeA;&lt;br /&gt;&lt;/pre&gt;                 &lt;/td&gt;               &lt;/tr&gt;             &lt;/tbody&gt;           &lt;/table&gt;          &lt;/dd&gt;&lt;/dl&gt;   New/delete is preferred to malloc()/free() because it can initialize the  memory and it invokes the constructor for new objects. New/delete also point to the correct memory type.  Note on mixing source code containing new/delete and malloc()/free().  This is not a problem with the GNU C++ compiler but this is not guaranteed for all C++ compilers.       &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;p&gt;       &lt;b&gt;Inheritance, polymorphism and the wrong delete:&lt;/b&gt;        &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt;           &lt;table bgcolor="#000000" border="1" cellpadding="4" cellspacing="1" width="100%"&gt;              &lt;tbody&gt;               &lt;tr bgcolor="#c0c0c0"&gt;                 &lt;td&gt;                 &lt;pre&gt;BaseClass* obj_ptr = new DerivedClass;  // Allowed due to polymorphism.&lt;br /&gt;...&lt;br /&gt;delete obj_ptr;  // this will call the destructor ~Parent() and NOT ~Child()&lt;br /&gt;&lt;/pre&gt;                 &lt;/td&gt;               &lt;/tr&gt;             &lt;/tbody&gt;           &lt;/table&gt;          &lt;/dd&gt;&lt;/dl&gt;        &lt;p&gt; If you are counting on the destructor to delete memory allocated in the  constructor beware of this mistake as it will cause a memory leak. Use a virtual destructor to avoid this problem.  The ~BaseClass() destructor is called and then the destructor ~DerivedClass()  is chosen and called at run time because it is a virtual destructor. If it is not declared virtual then only the ~BaseClass() destructor is called leaving any allocated memory from the DerivedClass to persist and leak. This assumes that the DerivedClass has extra memory allocated above and beyond  that of the BaseClass which must be freed.       &lt;/p&gt;       &lt;p&gt; The same ill effect can be achieved with a C style cast to a class of less scope which will dumb down the destructor to that which may not execute all the freeing of the original class. A C++ style dynamic cast may prevent this error as it will recognize the loss of translation and not  allow the cast to take place resulting in a traceable crash rather a tough to find memory leak.       &lt;/p&gt;       &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;p&gt;       &lt;b&gt;Pointer re-assignment error leads to dangling pointer:&lt;/b&gt;       &lt;/p&gt;       &lt;p&gt; If the pointer is re-assigned a new value before being freed, it will lead to a "dangling pointer" and memory leak.       &lt;/p&gt;       &lt;p&gt; Example:       &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt;           &lt;table bgcolor="#000000" border="1" cellpadding="4" cellspacing="1" width="100%"&gt;              &lt;tbody&gt;               &lt;tr bgcolor="#c0c0c0"&gt;                 &lt;td&gt;                 &lt;pre&gt;char *a = malloc(128*sizeof(char));&lt;br /&gt;char *b = malloc(128*sizeof(char));&lt;br /&gt;b = a;&lt;br /&gt;free(a);&lt;br /&gt;free(b); // will not free the pointer to the original allocated memory.&lt;br /&gt;&lt;/pre&gt;                 &lt;/td&gt;               &lt;/tr&gt;             &lt;/tbody&gt;           &lt;/table&gt;          &lt;/dd&gt;&lt;/dl&gt;        &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;p&gt;       &lt;b&gt;Default copy constructor may not give correct results:&lt;/b&gt;       &lt;/p&gt;       &lt;p&gt; Memory allocated by copy constructors for pointer duplication.  Check in destructor and delete if necessary. Memory allocated in passing class by value which invokes copy constructor. Also beware, the default copy constructor may not give you the results you want especially when dealing with pointers as the default copy constructor has no  knowledge of how to copy the contents of what the pointer points to.  To prohibit the use of the default copy constructor define a null assignment operator.        &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt;           &lt;table bgcolor="#000000" border="1" cellpadding="4" cellspacing="1" width="100%"&gt;              &lt;tbody&gt;               &lt;tr bgcolor="#c0c0c0"&gt;                 &lt;td&gt;                 &lt;pre&gt;ClassA&amp;amp; operator=(const ClassA&amp;amp; right_hand_side);&lt;br /&gt;&lt;/pre&gt;                 &lt;/td&gt;               &lt;/tr&gt;             &lt;/tbody&gt;           &lt;/table&gt;          &lt;/dd&gt;&lt;/dl&gt;        &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;p&gt; Good practice: Use assert to check pointers before freeing or using:       &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt;           &lt;table bgcolor="#000000" border="1" cellpadding="4" cellspacing="1" width="100%"&gt;              &lt;tbody&gt;               &lt;tr bgcolor="#c0c0c0"&gt;                 &lt;td&gt;                 &lt;pre&gt;assert(ptr !=0)&lt;br /&gt;&lt;/pre&gt;                 &lt;/td&gt;               &lt;/tr&gt;             &lt;/tbody&gt;           &lt;/table&gt;          &lt;/dd&gt;&lt;/dl&gt;        &lt;p&gt;       &lt;a name="MEMORYCORRUPTION"&gt;&lt;/a&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;table border="0" cellpadding="2" cellspacing="0" width="100%"&gt;          &lt;tbody&gt;           &lt;tr bgcolor="#ffcc33"&gt;             &lt;td&gt;&lt;b&gt;&lt;big&gt;Memory Corruption:&lt;/big&gt;&lt;/b&gt;&lt;/td&gt;           &lt;/tr&gt;          &lt;/tbody&gt;       &lt;/table&gt;        &lt;p&gt;       &lt;b&gt;Memory Corruption:&lt;/b&gt;  Memory when altered without an explicit assignment due to the inadvertent and unexpected altering of data held in memory or the altering of a pointer to a specific place in memory.       &lt;/p&gt;       &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;p&gt;       &lt;b&gt;Buffer overflow:&lt;/b&gt;       &lt;/p&gt;       &lt;p&gt; Example 1:      &lt;br /&gt; Overwrite beyond allocated length - overflow.       &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt;           &lt;table bgcolor="#000000" border="1" cellpadding="4" cellspacing="1" width="100%"&gt;              &lt;tbody&gt;               &lt;tr bgcolor="#c0c0c0"&gt;                 &lt;td&gt;                 &lt;pre&gt;char *a = malloc(128*sizeof(char));&lt;br /&gt;memcpy(a, data, dataLen);      // Error if dataLen too long.&lt;br /&gt;&lt;/pre&gt;                 &lt;/td&gt;               &lt;/tr&gt;             &lt;/tbody&gt;           &lt;/table&gt;          &lt;/dd&gt;&lt;/dl&gt;        &lt;p&gt; Example 2:      &lt;br /&gt; Index of array out of bounds:      (array index overflow - index too large/underflow - negative index)        &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt;           &lt;table bgcolor="#000000" border="1" cellpadding="4" cellspacing="1" width="100%"&gt;              &lt;tbody&gt;               &lt;tr bgcolor="#c0c0c0"&gt;                 &lt;td&gt;                 &lt;pre&gt;ptr = (char *) malloc(strlen(string_A));  // Should be (string_A + 1) to account for null termination.&lt;br /&gt;strcpy(ptr, string_A); // Copies memory from string_A which is one byte longer than its destination ptr.&lt;br /&gt;&lt;/pre&gt;                 &lt;/td&gt;               &lt;/tr&gt;             &lt;/tbody&gt;           &lt;/table&gt;          &lt;/dd&gt;&lt;/dl&gt;   Overflow by one byte.       &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;p&gt;       &lt;b&gt;Using an address before memory is allocated and set:&lt;/b&gt;       &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt;           &lt;table bgcolor="#000000" border="1" cellpadding="4" cellspacing="1" width="100%"&gt;              &lt;tbody&gt;               &lt;tr bgcolor="#c0c0c0"&gt;                 &lt;td&gt;                 &lt;pre&gt;struct *ABC_ptr;&lt;br /&gt;x = ABC_ptr-&gt;name;&lt;br /&gt;&lt;/pre&gt;                 &lt;/td&gt;               &lt;/tr&gt;             &lt;/tbody&gt;           &lt;/table&gt;          &lt;/dd&gt;&lt;/dl&gt;   In this case the memory location is NULL or random.       &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;p&gt;       &lt;b&gt;Using a pointer which is already freed:&lt;/b&gt;        &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt;           &lt;table bgcolor="#000000" border="1" cellpadding="4" cellspacing="1" width="100%"&gt;              &lt;tbody&gt;               &lt;tr bgcolor="#c0c0c0"&gt;                 &lt;td&gt;                 &lt;pre&gt;char *a = malloc(128*sizeof(char));&lt;br /&gt;..&lt;br /&gt;..&lt;br /&gt;free(a);&lt;br /&gt;&lt;br /&gt;cout &lt;&lt; a &lt;&lt; endl;  // This will probably work but dangerous.&lt;br /&gt;&lt;br /&gt;... Do stuff. Probable overwriting of freed memory.&lt;br /&gt;&lt;br /&gt;cout &lt;&lt; a &lt;&lt; endl;  // No longer the same contents. Memory overwritten by new stuff.&lt;br /&gt;&lt;/pre&gt;                 &lt;/td&gt;               &lt;/tr&gt;             &lt;/tbody&gt;           &lt;/table&gt;          &lt;/dd&gt;&lt;/dl&gt;        &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;p&gt;       &lt;b&gt;Freeing memory which has already been freed. Also applies to delete.&lt;/b&gt;       &lt;/p&gt;       &lt;p&gt; Freeing a pointer twice:       &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt;           &lt;table bgcolor="#000000" border="1" cellpadding="4" cellspacing="1" width="100%"&gt;              &lt;tbody&gt;               &lt;tr bgcolor="#c0c0c0"&gt;                 &lt;td&gt;                 &lt;pre&gt;char *a = malloc(128*sizeof(char));&lt;br /&gt;free(a);&lt;br /&gt;...   Do stuff&lt;br /&gt;free(a);  // A check for NULL would indicate nothing.&lt;br /&gt;         // This memory space may be reallocated and thus we may be freeing&lt;br /&gt;         // memory we do not intend to free or portions of another block of&lt;br /&gt;         // memory. The size of the block of memory allocated is often held&lt;br /&gt;         // just before the memory block itself..&lt;br /&gt;&lt;/pre&gt;                 &lt;/td&gt;               &lt;/tr&gt;             &lt;/tbody&gt;           &lt;/table&gt;          &lt;/dd&gt;&lt;/dl&gt;        &lt;p&gt;       &lt;b&gt;Freeing memory which was not dynamically allocated:&lt;/b&gt;        &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt;           &lt;table bgcolor="#000000" border="1" cellpadding="4" cellspacing="1" width="100%"&gt;              &lt;tbody&gt;               &lt;tr bgcolor="#c0c0c0"&gt;                 &lt;td&gt;                 &lt;pre&gt;struct ABC abc;&lt;br /&gt;struct ABC *abc_ptr = &amp;abc;&lt;br /&gt;...&lt;br /&gt;free(abc_ptr);&lt;br /&gt;&lt;/pre&gt;                 &lt;/td&gt;               &lt;/tr&gt;             &lt;/tbody&gt;           &lt;/table&gt;          &lt;/dd&gt;&lt;/dl&gt;        &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;p&gt;       &lt;b&gt;Incorrect use of delete: The delete must match the use of new.&lt;/b&gt;       &lt;/p&gt;       &lt;p&gt; The pairing is new/delete and new [] / delete[]        &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt;           &lt;table bgcolor="#000000" border="1" cellpadding="4" cellspacing="1" width="100%"&gt;              &lt;tbody&gt;               &lt;tr bgcolor="#c0c0c0"&gt;                 &lt;td&gt;                 &lt;pre&gt;ClassABC *abc_ptr = new ClassABC[100];&lt;br /&gt;...&lt;br /&gt;delete [] abc_ptr;&lt;br /&gt;&lt;/pre&gt;                 &lt;/td&gt;               &lt;/tr&gt;             &lt;/tbody&gt;           &lt;/table&gt;          &lt;/dd&gt;&lt;/dl&gt;   Use of "delete abc_ptr" is an error.       &lt;p&gt; Do not use malloc()/free() with a C++ class as it will not call the constructor or destructor. Also malloc()/free() can not be mixed with new/delete. i.e. Free() can not be used to free memory allocated with new and delete can not be used to free memory allocated with malloc().       &lt;/p&gt;       &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;p&gt;       &lt;b&gt;Exception Errors:&lt;/b&gt;       &lt;/p&gt;       &lt;p&gt; Freeing memory never allocated. If you use a constructor to allocate memory but an exception is thrown  before all is allocated, the destructor needs to be aware that fact or else it may try to free memory which was never allocated.       &lt;/p&gt;       &lt;p&gt; Also the converse is true. If the destructor throws an exception, subsequent steps which free memory may not be executed. This applies to the destructor and all nested destructors which handle/re-throw the exception while the stack  unwinds.       &lt;/p&gt;       &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;p&gt;       &lt;b&gt;Pointer persistence:&lt;/b&gt;       &lt;/p&gt;       &lt;p&gt; Function returning a pointer from the stack which can get overwritten by the calling function (in this case main()):        &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt;           &lt;table bgcolor="#000000" border="1" cellpadding="4" cellspacing="1" width="100%"&gt;              &lt;tbody&gt;               &lt;tr bgcolor="#c0c0c0"&gt;                 &lt;td&gt;                 &lt;pre&gt;int *get_ii()&lt;br /&gt;{&lt;br /&gt;  int ii;        // Local stack variable&lt;br /&gt;  ii = 2;&lt;br /&gt;  return &amp;ii;&lt;br /&gt;}&lt;br /&gt;main()&lt;br /&gt;{&lt;br /&gt; int *ii;&lt;br /&gt; ii = get_ii();  // After this call the stack is given up by the routine&lt;br /&gt;                 // get_ii() and its values are no longer safe.&lt;br /&gt;&lt;br /&gt; ... Do stuff&lt;br /&gt; ..  ii may be corrupt by this point.&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;                 &lt;/td&gt;               &lt;/tr&gt;             &lt;/tbody&gt;           &lt;/table&gt;          &lt;/dd&gt;&lt;/dl&gt;   This is also true for a local variable within the scope of only { and } as well as for the scope of a function.       &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;p&gt;       &lt;b&gt;Incorrect passing of a function argument:&lt;/b&gt;       &lt;/p&gt;       &lt;p&gt; If the pointer is passed around as an argument and does not get passed  correctly, one may try to free the incorrect pointer.       &lt;/p&gt;       &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;p&gt;       &lt;b&gt;Mixing the object base class and derived class:&lt;/b&gt;       &lt;/p&gt;       &lt;p&gt; If mixing the object base class and derived class when passing an object by value as a function parameter, make sure that you understand what may be lost.        &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt;           &lt;table bgcolor="#000000" border="1" cellpadding="4" cellspacing="1" width="100%"&gt;              &lt;tbody&gt;               &lt;tr bgcolor="#c0c0c0"&gt;                 &lt;td&gt;                 &lt;pre&gt;function_A(BaseClass baseClass_ptr)&lt;br /&gt;{&lt;br /&gt;...&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// Call to function&lt;br /&gt;function_A(derivedClass_ptr); // Note that much of the information contained&lt;br /&gt;                           // in the derived class will not be passed into&lt;br /&gt;                           // the function including virtual destructors.&lt;br /&gt;&lt;/pre&gt;                 &lt;/td&gt;               &lt;/tr&gt;             &lt;/tbody&gt;           &lt;/table&gt;          &lt;/dd&gt;&lt;/dl&gt;        &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;p&gt;       &lt;b&gt;Copying an object:&lt;/b&gt;       &lt;/p&gt;       &lt;p&gt; Don't use memcpy() or any bit for bit copy function to copy an object.  It will not execute the class constructor. What kind of person would do this?? Passing an object in a va_arg() list will result in a bit for bit copy and will not use the default copy constructor.       &lt;/p&gt;       &lt;p&gt;       &lt;a name="LINKS"&gt;&lt;/a&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;table border="0" cellpadding="2" cellspacing="0" width="100%"&gt;          &lt;tbody&gt;           &lt;tr bgcolor="#ffcc33"&gt;             &lt;td&gt;&lt;b&gt;&lt;big&gt;Links:&lt;/big&gt;&lt;/b&gt;&lt;/td&gt;           &lt;/tr&gt;          &lt;/tbody&gt;       &lt;/table&gt;        &lt;p&gt;       &lt;/p&gt;       &lt;ul&gt;&lt;li&gt;&lt;a href="http://www.informit.com/articles/article.asp?p=30642&amp;amp;seqNum=9"&gt;C++ Memory and Resource Management: Improper Use of auto_ptr&lt;/a&gt;         &lt;/li&gt;&lt;li&gt;&lt;a href="http://www.eventhelix.com/RealtimeMantra/Basics/debugging_software_crashes_2.htm"&gt;Debugging Software Crashes&lt;/a&gt;         &lt;/li&gt;&lt;li&gt;&lt;a href="http://users.actcom.co.il/%7Echoo/lupg/tutorials/unix-memory/unix-memory.html"&gt;Unix And C/C++ Runtime Memory Management For Programmers&lt;/a&gt;         &lt;/li&gt;&lt;li&gt;&lt;a href="http://www.linuxdevcenter.com/pub/a/linux/2003/05/08/cpp_mm-1.html?page=1"&gt;C++ Memory Management: From Fear to Triumph&lt;/a&gt;         &lt;/li&gt;&lt;/ul&gt;        &lt;p&gt; Related YoLinux Tutorials:       &lt;/p&gt;       &lt;ul&gt;&lt;li&gt;&lt;a href="http://www.yolinux.com/TUTORIALS/LinuxTutorialSoftwareDevelopment.html#MEMORYTOOLS"&gt;Software Development Tools: Memory Debugging Development Tools&lt;/a&gt;         &lt;/li&gt;&lt;li&gt;&lt;a href="http://www.yolinux.com/TUTORIALS/LinuxTutorialC++.html"&gt;C++ programming on Linux&lt;/a&gt;         &lt;/li&gt;&lt;li&gt;&lt;a href="http://www.yolinux.com/TUTORIALS/LinuxTutorialC++CodingStyle.html"&gt;C++ Coding styles and practices &lt;/a&gt;         &lt;/li&gt;&lt;li&gt;&lt;a href="http://www.yolinux.com/TUTORIALS/LinuxTutorialC++Structures.html"&gt;C++ structures&lt;/a&gt;         &lt;/li&gt;&lt;li&gt;&lt;a href="http://www.yolinux.com/TUTORIALS/index.html#PROGRAMMING"&gt;Programming Tutorials&lt;/a&gt;         &lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-3992981296261872807?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/3992981296261872807/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=3992981296261872807' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/3992981296261872807'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/3992981296261872807'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/03/cc-software-memory-corruption-types.html' title='C/C++ software memory corruption types:  There are two forms of Linux Memory accessible to the programmer:     1. User&apos;s virtual memory space in which'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-3910306490763622439</id><published>2009-03-06T13:38:00.000-08:00</published><updated>2009-03-06T13:55:25.743-08:00</updated><title type='text'>Interview questions</title><content type='html'>&lt;span style="font-size:130%;"&gt;1) What's the difference between fopen and open?&lt;/span&gt;&lt;br /&gt;fopen/fread/fwrite have buffer to fasten I/O process, but open/read/write&lt;br /&gt;dosen't&lt;br /&gt;&lt;br /&gt;open() is not standard and might not be implemented in some standard-conforming hosted environments, whereas fopen() is standard and is implemented in all standard-conforming hosted environments.  Therefore for portability, use the standard functions, not (emulated)&lt;br /&gt;Unix system service calls.&lt;br /&gt;&lt;br /&gt;There are other functional differences, the most notable being that the stdio stream uses a buffer in "user space", whereas the direct system-call I/O does not.  (There might or might not be kernel-space buffers in both cases.)  This can matter if record length is important; for example, if you want to write a magnetic tape record of length 80, write(fd,buf,80) will do that, whereas fwrite(buf,80,1,fp) will likely just put the data in a user-space buffer, with the actual write occurring eventually when the buffer is full - which will result in something like a 512-byte&lt;br /&gt;magtape record.  You could perhaps work around that by issuing a fflush(fp) after the fwrite(), but it's a kludgy way to accomplish what write() does directly.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;2) Difference between Threads and process&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A single process can have multiple threads that share global data and address space with other threads running in the same process, and therefore can operate on the same data set easily. Processes do not share address space and a different mechanism must be used if they are to share data.&lt;br /&gt; If we consider running a word processing program to be a process, then the auto-save and spell check features that occur in the background are different threads of that process which are all operating on the same data set (your document).&lt;br /&gt;&lt;br /&gt;&lt;span id="sort1"&gt;&lt;span class="tdvamseel"&gt;Creation of new process requires new resources and Address space whereas the thread can be created in the same address space of the process which not only saves space and resources but are also easy to create and delete,and many threads can exhists in a process.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span id="sort1"&gt;&lt;span class="tdvamseel"&gt;&lt;p&gt;Threads share the address space of the process that created it; processes have their own address.&lt;br /&gt;&lt;br /&gt;Threads have direct access to the data segment of its process; processes have their own copy of the data segment of the parent process.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Threads can directly communicate with other threads of its process; processes must use inter-process communication to communicate with sibling processes.&lt;br /&gt;&lt;br /&gt;Threads have almost no overhead; processes have considerable overhead.&lt;br /&gt;&lt;br /&gt;New threads are easily created; new processes require duplication of the parent process.&lt;br /&gt;&lt;br /&gt;Threads can exercise considerable control over threads of the same process; processes can only exercise control over child processes.&lt;br /&gt;&lt;br /&gt;Changes to the main thread (cancellation, priority change, etc.) may affect the behavior of the other threads of the process, changes to the parent process does not affect child processes.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Both have an id, set of registers, state, priority, and scheduling policy.&lt;br /&gt;&lt;br /&gt;Both have attributes that describe the entity to the OS.&lt;br /&gt;&lt;br /&gt;Both have an information block.&lt;br /&gt;&lt;br /&gt;Both share resources with the parent process.&lt;br /&gt;&lt;br /&gt;Both function as independent entities from the parent process.&lt;br /&gt;&lt;br /&gt;The creator can exercise some control over the thread or process.&lt;br /&gt;&lt;br /&gt;Both can change their attributes.&lt;br /&gt;&lt;br /&gt;Both can create new resources.&lt;br /&gt;&lt;br /&gt;Neither can access the resources of another process.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;3) Difference between mutex and critical section&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;A concrete example of program using a mutex between process, is the registry (advapi32.dll).&lt;br /&gt;&lt;br /&gt;All registry operations use the same mutex to modify the internal hash-table that represents the registry (Under Windows 95 and 98 at least).&lt;br /&gt;&lt;br /&gt;So remember (on multiprocessor platform at least) that a registry function is relatively slow.&lt;br /&gt;&lt;br /&gt;I think that CriticalSections use internally a Semaphore, and that a request to a critical section is very, very fast if the critical section if not currently used (for many applications, that is almost always the case), and if not it is slow like a normal mutex or semaphore.&lt;br /&gt;&lt;br /&gt;Quite often you'll see reference to the speed differences between the user mode critical section and the kernel objects mutex and semaphore. I really don't pay much attention to these 'speed' differences because either you can use a critical section or you can't.&lt;br /&gt;&lt;br /&gt;If you are synchronizing data shared between multiple threads of the same process, you can use a critical section. Yes, you *could* use a mutex or semaphore, but they will be a few clock cycles slower because they are kernel objects. A good general usage rule is: When in the same process, prefer to use the critical section.&lt;br /&gt;&lt;br /&gt;When you are synchronizing data shared between multiple processes, you can't use a critical section. So it doesn't matter that the mutex or semaphore is slower than the critical section, since you can't use a critical section anyway across processes.&lt;br /&gt;&lt;br /&gt;I usually follow this rule: "Slower, properly synchronized data is still better than fast, corrupt data!"&lt;br /&gt;&lt;br /&gt;A &lt;em&gt;critical section object&lt;/em&gt; provides synchronization similar to that provided by a mutex object, except that a critical section can be used only by the threads of a single process. Event, mutex, and semaphore objects can also be used in a single-process application, but critical section objects provide a slightly faster, more efficient mechanism for mutual-exclusion synchronization (a processor-specific test and set instruction). Like a mutex object, a critical section object can be owned by only one thread at a time, which makes it useful for protecting a shared resource from simultaneous access. Unlike a mutex object, there is no way to tell whether a critical section has been abandoned.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-3910306490763622439?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/3910306490763622439/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=3910306490763622439' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/3910306490763622439'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/3910306490763622439'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/03/interview-questions.html' title='Interview questions'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-5182412127313402556</id><published>2009-02-26T08:35:00.001-08:00</published><updated>2009-02-26T08:35:32.312-08:00</updated><title type='text'>[C++] Returning Vector from Function</title><content type='html'>&lt;strong&gt;[C++] Returning Vector from Function&lt;/strong&gt;        &lt;hr style="color: rgb(255, 255, 255); background-color: rgb(255, 255, 255);" size="1"&gt;    &lt;!-- / icon and title --&gt;           &lt;!-- message --&gt;   &lt;div class="vbclean_msgtext" id="post_message_3971175"&gt;&lt;div style="margin: 5px 20px 20px;"&gt;  &lt;div class="smallfont" style="margin-bottom: 2px;"&gt;Code:&lt;/div&gt;  &lt;pre class="alt2" dir="ltr" style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 640px; height: 210px; text-align: left;"&gt;std::vector&lt;int&gt; foo()&lt;br /&gt;{&lt;br /&gt; std::vector&lt;int&gt; v;&lt;br /&gt; /* fill it */&lt;br /&gt; return v; // (1)&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void bar()&lt;br /&gt;{&lt;br /&gt; std::vector&lt;int&gt; v = foo(); // (2)&lt;br /&gt; v = foo(); // (3)&lt;br /&gt;}&lt;/pre&gt; &lt;/div&gt;What really happens here?&lt;br /&gt;&lt;br /&gt;First off, despite the apparent notation line (2) really is a copy constructor, and not a default constructor + assignment. This is mandated by the standard, and that's the reason why I used both examples (2) and (3).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So...&lt;br /&gt;(2) call foo&lt;br /&gt;(1) copy constructor&lt;br /&gt;(back to 2) copy constructor again (ouch!)&lt;br /&gt;&lt;br /&gt;(3) call foo&lt;br /&gt;(1) copy constructor&lt;br /&gt;(back to 3) assignment operator, which is &lt;i&gt;usually&lt;/i&gt; implemented as a copy constructor (ouch again!) + swap&lt;br /&gt;&lt;br /&gt;So as you can see, the problem is that returning an object will trigger a copy. Most modern compilers have an optimization called "Return Value Optimization" (RVO for short) which is &lt;i&gt;most of the time&lt;/i&gt; able to merge the steps (1) and (back to...). But as with any compiler optimization you shouldn't really count on that...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;That leaves us with at least one copy, which could easily be avoided:&lt;br /&gt;&lt;div style="margin: 5px 20px 20px;"&gt;  &lt;div class="smallfont" style="margin-bottom: 2px;"&gt;Code:&lt;/div&gt;  &lt;pre class="alt2" dir="ltr" style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 640px; height: 210px; text-align: left;"&gt;void foo(std::vector&lt;int&gt;&amp;amp; retVal)&lt;br /&gt;{&lt;br /&gt; std::vector&lt;int&gt; v;&lt;br /&gt; /* fill it */&lt;br /&gt; retVal.swap(v); // (1)&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void bar()&lt;br /&gt;{&lt;br /&gt; std::vector&lt;int&gt; v; // (2)&lt;br /&gt; foo(v); // (3)&lt;br /&gt;}&lt;/pre&gt; &lt;/div&gt;Now we're left with:&lt;br /&gt;(2) default constructor, quite lightweight to say the least&lt;br /&gt;(3) call foo&lt;br /&gt;(1) swapping both vectors, again hyper lightweight&lt;br /&gt;(back to 3) nothing more &lt;img src="http://ubuntuforums.org/images/smilies/icon_smile.gif" alt="" title="Smile" class="inlineimg" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So as yabbadabbadont put it, the best way to pass big objects back from the callee to the caller obviously is to use a reference argument.&lt;br /&gt;Although this doesn't really matter for small datasets, returning vectors or other containers from a function can quickly introduce huge overhead when the dataset grows (since it involves copying the whole dataset at least once).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Which leads me way off topic:&lt;br /&gt;A class supporting copy / assignment should always have a swap() method too...&lt;br /&gt;- the copy constructor just does its job&lt;br /&gt;- the swap method quickly and safely (as in nothrow-guarantee) exchanges the contents of two objects&lt;br /&gt;- the assignment operator is implemented in terms of copy + swap (after checking for self-assignment of course)&lt;br /&gt;&lt;br /&gt;This way you end up with an exception-safe assignment operator for almost no effort, and many use cases can be optimized away thanks to the swap() method. It's a win-win... &lt;img src="http://ubuntuforums.org/images/smilies/icon_smile.gif" alt="" title="Smile" class="inlineimg" border="0" /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-5182412127313402556?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/5182412127313402556/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=5182412127313402556' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/5182412127313402556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/5182412127313402556'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/02/c-returning-vector-from-function.html' title='[C++] Returning Vector from Function'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-4631570017734772477</id><published>2009-02-22T18:24:00.000-08:00</published><updated>2009-02-22T18:25:25.756-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technique'/><title type='text'>Detect iPhone browser</title><content type='html'>&lt;h1 class="date" style="font-size: 125%;" title="How do I detect an iPhone user coming to my site?"&gt;How do I detect an iPhone user coming to my site?&lt;/h1&gt;     &lt;div class="KonaBody"&gt;   &lt;div style="font-style: italic; color: rgb(0, 0, 51);"&gt;   &lt;p&gt;Amazon.com's jumped on the wagon, and Meebo has too: they automatically give you a different version of their site if you're browsing from an Apple iPhone. I want to do that too. How the heck do I detect that a visitor has an iPhone?&lt;/p&gt;  &lt;/div&gt;    &lt;!-- end of google rect block div --&gt;  &lt;div style="margin-top: 25px; margin-bottom: 25px;"&gt; &lt;hr color="#cccccc" size="6" noshade="noshade"&gt; &lt;/div&gt;  Dave's Answer:   &lt;p&gt;The key to detecting a browser type is to remember that there's an environment full of information transmitted with each query sent from the web &lt;a id="KonaLink0" target="undefined" class="kLink" style="text-decoration: underline ! important; position: static;" href="http://www.askdavetaylor.com/detect_apple_iphone_user_web_site_server.html#"&gt;&lt;span style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;color:#111166;" &gt;&lt;span class="kLink" style="border-bottom: 1px none rgb(17, 17, 102); color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static; background-color: transparent;"&gt;browser&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; to the server. It includes the obvious things like the requested &lt;a id="KonaLink1" target="undefined" class="kLink" style="text-decoration: underline ! important; position: static;" href="http://www.askdavetaylor.com/detect_apple_iphone_user_web_site_server.html#"&gt;&lt;span style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;color:#111166;" &gt;&lt;span class="kLink" style="border-bottom: 1px none rgb(17, 17, 102); color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static; background-color: transparent;"&gt;data &lt;/span&gt;&lt;span class="kLink" style="border-bottom: 1px none rgb(17, 17, 102); color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static; background-color: transparent;"&gt;file&lt;/span&gt;&lt;/span&gt;&lt;span style="position: relative;" id="preLoadWrap1"&gt;&lt;div style="position: absolute; z-index: 4000; top: -32px; left: -18px; display: none;" id="preLoadLayer1"&gt;&lt;img style="border: 0px none ;" src="http://kona.kontera.com/javascript/lib/imgs/grey_loader.gif" /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/a&gt; (which can be an &lt;a id="KonaLink2" target="undefined" class="kLink" style="text-decoration: underline ! important; position: static;" href="http://www.askdavetaylor.com/detect_apple_iphone_user_web_site_server.html#"&gt;&lt;span style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;color:#111166;" &gt;&lt;span class="kLink" style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;"&gt;HTML &lt;/span&gt;&lt;span class="kLink" style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;"&gt;document&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;, &lt;a id="KonaLink3" target="undefined" class="kLink" style="text-decoration: underline ! important; position: static;" href="http://www.askdavetaylor.com/detect_apple_iphone_user_web_site_server.html#"&gt;&lt;span style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;color:#111166;" &gt;&lt;span class="kLink" style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;"&gt;GIF&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; or &lt;a id="KonaLink4" target="undefined" class="kLink" style="text-decoration: underline ! important; position: static;" href="http://www.askdavetaylor.com/detect_apple_iphone_user_web_site_server.html#"&gt;&lt;span style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;color:#111166;" &gt;&lt;span class="kLink" style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;"&gt;JPEG &lt;/span&gt;&lt;span class="kLink" style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;"&gt;image&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;, AVI movie, FLV animation or related) and the &lt;a id="KonaLink5" target="undefined" class="kLink" style="text-decoration: underline ! important; position: static;" href="http://www.askdavetaylor.com/detect_apple_iphone_user_web_site_server.html#"&gt;&lt;span style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;color:#111166;" &gt;&lt;span class="kLink" style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;"&gt;IP &lt;/span&gt;&lt;span class="kLink" style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;"&gt;address&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; of the browser's computer, but it also includes a critical variable called &lt;b&gt;HTTP_USER_AGENT&lt;/b&gt;.&lt;/p&gt;  &lt;p&gt;Visit with a regular browser from a regular computer and you'll see something like this:&lt;/p&gt;  &lt;div class="code"&gt;HTTP_USER_AGENT=Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)&lt;/div&gt;  &lt;p&gt;Here you can see that I'm &lt;a id="KonaLink7" target="undefined" class="kLink" style="text-decoration: underline ! important; position: static;" href="http://www.askdavetaylor.com/detect_apple_iphone_user_web_site_server.html#"&gt;&lt;span style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;color:#111166;" &gt;&lt;span class="kLink" style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;"&gt;testing&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; from Firefox (which identifies itself as Mozilla for historical reasons) running on &lt;a id="KonaLink8" target="undefined" class="kLink" style="text-decoration: underline ! important; position: static;" href="http://www.askdavetaylor.com/detect_apple_iphone_user_web_site_server.html#"&gt;&lt;span style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;color:#111166;" &gt;&lt;span class="kLink" style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;"&gt;Windows &lt;/span&gt;&lt;span class="kLink" style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;"&gt;XP&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; (though it's identifying it as Windows NT for some cockamainie reason) and that I'm also running .NET.&lt;/p&gt;  &lt;p&gt;Grab that same environment value from a slick Apple iPhone query, though, and the values are quite a bit different:&lt;/p&gt;  &lt;div class="code"&gt;HTTP_USER_AGENT=Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en)&lt;br /&gt;AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1C25 Safari/419.3&lt;/div&gt;  &lt;p&gt;Pretty interesting reading if you're a geek: You can see where it's also identifying itself as Mozilla, but this time as Mozilla/5.0 rather than Mozilla/4.0. The string "iPhone" appears, which is what we'll key on, but notice also that it says that it's on a &lt;a id="KonaLink9" target="undefined" class="kLink" style="text-decoration: underline ! important; position: static;" href="http://www.askdavetaylor.com/detect_apple_iphone_user_web_site_server.html#"&gt;&lt;span style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;color:#111166;" &gt;&lt;span class="kLink" style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;"&gt;system&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; with a "CPU like Mac OS X", just as we iPhone users have been suspecting for a while.&lt;/p&gt;  &lt;p&gt;You can see the basic test we'll need to do here to ascertain if the visitor is using an iPhone or not: if their HTTP_USER_AGENT environment value contains the string "iPhone", we've got a match. Otherwise it's something else on some other device or computer.&lt;/p&gt;  &lt;p&gt;You can do this test and act on it in a zillion different places, ranging from the actual Web server ruleset to &lt;a id="KonaLink10" target="undefined" class="kLink" style="text-decoration: underline ! important; position: static;" href="http://www.askdavetaylor.com/detect_apple_iphone_user_web_site_server.html#"&gt;&lt;span style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;color:#111166;" &gt;&lt;span class="kLink" style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;"&gt;JavaScript &lt;/span&gt;&lt;span class="kLink" style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;"&gt;code&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; to PHP conditional code to even having a separate "&lt;a id="KonaLink11" target="undefined" class="kLink" style="text-decoration: underline ! important; position: static;" href="http://www.askdavetaylor.com/detect_apple_iphone_user_web_site_server.html#"&gt;&lt;span style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;color:#111166;" &gt;&lt;span class="kLink" style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;"&gt;gateway&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;" script page that everyone hits and redirects them to the iPhone or non-iPhone version of your Web page and site.  &lt;/p&gt;  &lt;p&gt;A &lt;a id="KonaLink12" target="undefined" class="kLink" style="text-decoration: underline ! important; position: static;" href="http://www.askdavetaylor.com/detect_apple_iphone_user_web_site_server.html#"&gt;&lt;span style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;color:#111166;" &gt;&lt;span class="kLink" style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;"&gt;JavaScript&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; snippet might look like this:&lt;/p&gt;  &lt;div class="code"&gt;var agent=navigator.userAgent.toLowerCase();&lt;br /&gt;var is_iphone  = ((agent.indexOf('iphone')!=-1);&lt;br /&gt;if (is_iphone) { &lt;i&gt;conditional code goes here&lt;/i&gt; }&lt;/div&gt;  &lt;p&gt;Rather do it as a &lt;a id="KonaLink13" target="undefined" class="kLink" style="text-decoration: underline ! important; position: static;" href="http://www.askdavetaylor.com/detect_apple_iphone_user_web_site_server.html#"&gt;&lt;span style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;color:#111166;" &gt;&lt;span class="kLink" style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;"&gt;shell &lt;/span&gt;&lt;span class="kLink" style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;"&gt;script&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;?  Me too. Here's how I'd do that as a rudimentary Linux shell script:&lt;/p&gt;  &lt;div class="code"&gt;#!/bin/sh&lt;br /&gt;&lt;br /&gt;if [ ! -z "$(echo $HTTP_USER_AGENT | grep iPhone)" ] ; then&lt;br /&gt;  echo "Location: iphone/index.html"&lt;br /&gt;else&lt;br /&gt;  echo "Location: index2.html"&lt;br /&gt;fi&lt;br /&gt;exit 0&lt;/div&gt;  &lt;p&gt;You can also have the conditional directly in &lt;a id="KonaLink14" target="undefined" class="kLink" style="text-decoration: underline ! important; position: static;" href="http://www.askdavetaylor.com/detect_apple_iphone_user_web_site_server.html#"&gt;&lt;span style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;color:#111166;" &gt;&lt;span class="kLink" style="color: rgb(17, 17, 102) ! important; font-family: verdana,arial,sans-serif; font-weight: 400; font-size: 13px; position: static;"&gt;CSS&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; itself, if you're really into cryptic notations:&lt;/p&gt;  &lt;div class="code"&gt;&lt;!--#if expr="(${HTTP_USER_AGENT} = /iPhone/)"--&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;&lt;!--&lt;br /&gt;&lt;i&gt;here's where you'd include special styles for the iPhone&lt;/i&gt;&lt;br /&gt;--&gt;&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;!--#else --&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;&lt;!--&lt;br /&gt;&lt;i&gt;regular web browser style and CSS information goes here&lt;/i&gt;&lt;br /&gt;--&gt;&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;!--#endif --&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;The basic idea in either case is that once you have detected that they're running an iPhone, you can modify what you deliver to them, either changing what's on the page, perhaps giving them a completely different version of the page, or even taking them to a different site entirely.&lt;/p&gt;  &lt;p&gt;Hope that helps you out!  Don't forget while you're here that I have quite a lot of &lt;a href="http://www.askdavetaylor.com/about_iphone.html" target="_blank"&gt;iPhone help&lt;/a&gt; here too.&lt;/p&gt;  &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-4631570017734772477?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/4631570017734772477/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=4631570017734772477' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/4631570017734772477'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/4631570017734772477'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/02/detect-iphone-browser.html' title='Detect iPhone browser'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-5971803765614434173</id><published>2009-01-09T15:53:00.001-08:00</published><updated>2009-01-09T15:53:55.655-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technique'/><title type='text'>BLACKBERRY 解锁</title><content type='html'>&lt;h3&gt;搞定BLACKBERRY解锁了。现在俺ROGERS的黑莓回国探亲时候中国的卡也能用了。提醒大家不用花钱解锁了&lt;/h3&gt;                    &lt;span style="font-family:Arial;"&gt;&lt;span style="font-size: 12px;"&gt;&lt;span style="font-size: 12px;"&gt;据说是RIM的测试程序泄漏出来了。叫做 MFI MULTILOADER。今天把自己的解了。很爽。大概过程如下：&lt;br /&gt;1.下载4.7版的DESKTOP MANAGER，安装&lt;br /&gt;2.下载你黑莓那个版本的最新OS。安装 ，安装完以后去删除VENDOR.XML （C:program filescommon files research in motionpploader&lt;br /&gt;3. 下载并安装微软的NET FRAMWORK 2.0&lt;br /&gt;4. 下载并安装MML,（5M左右）&lt;br /&gt;5. 下载MFI MULTILOADER 解压缩到C:MML目录下覆盖文件(大约700M）&lt;br /&gt;6. 执行MML（桌面上有图标），等READY了，插上BLACKBERRY。会自动开始解锁。&lt;br /&gt;7. 解锁完成后，拔下来黑莓，关闭MML。这时黑莓绿灯会闪来闪去，在黑莓上输入START。&lt;br /&gt;8。再次插上黑莓，打开DESKTOP MANAGER， 升级黑莓操作系统。&lt;br /&gt;9。升级完后黑莓自动重启，搞定！！&lt;br /&gt;如何检验： 进入OPTION--ADVANCED OPTION--SIM CARD 输入MCPD，如果看到NETWORK是DISABLE，那就解锁成功了，没解之前是ACTIVE。&lt;br /&gt;现在随便什么卡都能用了，不用花20刀去找人解锁了。提醒：备份好数据先！！&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-5971803765614434173?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/5971803765614434173/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=5971803765614434173' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/5971803765614434173'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/5971803765614434173'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/01/blackberry.html' title='BLACKBERRY 解锁'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-6293980123988648320</id><published>2009-01-01T20:50:00.000-08:00</published><updated>2009-01-01T20:55:41.019-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technique'/><title type='text'>SUN WTK 2.5 + EclipseMe 1.7.9 + Nokia S60 5Edition</title><content type='html'>Nokia is always the super, I do not what to say, they create the most weird development tools ever!!!&lt;br /&gt;&lt;br /&gt;Trying to build a package with the tool chain (SUN WTK 2.5 + EclipseMe 1.7.9 + Nokia S60 5Edition).  I do not know for what reason it does not work, finally figured out and make a memo here.&lt;br /&gt;&lt;br /&gt;Wish can help you.&lt;br /&gt;&lt;br /&gt;Put the class entrance in the %project%.jad file to mention the project name and entrance class. Then the generated deployed jad and jar will work for the phone and the simulator.&lt;br /&gt;&lt;br /&gt;Good luck.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-6293980123988648320?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/6293980123988648320/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=6293980123988648320' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/6293980123988648320'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/6293980123988648320'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2009/01/sun-wtk-25-eclipseme-179-nokia-s60.html' title='SUN WTK 2.5 + EclipseMe 1.7.9 + Nokia S60 5Edition'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-6245333124582962878</id><published>2008-12-27T14:38:00.000-08:00</published><updated>2008-12-27T14:39:25.482-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='BlackBerry'/><title type='text'>Switching Dialog</title><content type='html'>&lt;p&gt;Thanks for the answer, i think that then i have to do it for myself, for now i have one dialog similar to that, only that whith vertical scroll.&lt;/p&gt;&lt;pre&gt;&lt;p&gt;package es.telefonica.ui.menus;&lt;br /&gt;&lt;br /&gt;import net.rim.device.api.i18n.ResourceBundle;&lt;br /&gt;import net.rim.device.api.system.EncodedImage;&lt;br /&gt;import net.rim.device.api.ui.Field;&lt;br /&gt;import net.rim.device.api.ui.Keypad;&lt;br /&gt;import net.rim.device.api.ui.Manager;&lt;br /&gt;import net.rim.device.api.ui.component.Dialog;&lt;br /&gt;import es.telefonica.cmcore.ComunicadorCore;&lt;br /&gt;import es.telefonica.common.MensajesLog;&lt;br /&gt;import es.telefonica.countryinfo.CountryResource;&lt;br /&gt;import es.telefonica.icons.IconosResource;&lt;br /&gt;import es.telefonica.ui.componentes.BotonContactos;&lt;br /&gt;import es.telefonica.ui.componentes.ImagenException;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* Dialogo que sirve para seleccionar los posibles estados de presencia&lt;br /&gt;* Ejemplo:Ausente, Conectado, etc..-&lt;br /&gt;* @author jose&lt;br /&gt;*&lt;br /&gt;*/&lt;br /&gt;public class DialogoEstados extends Dialog&lt;br /&gt;{&lt;br /&gt; &lt;br /&gt; private static ResourceBundle countryResource = ResourceBundle.getBundle(&lt;br /&gt;   CountryResource.BUNDLE_ID, CountryResource.BUNDLE_NAME);&lt;br /&gt; &lt;br /&gt; private static ResourceBundle iconResource = ResourceBundle.getBundle(&lt;br /&gt;   IconosResource.BUNDLE_ID, IconosResource.BUNDLE_NAME);&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt; private BotonContactos desconectado; &lt;br /&gt; private BotonContactos conectado;&lt;br /&gt; private BotonContactos ocupado;&lt;br /&gt; private BotonContactos vuelvoEnseguida;&lt;br /&gt; private BotonContactos ausente;&lt;br /&gt; private BotonContactos alTelefono;&lt;br /&gt; &lt;br /&gt; /**&lt;br /&gt;  * El constructor ya crea un dialogo con los botones y el titulo correctos&lt;br /&gt;  */&lt;br /&gt; public DialogoEstados()&lt;br /&gt; {&lt;br /&gt;  super(countryResource.getString(CountryResource.Title_Status_Dialog),null,null,0,null,Manager.VERTICAL_SCROLL);&lt;br /&gt;  try&lt;br /&gt;  {&lt;br /&gt;   desconectado=new BotonContactos();&lt;br /&gt;   desconectado.setImagenEstado(ComunicadorCore.getGestorImagenes().getImagen(iconResource.getString(IconosResource.Image_Disconnected)));&lt;br /&gt;    // TODO Auto-generated catch block&lt;br /&gt;   desconectado.setLabelNombre(countryResource.getString(CountryResource.Disconnected)); &lt;br /&gt;   &lt;br /&gt;   this.add(desconectado);&lt;br /&gt;   &lt;br /&gt;   conectado=new BotonContactos();&lt;br /&gt;   conectado.setImagenEstado(ComunicadorCore.getGestorImagenes().getImagen(iconResource.getString(IconosResource.Image_Connected)));    &lt;br /&gt;   conectado.setLabelNombre(countryResource.getString(CountryResource.Connected));&lt;br /&gt;   &lt;br /&gt;   this.add(conectado);&lt;br /&gt;   &lt;br /&gt;   ocupado=new BotonContactos();&lt;br /&gt;   ocupado.setImagenEstado(ComunicadorCore.getGestorImagenes().getImagen(iconResource.getString(IconosResource.Image_Busy)));    &lt;br /&gt;   ocupado.setLabelNombre(countryResource.getString(CountryResource.Busy));&lt;br /&gt;   &lt;br /&gt;   this.add(ocupado);&lt;br /&gt;   &lt;br /&gt;   vuelvoEnseguida=new BotonContactos();&lt;br /&gt;   vuelvoEnseguida.setImagenEstado(ComunicadorCore.getGestorImagenes().getImagen(iconResource.getString(IconosResource.Image_Back_Right_Away)));    &lt;br /&gt;   vuelvoEnseguida.setLabelNombre(countryResource.getString(CountryResource.BackRightAway));&lt;br /&gt;  &lt;br /&gt;   this.add(vuelvoEnseguida);&lt;br /&gt;   &lt;br /&gt;   ausente=new BotonContactos();&lt;br /&gt;   ausente.setImagenEstado(ComunicadorCore.getGestorImagenes().getImagen(iconResource.getString(IconosResource.Image_Absent)));    &lt;br /&gt;   ausente.setLabelNombre(countryResource.getString(CountryResource.Absent));&lt;br /&gt;   &lt;br /&gt;   this.add(ausente);&lt;br /&gt;   &lt;br /&gt;   alTelefono=new BotonContactos();&lt;br /&gt;   alTelefono.setImagenEstado(ComunicadorCore.getGestorImagenes().getImagen(iconResource.getString(IconosResource.Image_To_The_Phone)));    &lt;br /&gt;   alTelefono.setLabelNombre(countryResource.getString(CountryResource.ToThePhone));&lt;br /&gt;   &lt;br /&gt;   this.add(alTelefono);&lt;br /&gt;  }&lt;br /&gt;  catch (ImagenException e)&lt;br /&gt;  {&lt;br /&gt;    e.printStackTrace();&lt;br /&gt;  }&lt;br /&gt;  &lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; /**&lt;br /&gt;  * Metodo que se ejecuta cuando se pulsa la rueda&lt;br /&gt;  */&lt;br /&gt; protected boolean navigationClick(int status, int time)&lt;br /&gt; {&lt;br /&gt;  onSeleccion();&lt;br /&gt;  return super.navigationUnclick(status, time);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; /**&lt;br /&gt;  * MEtodo que se ejecuta cuando se pulsa una tecla, en este caso no interesa solo el Enter y el Escape&lt;br /&gt;  */&lt;br /&gt; protected boolean keyChar(char key, int status, int time)&lt;br /&gt; {&lt;br /&gt;  // TODO Auto-generated method stub&lt;br /&gt;  if(key==Keypad.KEY_ENTER)&lt;br /&gt;  {&lt;br /&gt;   onSeleccion();&lt;br /&gt;  }&lt;br /&gt;  else if(key==Keypad.KEY_ESCAPE)&lt;br /&gt;  {&lt;br /&gt;   this.close();&lt;br /&gt;  }&lt;br /&gt;  return super.keyChar(key, status, time);&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; /**&lt;br /&gt;  * Este metodo es el que extrae el boton que actualmente esta seleccionado, y ejecuta el cambio de estado&lt;br /&gt;  */&lt;br /&gt; private void onSeleccion()&lt;br /&gt; {&lt;br /&gt;  Field panelVertical = this.getFieldWithFocus();&lt;br /&gt;  if(panelVertical instanceof Manager)&lt;br /&gt;  {&lt;br /&gt;   Manager manager=(Manager)panelVertical;&lt;br /&gt;   Field campoSeleccionado = manager.getFieldWithFocus();&lt;br /&gt;   campoSeleccionado.getBorderBottom();&lt;br /&gt;   &lt;br /&gt;   EncodedImage imagenEstado=null;&lt;br /&gt;   if(campoSeleccionado instanceof BotonContactos)&lt;br /&gt;   {&lt;br /&gt;    try&lt;br /&gt;    {&lt;br /&gt;     BotonContactos boton=(BotonContactos)campoSeleccionado;&lt;br /&gt;     String id = boton.getLabelNombre();&lt;br /&gt;     if(id.equals(countryResource.getString(CountryResource.Disconnected)))&lt;br /&gt;     {&lt;br /&gt;      imagenEstado=ComunicadorCore.getGestorImagenes().getImagen(iconResource.getString(IconosResource.Image_Disconnected));&lt;br /&gt;      MensajesLog.debug(DialogoEstados.class, "Seleccionado: "+countryResource.getString(CountryResource.Disconnected));&lt;br /&gt;     }&lt;br /&gt;     else if(id.equals(countryResource.getString(CountryResource.Connected)))&lt;br /&gt;     {&lt;br /&gt;      imagenEstado=ComunicadorCore.getGestorImagenes().getImagen(iconResource.getString(IconosResource.Image_Connected));&lt;br /&gt;      MensajesLog.debug(DialogoEstados.class, "Seleccionado: "+countryResource.getString(CountryResource.Connected));&lt;br /&gt;     }&lt;br /&gt;     else if(id.equals(countryResource.getString(CountryResource.Busy)))&lt;br /&gt;     {&lt;br /&gt;      imagenEstado=ComunicadorCore.getGestorImagenes().getImagen(iconResource.getString(IconosResource.Image_Busy));&lt;br /&gt;      MensajesLog.debug(DialogoEstados.class, "Seleccionado: "+countryResource.getString(CountryResource.Busy));&lt;br /&gt;     }&lt;br /&gt;     else if(id.equals(countryResource.getString(CountryResource.BackRightAway)))&lt;br /&gt;     {&lt;br /&gt;      imagenEstado=ComunicadorCore.getGestorImagenes().getImagen(iconResource.getString(IconosResource.Image_Back_Right_Away));&lt;br /&gt;      MensajesLog.debug(DialogoEstados.class, "Seleccionado: "+countryResource.getString(CountryResource.BackRightAway));&lt;br /&gt;     }&lt;br /&gt;     else if(id.equals(countryResource.getString(CountryResource.Absent)))&lt;br /&gt;     {&lt;br /&gt;      imagenEstado=ComunicadorCore.getGestorImagenes().getImagen(iconResource.getString(IconosResource.Image_Absent));&lt;br /&gt;      MensajesLog.debug(DialogoEstados.class, "Seleccionado: "+countryResource.getString(CountryResource.Absent));&lt;br /&gt;     }&lt;br /&gt;     else if(id.equals(countryResource.getString(CountryResource.ToThePhone)))&lt;br /&gt;     {&lt;br /&gt;      imagenEstado=ComunicadorCore.getGestorImagenes().getImagen(iconResource.getString(IconosResource.Image_To_The_Phone));&lt;br /&gt;      MensajesLog.debug(DialogoEstados.class, "Seleccionado: "+countryResource.getString(CountryResource.ToThePhone));&lt;br /&gt;     }&lt;br /&gt;     &lt;br /&gt;     //TODO cambiar el icono del usuario&lt;br /&gt;     if(imagenEstado!=null)&lt;br /&gt;     {&lt;br /&gt;      &lt;br /&gt;     }&lt;br /&gt;    }&lt;br /&gt;    catch(ImagenException e)&lt;br /&gt;    {&lt;br /&gt;     e.printStackTrace();&lt;br /&gt;    }&lt;br /&gt;    finally&lt;br /&gt;    {&lt;br /&gt;     this.close();&lt;br /&gt;    }&lt;br /&gt;   }&lt;br /&gt;  }    &lt;br /&gt; } &lt;br /&gt;}&lt;/p&gt;&lt;/pre&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt; thanks&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-6245333124582962878?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/6245333124582962878/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=6245333124582962878' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/6245333124582962878'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/6245333124582962878'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2008/12/switching-dialog.html' title='Switching Dialog'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-2862472066950277597</id><published>2008-12-27T14:36:00.001-08:00</published><updated>2008-12-27T14:36:49.378-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='BlackBerry'/><title type='text'>Blackberry Virtual Keyboard</title><content type='html'>&lt;p&gt;Well I have finally resolved this by developing my own home grown virtual keyboard.  This should work until RIM fixes the bug with their virtual keyboard.  In case anyone else is having the same problem, I have provide the code for it here:&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;public class MyVirtualKeyboard extends VerticalFieldManager&lt;br /&gt;{&lt;br /&gt;    // 1---2---3&lt;br /&gt;    // 4---5---6&lt;br /&gt;    // 7---8---9&lt;br /&gt;    // .---0---x&lt;br /&gt;    private ButtonField[] numbers = new ButtonField[]&lt;br /&gt;    {&lt;br /&gt;        new ButtonField("1", ButtonField.CONSUME_CLICK),&lt;br /&gt;        new ButtonField("2", ButtonField.CONSUME_CLICK),&lt;br /&gt;        new ButtonField("3", ButtonField.CONSUME_CLICK),&lt;br /&gt;        new ButtonField("4", ButtonField.CONSUME_CLICK),&lt;br /&gt;        new ButtonField("5", ButtonField.CONSUME_CLICK),&lt;br /&gt;        new ButtonField("6", ButtonField.CONSUME_CLICK),&lt;br /&gt;        new ButtonField("7", ButtonField.CONSUME_CLICK),&lt;br /&gt;        new ButtonField("8", ButtonField.CONSUME_CLICK),&lt;br /&gt;        new ButtonField("9", ButtonField.CONSUME_CLICK),&lt;br /&gt;        new ButtonField(".", ButtonField.CONSUME_CLICK),&lt;br /&gt;        new ButtonField("0", ButtonField.CONSUME_CLICK),&lt;br /&gt;        new ButtonField("x", ButtonField.CONSUME_CLICK),&lt;br /&gt;    };&lt;br /&gt;    private ButtonField close = new ButtonField("Close",&lt;br /&gt;        ButtonField.CONSUME_CLICK);&lt;br /&gt;    private FieldChangeListener listener = new FieldChangeListener()&lt;br /&gt;    {&lt;br /&gt;        public void fieldChanged(Field f, int ctx)&lt;br /&gt;        {&lt;br /&gt;            if (ctx == FieldChangeListener.PROGRAMMATIC)&lt;br /&gt;                return;&lt;br /&gt;            String val = ((ButtonField) f).getLabel();&lt;br /&gt;            if (Character.isDigit(val.charAt(0)) || val.equals("."&lt;img class="emoticon emoticon-smileywink" id="smileywink" src="http://supportforums.blackberry.com/i/smilies/16x16_smiley-wink.gif" alt=":smileywink:" title="Smiley Wink" /&gt;)&lt;br /&gt;                caller.setCharacter(val);&lt;br /&gt;            else if (val.equals("x"&lt;img class="emoticon emoticon-smileywink" id="smileywink" src="http://supportforums.blackberry.com/i/smilies/16x16_smiley-wink.gif" alt=":smileywink:" title="Smiley Wink" /&gt;)&lt;br /&gt;                caller.removeLastCharacter();&lt;br /&gt;        }&lt;br /&gt;    };&lt;br /&gt;    private Caller caller;&lt;br /&gt;&lt;br /&gt;    public MyVirtualKeyboard(Caller caller)&lt;br /&gt;    {&lt;br /&gt;        this.caller = caller;&lt;br /&gt;        // 4 rows of buttons will be displayed&lt;br /&gt;        int buttonIndex = 0;&lt;br /&gt;        for (int i = 0; i &lt; 4; i++)&lt;br /&gt;        {&lt;br /&gt;            HorizontalFieldManager row = new HorizontalFieldManager();&lt;br /&gt;            for (int j = 0; j &lt; 3; j++)&lt;br /&gt;            {&lt;br /&gt;                numbers[buttonIndex].setChangeListener(listener);&lt;br /&gt;                row.add(numbers[buttonIndex++]);&lt;br /&gt;            }&lt;br /&gt;            add(row);&lt;br /&gt;        }&lt;br /&gt;        close.setChangeListener(new FieldChangeListener()&lt;br /&gt;        {&lt;br /&gt;            public void fieldChanged(Field field, int ctx)&lt;br /&gt;            {&lt;br /&gt;                MyVirtualKeyboard.this.caller.closeMe();&lt;br /&gt;            }&lt;br /&gt;        });&lt;br /&gt;        add(close);&lt;br /&gt;    }&lt;br /&gt;}&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;Here is the interface I created callled 'Caller':&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;public interface Caller&lt;br /&gt;{&lt;br /&gt;    public void closeMe();&lt;br /&gt;    public void setCharacter(String character);&lt;br /&gt;    public void removeLastCharacter();&lt;br /&gt;}&lt;br /&gt; &lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;Here is how I invoke it (this code is in my MainScreen subclass, which is implementing FocusChangeListener and my call back interface Caller):&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;public void focusChanged(Field field, int ctx)    {&lt;br /&gt;        currentlyEditing = null;&lt;br /&gt;        if (field != checkAmt &amp;amp;&amp;amp; field != taxAmt)&lt;br /&gt;            return;&lt;br /&gt;        if (ctx == FocusChangeListener.FOCUS_GAINED)&lt;br /&gt;        {&lt;br /&gt;            currentlyEditing = (BasicEditField) field;&lt;br /&gt;            MyVirtualKeyboard keyboard = new MyVirtualKeyboard(this);&lt;br /&gt;            popup = new PopupScreen(keyboard);&lt;br /&gt;            getUiEngine().pushScreen(popup);&lt;br /&gt;        }&lt;br /&gt;    }&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;Here is the callback methods on the main screen class that take the input from the popup keyboard:&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;public void setCharacter(String character)&lt;br /&gt;    {&lt;br /&gt;        String currText = currentlyEditing.getText();&lt;br /&gt;        currText += character;&lt;br /&gt;        currentlyEditing.setText(currText);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public void removeLastCharacter()&lt;br /&gt;    {&lt;br /&gt;        String currText = currentlyEditing.getText();&lt;br /&gt;        if (currText.length() == 0)&lt;br /&gt;            return;&lt;br /&gt;        currentlyEditing.setText(currText.substring(0, currText.length() - 1));&lt;br /&gt;    }&lt;br /&gt; &lt;/p&gt;&lt;p&gt;  public void closeMe()&lt;br /&gt;    {&lt;br /&gt;        getUiEngine().popScreen(popup);&lt;br /&gt;    }&lt;br /&gt; &lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;Also, I have a menu item where if the user needs to display the keyboard, they can:&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;showKeyboard = new MenuItem("Show Keyboard", 3, 12)       {&lt;br /&gt;            public void run()&lt;br /&gt;            {&lt;br /&gt;                MyVirtualKeyboard keyboard = new MyVirtualKeyboard(&lt;br /&gt;                    MyScreen.this);&lt;br /&gt;                popup = new PopupScreen(keyboard);&lt;br /&gt;                getUiEngine().pushScreen(popup);&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt; &lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;Here is what the popup virtual keyboard looks like:&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;img alt="virtual keyboard for floating point" src="http://i200.photobucket.com/albums/aa11/swarsa/myvirtualkeyboard.jpg" border="0" width="188" height="265" /&gt;&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;Hopefully this will help someone else.&lt;/p&gt;&lt;div class="message-edit-history"&gt;&lt;span class="edit-author"&gt;Message Edited by stevewarsa on &lt;/span&gt;&lt;span class="local-date"&gt;12-07-2008&lt;/span&gt;&lt;span class="local-time"&gt; 08:02 AM&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-2862472066950277597?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/2862472066950277597/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=2862472066950277597' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/2862472066950277597'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/2862472066950277597'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2008/12/blackberry-virtual-keyboard.html' title='Blackberry Virtual Keyboard'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-3301533917304044901</id><published>2008-12-09T07:34:00.001-08:00</published><updated>2008-12-09T07:34:52.697-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technique'/><title type='text'>Redmine</title><content type='html'>&lt;div class="wiki"&gt;   &lt;h1 id="Redmine"&gt;Redmine&lt;a href="http://www.redmine.org/#Redmine" class="wiki-anchor"&gt;¶&lt;/a&gt;&lt;/h1&gt;    &lt;p&gt;Redmine is a flexible project management web application. Written using Ruby on Rails framework, it is cross-platform and cross-database.&lt;/p&gt;    &lt;p&gt;Redmine is open source and released under the terms of the &lt;a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html" class="external"&gt;GNU General Public License v2&lt;/a&gt; (GPL).&lt;/p&gt;    &lt;h2 id="Overview"&gt;Overview&lt;a href="http://www.redmine.org/#Overview" class="wiki-anchor"&gt;¶&lt;/a&gt;&lt;/h2&gt;    &lt;ul&gt;&lt;li&gt;Multiple projects support&lt;/li&gt;&lt;li&gt;Flexible role based access control.&lt;/li&gt;&lt;li&gt;Flexible issue tracking system&lt;/li&gt;&lt;li&gt;Gantt chart and calendar&lt;/li&gt;&lt;li&gt;News, documents &amp;amp; files management&lt;/li&gt;&lt;li&gt;Feeds &amp;amp; email notifications.&lt;/li&gt;&lt;li&gt;Per project wiki&lt;/li&gt;&lt;li&gt;Per project forums&lt;/li&gt;&lt;li&gt;Simple time tracking functionality&lt;/li&gt;&lt;li&gt;Custom fields for issues, projects and users&lt;/li&gt;&lt;li&gt;SCM integration (SVN, CVS, Git, Mercurial, Bazaar and Darcs)&lt;/li&gt;&lt;li&gt;Multiple LDAP authentication support&lt;/li&gt;&lt;li&gt;User self-registration support&lt;/li&gt;&lt;li&gt;Multilanguage support&lt;/li&gt;&lt;li&gt;Multiple databases support&lt;/li&gt;&lt;/ul&gt;    &lt;p&gt;Read more about &lt;a href="http://www.redmine.org/wiki/redmine/Features" class="wiki-page"&gt;Redmine features&lt;/a&gt;&lt;/p&gt;    &lt;h2 id="Documentation"&gt;Documentation&lt;a href="http://www.redmine.org/#Documentation" class="wiki-anchor"&gt;¶&lt;/a&gt;&lt;/h2&gt;    &lt;p&gt;You can read the &lt;a href="http://www.redmine.org/wiki/redmine/Guide" class="wiki-page"&gt;Redmine guide&lt;/a&gt; (work in progress).&lt;/p&gt;   Others resources:  &lt;ul&gt;&lt;li&gt;&lt;a href="http://www.redmine.org/wiki/redmine/Changelog" class="wiki-page"&gt;Changelog&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.redmine.org/wiki/redmine/FAQ" class="wiki-page"&gt;Frequently Asked Questions&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.redmine.org/wiki/redmine/HowTos" class="wiki-page"&gt;HowTos&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.redmine.org/wiki/redmine/Plugins" class="wiki-page"&gt;Plugins&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;    &lt;h2 id="They-are-using-Redmine"&gt;They are using Redmine&lt;a href="http://www.redmine.org/#They-are-using-Redmine" class="wiki-anchor"&gt;¶&lt;/a&gt;&lt;/h2&gt;    &lt;p&gt;&lt;a href="http://www.redmine.org/wiki/redmine/TheyAreUsingRedmine" class="wiki-page"&gt;This page lists&lt;/a&gt; some companies/projects using Redmine.&lt;/p&gt;    &lt;h2 id="Support-xx-getting-help"&gt;Support &amp;amp; getting help&lt;a href="http://www.redmine.org/#Support-xx-getting-help" class="wiki-anchor"&gt;¶&lt;/a&gt;&lt;/h2&gt;    &lt;p&gt;For getting help or discussing about Redmine, you can browse the &lt;a href="http://www.redmine.org/projects/redmine/boards" class="external"&gt;Redmine forums&lt;/a&gt; hosted right here in Redmine. Or, join #redmine on the &lt;a href="http://freenode.net/irc_servers.shtml" class="external"&gt;freenode&lt;/a&gt; IRC network. Prior to March 7, 2008, the Redmine forums were hosted at Rubyforge.  You can search the &lt;a href="http://rubyforge.org/forum/?group_id=1850" class="external"&gt;old forum archives&lt;/a&gt; as well.&lt;/p&gt;    &lt;p&gt;Before submitting a bug report here, please read this: &lt;a href="http://www.redmine.org/wiki/redmine/SubmittingBugs" class="wiki-page"&gt;SubmittingBugs&lt;/a&gt;.&lt;/p&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-3301533917304044901?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/3301533917304044901/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=3301533917304044901' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/3301533917304044901'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/3301533917304044901'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2008/12/redmine.html' title='Redmine'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-2582609818015567028</id><published>2008-11-20T12:26:00.000-08:00</published><updated>2008-11-20T12:27:26.551-08:00</updated><title type='text'>The Power User's BlackBerry Guide: 121 CrackBerry Tips</title><content type='html'>&lt;h1&gt;The Power User's BlackBerry Guide: 121 CrackBerry Tips, Hacks and Resources&lt;/h1&gt;       &lt;div class="content_teaser bold"&gt;         Addicted to your PDA? It's time to get more from it.       &lt;/div&gt;       &lt;div class="content_date"&gt;        By &lt;span class="bold"&gt;Inside CRM Editors&lt;/span&gt;           &lt;/div&gt;               &lt;div id="innercol" class="right"&gt;      &lt;img src="http://static.insidecrm.com/images/crm/hd_article-tools.gif" alt="Article Tools" /&gt;&lt;br /&gt;     &lt;div class="article_socialmedia pad_bottom"&gt;       &lt;ul&gt;&lt;li&gt;             &lt;img src="http://static.insidecrm.com/images/crm/icon_digg.gif" alt="" class="left" width="16" height="14" /&gt;            &lt;script type="text/javascript"&gt;             digg_url = 'http://digg.com/gadgets/The_Power_User_s_BlackBerry_Guide ';             digg_skin = 'compact';            &lt;/script&gt;          &lt;script src="http://digg.com/tools/diggthis.js" type="text/javascript"&gt;&lt;/script&gt;&lt;iframe src="http://digg.com/tools/diggthis.php?u=http%3A//digg.com/gadgets/The_Power_User_s_BlackBerry_Guide%20&amp;amp;s=compact" scrolling="no" width="120" frameborder="0" height="18"&gt;&lt;/iframe&gt;           &lt;/li&gt;&lt;li&gt;&lt;a href="http://del.icio.us/post?url=http://www.insidecrm.com/features/121-blackberry-tips-021408/"&gt;&lt;img src="http://static.voip-news.com/images/btn-delicious.gif" alt="" width="57" height="16" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.insidecrm.com/features/121-blackberry-tips-021408/"&gt;&lt;img src="http://static.voip-news.com/images/btn-stumble.gif" alt="" width="60" height="16" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;      &lt;/div&gt;          &lt;img src="http://static.insidecrm.com/images/crm/hd_related-articles.gif" alt="Related Articles" /&gt;&lt;br /&gt;     &lt;div class="related_articles"&gt;             &lt;/div&gt;     &lt;/div&gt;             &lt;p&gt;                 &lt;/p&gt;&lt;div class="body_content"&gt;          &lt;p&gt;CrackBerry addicts, are you ready to take your BlackBerry to the next level? In this list, you'll find some of the most awesome tips, hacks, how-tos and guides for the BlackBerry, making it easy for just about anyone to become a power user.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Tips&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;These BlackBerry tips will help you work easier, better and faster.&lt;/p&gt;  &lt;ol&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberrytips.net/tips.php?id=93"&gt;Delete Multiple Messages&lt;/a&gt;&lt;/strong&gt;: Search for messages, then press Delete Prior to delete all of the messages in the results.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Read "&lt;a href="http://www.washingtonpost.com/wp-dyn/content/article/2007/06/10/AR2007061001276.html"&gt;A Wired-In Guy Getting Set for a Big Date&lt;/a&gt;":&lt;/strong&gt; Stick your wet BlackBerry, or any other doomed device, (turned off) in a bowl of uncooked rice overnight, and it will suck out the moisture.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Navigate Your Calendar Quickly:&lt;/strong&gt; First, enable Quick Entry, then press "D" for day, "W" for week, "M" for month and "A" for agenda.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://forums.crackberry.com/f3/handy-tip-separate-your-smss-emails-6035/"&gt;Separate SMS (Short Message Service) Messages and Emails&lt;/a&gt;&lt;/strong&gt;: Select Separate in the SMS and Email Inboxes field under General Options.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberrytips.net/tips.php?id=140"&gt;Select Text on a Page&lt;/a&gt;&lt;/strong&gt;: To highlight text, press Shift, then move the wheel up or down.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Delete by Date&lt;/strong&gt;: Click a date and press Delete Prior to restore order to your mailbox while still retaining your most recent messages.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryfaq.com/index.php/Tips_and_Tricks"&gt;Get BlackBerry Tips, Tricks and Key-Press Shortcuts&lt;/a&gt;:&lt;/strong&gt; Learn important keys, message tips and more.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberrytips.net/tips.php?id=89"&gt;Permanently Delete Emails&lt;/a&gt;&lt;/strong&gt;: To ensure that you're permanently deleting emails, delete them from your email client rather than using the Delete Prior feature.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Capitalize Letters:&lt;/strong&gt; Press and hold letters down to make them capitals.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://forums.crackberry.com/f3/how-block-pin-sms-mms-messages-9034/"&gt;Turn Off Messages&lt;/a&gt;&lt;/strong&gt;: You can choose to turn off messages by going through your &lt;a href="http://www.itsecurity.com/"&gt;security&lt;/a&gt; options and modifying your &lt;a href="http://www.itsecurity.com/firewalls/"&gt;firewall&lt;/a&gt; settings.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Get Better Coverage with Your Radio:&lt;/strong&gt; If your coverage is not doing well, try turning your radio off and on to force a network scan.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Scroll Down:&lt;/strong&gt; Use your spacebar to scroll down a page, then press Shift and the spacebar simultaneously to move back up.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryforums.com/aftermarket-software/2018-blackberry-calendar-tricks.html"&gt;Get BlackBerry Calendar Tricks&lt;/a&gt;&lt;/strong&gt;: This post covers popular tricks for the BlackBerry's calendar.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberrytips.net/tips.php?id=7"&gt;Sync Specific Folders&lt;/a&gt;&lt;/strong&gt;: Set up Folder Redirection to sync only selected email folders to your BlackBerry.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Dial Letter Numbers&lt;/strong&gt;: Call lettered numbers like 1-800-GOOG-411 by pressing Alt, hen typing the letters.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberrytips.net/tips.php?id=144"&gt;Empty Your Phone-Call Log&lt;/a&gt;&lt;/strong&gt;: Enable Call Logging, then delete items in your Phone Call Logs folder.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Insert the "@" Symbol in an Email Message&lt;/strong&gt;. Press the spacebar to enter an "@" symbol in a message or press it twice to insert a period.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Dry Your Device with Silica Gel&lt;/strong&gt;: If you've dropped your BlackBerry in water, dry it out with silica-gel packets, which often come in shoeboxes. This also works with silica cat litter, which is generally labeled as crystal.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Select Special Characters&lt;/strong&gt;: Press and hold a letter key, then move the thumb wheel up or down to get the appropriate character.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberrytips.net/tips.php?id=74"&gt;Enable Content Protection&lt;/a&gt;&lt;/strong&gt;: Store data on your device securely by enabling content protection.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Stop a Page from Loading&lt;/strong&gt;. Press the Escape button to keep Web pages from loading.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberrytips.net/tips.php?id=59"&gt;Reboot Your BlackBerry&lt;/a&gt;&lt;/strong&gt;: You can reboot your BlackBerry without pulling out your battery by pressing Alt, Caps and Delete simultaneously.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Dry Your BlackBerry with Alcohol&lt;/strong&gt;: Another drying option that also disinfects is 100 percent alcohol. Turn your BlackBerry off, soak it in alcohol and take it apart as much as possible. The alcohol should evaporate with exposure to air.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberrytips.net/tips.php?id=137"&gt;Read the Top 10 Phone Tips from BlackBerry&lt;/a&gt;&lt;/strong&gt;: This list includes simple tips for changing volume, speed-dialing and more.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://crackberry.com/advanced-crackberry-tip-use-your-blackberry-flashlight"&gt;Use Your BlackBerry as a Flashlight&lt;/a&gt;&lt;/strong&gt;: The BlackBerry makes a great flashlight for middle-of-the-night runs to the fridge or the bathroom.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberrytips.net/tips.php?id=68"&gt;Delete Mail-Client Emails from Your BlackBerry&lt;/a&gt;&lt;/strong&gt;: Select Purge Deleted Items under Email Reconciliation to delete emails on your mail client.&lt;/li&gt;&lt;/ol&gt;  &lt;p&gt;&lt;strong&gt;Guides&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Learn how to turn your BlackBerry into a supertool with these guides.&lt;/p&gt;  &lt;ol start="27"&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.businesscreditcards.com/bootstrapper/blackberry-on-crack-25-tools-to-supercharge-your-lifeline/"&gt;BlackBerry on Crack: 25 Tools to Supercharge Your Lifeline&lt;/a&gt;&lt;/strong&gt;: This guide offers useful tools for BlackBerry business users and more.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryforums.com/aftermarket-software/316-updated-blackberry-killer-software-utilities-thread.html"&gt;BlackBerry Software and Utilities&lt;/a&gt;&lt;/strong&gt;: If you're looking for any aftermarket BlackBerry tweaks, this is the place to start.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.bbhub.com/2006/10/17/mac-os-x-tethered-modem-solution-for-blackberry/"&gt;Mac OS X Tethered Modem Solution for BlackBerry&lt;/a&gt;&lt;/strong&gt;: Find out how to use a BlackBerry as a modem in OS X.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryforums.com/aftermarket-software/315-visual-voicemail-voice-text-automatic-transcription.html"&gt;Voice-to-Text Voice Mail Services and Third-Party Alpha Pager Dispatch Services&lt;/a&gt;&lt;/strong&gt;: Check out these services that will transcribe your BlackBerry voice mails.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryforums.com/rim-software/680-faq-what-methods-receiving-email-blackberry.html"&gt;What Are the Methods of Receiving Email on BlackBerry?&lt;/a&gt;&lt;/strong&gt;: Read this article to figure out your email options.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryfaq.com/index.php/BlackBerry_For_Deaf_%26_Hard_of_Hearing"&gt;BlackBerry for the Deaf and Hard of Hearing&lt;/a&gt;&lt;/strong&gt;: This article explains why BlackBerry devices are great for those who are hearing impaired.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.wired.com/science/discoveries/news/2005/10/69294"&gt;The Agony of "BlackBerry Thumb"&lt;/a&gt;&lt;/strong&gt;: Learn about BlackBerry-related thumb pain and what you can do about it.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryforums.com/general-blackberry-discussion/498-push-available-non-blackberry-devices.html#post3494"&gt;Why BlackBerry?&lt;/a&gt;&lt;/strong&gt;: Find out why the BlackBerry is a superior choice for some people.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryforums.com/rim-software/3921-blackberry-internet-browser-faq-html-web-images.html"&gt;BlackBerry HTML Web-Browsing FAQ&lt;/a&gt;&lt;/strong&gt;: Get the lowdown on HTML browsing here.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryhowto.com/content.php?article.27"&gt;Basic BlackBerry Etiquette&lt;/a&gt;&lt;/strong&gt;: Here, you'll find a basic list of dos and don'ts for being a polite BlackBerry user.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryfaq.com/index.php/Buying_a_BlackBerry_off_eBay"&gt;Buying a BlackBerry on eBay&lt;/a&gt;&lt;/strong&gt;: Check out this guide to learn how to avoid getting scammed when purchasing a BlackBerry from a seller on eBay.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryinsight.com/2006/05/13/implementing-getting-things-done-with-your-blackberry/"&gt;Implementing GTD with Your BlackBerry&lt;/a&gt;&lt;/strong&gt;: This guide recommends applications and more items for helping you get things done on the BlackBerry.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberry.com/btsc/dynamickc.do?externalId=KB05409&amp;amp;sliceId=SAL_Public&amp;amp;command=show&amp;amp;forward=nonthreadedKC&amp;amp;kcId=KB05409&amp;amp;cp=NLC-25&amp;amp;MIG=45DDE91AD98333EFE10000000A659D16"&gt;Transfer a File Using Bluetooth Technology Between Two BlackBerry Smart Phones&lt;/a&gt;&lt;/strong&gt;: This guide will show you how to transfer files easily.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://forums.crackberry.com/f3/gmail-receiving-sent-items-you-send-your-blackberry-853/"&gt;Gmail Receiving "Sent Items" You Send On Your BlackBerry&lt;/a&gt;&lt;/strong&gt;: Learn how to turn off this syncing feature for Gmail and more.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryforums.com/aftermarket-software/2973-blackberry-im-chat-apps-faq-msn-aim-icq-yahoo-google-updated.html"&gt;BlackBerry Chat Apps/FAQ&lt;/a&gt;&lt;/strong&gt;: Learn about awesome IM (instant messaging) applications and more in this guide.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://forums.crackberry.com/f3/remove-i-t-policy-blackberry-569/"&gt;Remove an IT Policy from a BlackBerry&lt;/a&gt;&lt;/strong&gt;: Here, you'll find out how to rid yourself of a pesky IT policy.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryinsight.com/2007/01/22/easy-blackberry-backup/"&gt;Easy BlackBerry Backup&lt;/a&gt;&lt;/strong&gt;: Use this guide to back up your BlackBerry in just a minute.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://crackberry.com/first-ten-things-you-should-do-your-new-blackberry"&gt;The First 10 Things You Should Do With Your New BlackBerry&lt;/a&gt;&lt;/strong&gt;: Before you do anything else with your BlackBerry, do these 10 things.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://howto.wired.com/wiki/Appear_to_be_in_the_Office_While_Actually_Working_from_Home"&gt;Appear to Be in the Office While Actually Working from Home&lt;/a&gt;&lt;/strong&gt;: Fool everyone by making these tweaks using your BlackBerry and more.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://forums.crackberry.com/f3/blackberry-messenger-what-how-does-work-5877/"&gt;BlackBerry Messenger: What Is It and How Does It Work?&lt;/a&gt;&lt;/strong&gt;: Get the lowdown on this BlackBerry-to-BlackBerry messaging service.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryfaq.com/index.php/Maximum_Battery_Life"&gt;Maximize the Battery Life of Your New BlackBerry&lt;/a&gt;&lt;/strong&gt;: Follow this tutorial to learn how to get the most out of your battery.&lt;/li&gt;&lt;/ol&gt;  &lt;p&gt;&lt;strong&gt;How-Tos&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;These how-tos will guide you through step-by-step hacks and tricks for the BlackBerry.&lt;/p&gt;  &lt;ol start="48"&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryinsight.com/2007/12/07/how-to-use-your-blackberry-to-transfer-your-tasks-notes-appointments-and-contacts-from-windows-to-mac-os-x-and-vice-versa/"&gt;How to Use Your BlackBerry to Transfer Between Windows and Mac OS X&lt;/a&gt;&lt;/strong&gt;: In this guide, you'll learn how to port tasks, notes, appointments and contacts from Mac OS X to Windows, and vice versa.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryfaq.com/index.php/StandyBy_mode_vs._Sleep"&gt;How to Turn on Standby Mode Using the Mute Key&lt;/a&gt;&lt;/strong&gt;: Use this method to avoid pressing keys by accident.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://forums.crackberry.com/f3/how-edit-profile-set-notifications-1623/"&gt;How to Edit a Profile and Set Notifications&lt;/a&gt;&lt;/strong&gt;: Here, you'll find out how to change your BlackBerry's message and email notifications.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberrytips.net/tips.php?id=69"&gt;How to Restore Your BlackBerry to Default Settings&lt;/a&gt;&lt;/strong&gt;: Perform a security wipe on your device with this quick tutorial.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberrytips.net/tips.php?id=87"&gt;How to Free Up Memory on Your BlackBerry&lt;/a&gt;&lt;/strong&gt;: Keep your BlackBerry from enabling the low-memory management feature with this tutorial.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberrytips.net/tips.php?id=136"&gt;How to Get Images onto Your BlackBerry&lt;/a&gt;&lt;/strong&gt;: This quick tutorial offers a few easy ways to get images on your device.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://forums.crackberry.com/f3/how-remove-sent-my-blackberry-4980/"&gt;How to Remove "Sent from my BlackBerry"&lt;/a&gt;&lt;/strong&gt;: This tutorial will walk you through the steps to changing your signature.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryforums.com/blackberry-guides/2019-user-howto-use-blackberry-modem-laptop.html"&gt;How to Use BlackBerry as Modem For Laptop&lt;/a&gt;&lt;/strong&gt;: Give your laptop full Internet access using a BlackBerry.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberrytips.net/tips.php?id=173"&gt;How to Increase the Speed of the BlackBerry Browser&lt;/a&gt;&lt;/strong&gt;: Speed things up with these simple tips.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryforums.com/blackberry-network/2185-blackberry-internet-msn-chat-web-telnet-tcpip-no-bes.html"&gt;How to Configure Full Internet Access on BlackBerry&lt;/a&gt;&lt;/strong&gt;: Learn how to get full Internet access on your BlackBerry with this tutorial.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryinsight.com/2007/07/25/how-to-install-3rd-party-applications-mac-os-x/"&gt;How to Install Third-Party Applications (Mac OS X)&lt;/a&gt;&lt;/strong&gt;: This guide will walk you through installing apps on your BlackBerry through Mac OS X.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://forums.crackberry.com/f3/blackberry-101-how-lecture-series-4716/"&gt;BlackBerry 101: The How-To Lecture Series&lt;/a&gt;&lt;/strong&gt;: This series covers purchasing a BlackBerry, checking out the controls, third-party apps andmuch more.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.bbhub.com/2006/09/28/how-to-disassemble-a-blackberry-pearl-lots-of-pix-too/"&gt;How to Disassemble a BlackBerry Pearl&lt;/a&gt;&lt;/strong&gt;: Whether you're taking your Pearl apart for fun, hacking or just to air it out, here's how to do the job.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryinsight.com/2007/12/04/how-to-secure-your-blackberry/"&gt;How to Secure Your BlackBerry&lt;/a&gt;&lt;/strong&gt;: Keep your data safe by following the tips in this guide.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryinsight.com/2007/06/13/how-to-clean-your-blackberrys-trackball/"&gt;How to Clean Your BlackBerry's Trackball&lt;/a&gt;&lt;/strong&gt;: Get your trackball cleaned up with this how-to.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://forums.crackberry.com/f3/how-stop-blinking-10187/"&gt;How to Stop the Blinking&lt;/a&gt;&lt;/strong&gt;: Here you'll find out what various blinking lights mean and what you can do about them.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryinsight.com/2006/12/28/installing-3rd-party-applications-2/"&gt;Installing Third-Party Applications&lt;/a&gt;&lt;/strong&gt;: This guide for Windows users walks you through the process of installing of apps.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryinsight.com/2007/04/27/howto-get-blackberry-internet-access-without-data-plan-example-china-mobile/"&gt;How to Get BlackBerry Internet Access without a Data Plan&lt;/a&gt;&lt;/strong&gt;: Avoid data plans with this hack.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://forums.crackberry.com/f3/how-setup-gmail-free-spam-filter-your-crackberry-5736/"&gt;How to Set up Gmail as a Free Spam Filter for Your CrackBerry&lt;/a&gt;&lt;/strong&gt;: Use Gmail to keep spam out of your BlackBerry.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryinsight.com/2007/06/11/how-to-pair-a-bluetooth-gps-receiver-with-your-blackberry/"&gt;How to Pair a Bluetooth GPS Receiver with Your BlackBerry&lt;/a&gt;&lt;/strong&gt;: Check out this Bluetooth hack to pair your BlackBerry with a GPS receiver.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryinsight.com/2008/02/05/howto-transfer-files-to-your-blackberry-windows/"&gt;How to Transfer Files to Your BlackBerry&lt;/a&gt;&lt;/strong&gt;: This guide will teach you a few different methods of file transfers.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryinsight.com/2008/01/25/howto-use-berrydialer-to-save-a-lot-of-money-on-voice-calls-especially-idd-calls/"&gt;How to Use BerryDialer to Save a Lot of Money on Voice Calls&lt;/a&gt;&lt;/strong&gt;: Use this dialing hack to save some cash.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.bbhub.com/2006/11/03/heres-how-to-turn-a-full-length-dvd-movie-into-a-pearl-movie-fi/"&gt;Turn a Full Length DVD Movie into a Pearl Movie File&lt;/a&gt;&lt;/strong&gt;: This guide shows you how to turn a DVD into an .avi file.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryinsight.com/2007/12/29/howto-use-your-blackberry-as-an-emergency-flashlight-tool/"&gt;How to Use Your BlackBerry as an Emergency Flashlight&lt;/a&gt;&lt;/strong&gt;: Learn what you need to do to turn your BlackBerry into a flashlight.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://forums.crackberry.com/f3/how-remove-clean-your-trackball-3243/"&gt;How to Remove and Clean the Trackball&lt;/a&gt;&lt;/strong&gt;: Get your trackball squeaky clean with this guide.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryinsight.com/2008/01/11/how-to-put-a-full-blown-windows-desktop-environment-on-your-blackberry/"&gt;How to Put a Full-Blown Windows Desktop Environment on Your BlackBerry&lt;/a&gt;&lt;/strong&gt;: Use your microSD card slot to get Windows on your BlackBerry.&lt;/li&gt;&lt;/ol&gt;  &lt;p&gt;&lt;strong&gt;Cheat Sheets&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Make shortcuts and formats with these BlackBerry cheat sheets.&lt;/p&gt;  &lt;ol start="74"&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberrytips.net/tips.php?id=61"&gt;Hot Keys: BlackBerry Browser&lt;/a&gt;&lt;/strong&gt;: Use these hot keys when viewing Web pages.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.ccpa.net/cumberland/cwp/view.asp?A=1147&amp;amp;Q=532388"&gt;BlackBerry Cheat Sheet&lt;/a&gt;&lt;/strong&gt;: This sheet is full of useful shortcuts.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.comparecellular.com/user_guides_manufacturer.asp?l=&amp;amp;ManufacturerID=52"&gt;Compare Cellular&lt;/a&gt;&lt;/strong&gt;: Compare Cellular offers guides to getting started as well as quick reference guides for a number of BlackBerry models.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberrytips.net/tips.php?id=128"&gt;Supported Document Types&lt;/a&gt;&lt;/strong&gt;: This list offers a glimpse at the file formats that a BlackBerry can handle.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryinsight.com/2007/07/16/blackberry-shortcut-collection/"&gt;BlackBerry Shortcut Collection&lt;/a&gt;&lt;/strong&gt;: This handy guide has lots of shortcuts for the BlackBerry.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://forums.crackberry.com/f3/tip-helpful-keyboard-shortcuts-13131/"&gt;Tip: Helpful Keyboard Shortcuts&lt;/a&gt;&lt;/strong&gt;: This cheat sheet offers lots of shortcuts for phoning, messaging and more.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://nlearnseries.com/site/products/other_blackberrye.html"&gt;RIM BlackBerry Quick Reference Guide&lt;/a&gt;&lt;/strong&gt;: Get this handy printable sheet for an easy, quick reference for your BlackBerry.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryforums.com/rim-software/55848-cheat-sheet-share.html"&gt;Cheat Sheet to Share&lt;/a&gt;&lt;/strong&gt;: Here, you'll find loads of shortcuts.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberrytips.net/tips.php?id=62"&gt;Hot Keys: Calendar&lt;/a&gt;&lt;/strong&gt;: Create appointments and view dates more quickly with these hot keys.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://handheld.softpedia.com/get/Guides/SMS-Language-Quick-Reference-BlackBerry-40050.shtml"&gt;SMS Quick Reference&lt;/a&gt;&lt;/strong&gt;: Get this quick-reference guide to learn about SMS shortcuts for the BlackBerry.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryforums.com/blackberry-network/731-sms-north-american-extensions-usage.html"&gt;Free SMS Messages&lt;/a&gt;&lt;/strong&gt;: Avoid messaging fees by sending carrier-specific emails.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://forums.crackberry.com/f3/what-my-carrier-s-blackberry-internet-service-bis-website-url-3187/"&gt;What Is My Carrier's BIS (&lt;/a&gt;&lt;/strong&gt;&lt;strong&gt;&lt;a href="http://forums.crackberry.com/f3/what-my-carrier-s-blackberry-internet-service-bis-website-url-3187/"&gt;BlackBerry Internet Service&lt;/a&gt;&lt;/strong&gt;&lt;strong&gt;&lt;a href="http://forums.crackberry.com/f3/what-my-carrier-s-blackberry-internet-service-bis-website-url-3187/"&gt;) Web Site URL?&lt;/a&gt;&lt;/strong&gt;: Here, you'll find BIS URLs for providers worldwide.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryforums.com/general-blackberry-discussion/4661-blackberry-glossary.html#post34233"&gt;The BlackBerry Glossary&lt;/a&gt;&lt;/strong&gt;: Find out what various acronyms stand for in this BlackBerry Glossary.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://209.85.173.104/search?q=cache:LYJJiCT38_IJ:www.dmhotline.com/DMHotline/pdf/QR%2520BlackBerry%2520Disaster%2520Recovery.pdf+blackberry+%22quick+reference%22&amp;amp;hl=en&amp;amp;ct=clnk&amp;amp;cd=13&amp;amp;gl=us&amp;amp;client=firefox-a"&gt;BlackBerry PIN Quick-Reference Guide&lt;/a&gt;&lt;/strong&gt;: Have everything you need to know about BlackBerry PINs handy with this guide.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberrytips.net/tips.php?id=130"&gt;Hot Keys: View Word Document&lt;/a&gt;&lt;/strong&gt;: Use these hot keys when working in Word.&lt;/li&gt;&lt;/ol&gt;  &lt;p&gt;&lt;strong&gt;Tools&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Put these tools to work on your BlackBerry for loads of increased functionality.&lt;/p&gt;  &lt;ol start="89"&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberryfaq.com/index.php/BlackBerry_Operating_System_Downloads"&gt;BlackBerry Operating System Downloads&lt;/a&gt;&lt;/strong&gt;: Find places to download a new OS here.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.thebogles.com/berry_bloglines.html"&gt;Berry Bloglines&lt;/a&gt;&lt;/strong&gt;: Access Bloglines from your BlackBerry device using this RSS reader.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.google.com/gmm/bes"&gt;Google Maps Mobile&lt;/a&gt;&lt;/strong&gt;: Get traffic, listings, maps and more with Google Maps for your BlackBerry.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.rovemobile.com/products/mdt/"&gt;Mobile Desktop&lt;/a&gt;&lt;/strong&gt;: With this software, you can access your desktop PC from anywhere using your BlackBerry.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://store.blackberrycool.com/product.asp?id=9970"&gt;Mobylo! MultiAlarm&lt;/a&gt;&lt;/strong&gt;: Get ultramanageable alarms with this neat tool.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://store.blackberrycool.com/product.asp?id=12708"&gt;Black &amp;amp; Whitelist&lt;/a&gt;&lt;/strong&gt;: Keep harassing phone calls at bay using this blacklist application for the BlackBerry.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.tryphone.com/"&gt;TryPhone&lt;/a&gt;&lt;/strong&gt;: If you're shopping for a BlackBerry, use TryPhone to find out exactly how your model will function.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Naggie&lt;/strong&gt;: This reminder application works with your BlackBerry's GPS to nag you about tasks when you get close to a location.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.google.com/mobile/sync/index.html"&gt;Google Mobile&lt;/a&gt;&lt;/strong&gt;: Sync up your Google Calendar and more with this service.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.cerience.com/products/pro/blackberry/index.htm"&gt;RepliGo Professional&lt;/a&gt;&lt;/strong&gt;: Using RepliGo Professional, you can view documents as if they were on your desktop computer.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://store.blackberrycool.com/product.asp?id=12446"&gt;Empower HTML Mail Viewer&lt;/a&gt;&lt;/strong&gt;: See your emails in HTML with graphics, links and more with this tool.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.digby.com/"&gt;Digby&lt;/a&gt;&lt;/strong&gt;: Shop a number of online stores from your BlackBerry using Digby.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.skylab-mobilesystems.com/en/products/spot.html"&gt;Spot&lt;/a&gt;&lt;/strong&gt;: Get GPS on your BlackBerry with this software.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.cybershift.com/products_expense_mobile.asp"&gt;Necho Expense BlackBerry Edition&lt;/a&gt;&lt;/strong&gt;: This tool makes expense reports a breeze.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://splashdata.com/splashid/blackberry/index.htm"&gt;Secure Password Manager&lt;/a&gt;&lt;/strong&gt;: With this manager, you can safely store all of your important passwords and numbers on your BlackBerry.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberrycool.com/bbsoftware/games/1145244746.zip"&gt;BBTetris&lt;/a&gt;&lt;/strong&gt;: Entertain yourself with this classic game for the BlackBerry (link opens download folder).&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.processtext.com/abcblackberry.html"&gt;ABC Amber BlackBerry Convertor&lt;/a&gt;&lt;/strong&gt;: Transfer contacts, emails, logs and lots more onto your desktop computer with this convertor.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.iskoot.com/register.php?device=NoDevice"&gt;iSkoot&lt;/a&gt;&lt;/strong&gt;: Use this Skype client to get cheap calls on your BlackBerry.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://store.blackberrycool.com/product.asp?id=849"&gt;IM+ All-in-One Mobile Messenger&lt;/a&gt;&lt;/strong&gt;: IM on several different accounts and applications with this neat tool.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.microstrategy.com/IntroToMobile"&gt;MicroStrategy Mobile&lt;/a&gt;&lt;/strong&gt;: MicroStrategy Mobile automatically reformats documents so that they can be easily viewed on your BlackBerry.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.rovemobile.com/products/ssh/"&gt;Mobile SSH&lt;/a&gt;&lt;/strong&gt;: Get access to your server from your BlackBerry using this cool tool.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.livesearchmobile.com/blackberry.htm"&gt;Windows Live Search Mobile&lt;/a&gt;&lt;/strong&gt;: Get local information, maps and searching capabilities with Windows Live Search Mobile.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberrycool.com/bbsoftware/utils/StockviewInstall.zip"&gt;StockView&lt;/a&gt;&lt;/strong&gt;: Track stock prices with this free viewer (link opens download folder).&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://software.crackberry.com/product.asp?id=10209"&gt;Translator+&lt;/a&gt;&lt;/strong&gt;: Use this tool to get easy foreign translations on the go.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberrycool.com/bbsoftware/utils/beamberry_200_42.zip"&gt;BeamBerry&lt;/a&gt;&lt;/strong&gt;: Make your BlackBerry compatible with PDFs, Word documents, text files and more with this software (link opens download folder).&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://thebogles.com/berry/beyond411"&gt;Beyond411&lt;/a&gt;&lt;/strong&gt;: Get supercharged 411 listings using Beyond411, a service that gives you local prices, listings and GPS searches.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.blackberrycool.com/2007/10/03/005761/"&gt;BlackBerry Unite!&lt;/a&gt;&lt;/strong&gt;: Collaborate with up to five users by sharing remote access, calendars, documents and more with BlackBerry Unite!.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://backpackit.com/mob"&gt;Backpack Mobile&lt;/a&gt;&lt;/strong&gt;: Get organized on the go with Backback for the BlackBerry.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://sourceforge.net/projects/blackberrytools/"&gt;BlackBerry Tools&lt;/a&gt;&lt;/strong&gt;: In this suite of BlackBerry tools, you'll find a number of useful applications.&lt;/li&gt;&lt;/ol&gt;  &lt;p&gt;&lt;strong&gt;Books&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Find out even more in-depth tips and hacks in these BlackBerry reference books.&lt;/p&gt;  &lt;ol start="118"&gt;&lt;li&gt;&lt;strong&gt;"&lt;a href="http://www.oreilly.com/catalog/blackberryhks/"&gt;BlackBerry Hacks&lt;/a&gt;"&lt;/strong&gt;: You'll learn how to supercharge your BlackBerry with this book.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;"&lt;a href="http://www.amazon.com/dp/0764589539?tag=gamegamegamep-20&amp;amp;camp=14573&amp;amp;creative=327641&amp;amp;linkCode=as1&amp;amp;creativeASIN=0764589539&amp;amp;adid=191EVBXN7J7GVY4QYCC5&amp;amp;"&gt;Professional BlackBerry&lt;/a&gt;"&lt;/strong&gt;: Learn how to extend your BlackBerry's functionality, get maximum uptime and more in this book.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;"&lt;a href="http://www.amazon.com/Hacking-BlackBerry-ExtremeTech-Glenn-Bachmann/dp/0471793043"&gt;Hacking BlackBerry: Extreme Tech&lt;/a&gt;"&lt;/strong&gt;: This book discusses some of the many ways that you can hack your BlackBerry.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;"&lt;a href="http://www.amazon.com/How-Everything-Your-BlackBerry-Second/dp/0072255870/ref=pd_sim_b_title_1"&gt;How to Do Everything with Your BlackBerry&lt;/a&gt;"&lt;/strong&gt;: Take your BlackBerry way beyond email with this book.&lt;/li&gt;&lt;/ol&gt;         &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-2582609818015567028?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/2582609818015567028/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=2582609818015567028' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/2582609818015567028'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/2582609818015567028'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2008/11/power-users-blackberry-guide-121.html' title='The Power User&apos;s BlackBerry Guide: 121 CrackBerry Tips'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-6627572323146799949</id><published>2008-11-11T14:19:00.000-08:00</published><updated>2008-11-11T14:22:05.239-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Forex'/><title type='text'>Pegged-To-Primary Orders</title><content type='html'>&lt;h1&gt;Pegged-To-Primary Orders&lt;/h1&gt;    &lt;div class="cellheader"&gt;Description&lt;/div&gt; &lt;p&gt;A Pegged-to-Primary Order allows you to enter a more aggressive price than the current market price, and have the entered price stay within a fixed interval to the market, should prices deteriorate. A Buy order is pegged to the bid (instead of the best offer) and a Sell order is pegged to the offer. You can enter an offset amount that is added to a buy order price and subtracted from a sell price.&lt;/p&gt; &lt;p&gt;For a buy order, the order is submitted at the best bid, with the offset amount (if used) added to the best bid. If the best bid moves before the order executes, your order price is modified to match to the new best bid with the offset amount added. &lt;/p&gt; &lt;p&gt;For a sell order, the order is submitted at the best offer, with the offset amount (if used) subtracted from the best offer. If the best offer moves before the order executes, your order price is modified to match to the new best offer, with the offset amount subtracted.&lt;/p&gt;  &lt;div class="CellHeader"&gt;TWS Links&lt;/div&gt; &lt;p&gt;For information on how to create Pegged-to-Primary orders, please refer to the &lt;a href="http://www.interactivebrokers.com/en/software/tws/usersguidebook/ordertypes/relative_pegged-to-primary.htm" target="_blank"&gt;TWS User's Guide&lt;/a&gt;. &lt;/p&gt; &lt;div class="CellHeader"&gt;Example&lt;/div&gt;          This order type is less aggressive than the pegged-to-market order.&lt;br /&gt;  &lt;br /&gt;If the market is $50-50.10 and a customer enters a pegged-to-primary buy with an offset of $.05, the order would be submitted at the NBB + offset amount, or $50.05. If the NBB moves to $50.10, your order is resubmitted at $50.15 (NBB + offset of $.05). If the NBB drops to $50.05, the buy order is resubmitted at $50.10.&lt;br /&gt;  &lt;br /&gt;   &lt;div align="center"&gt;&lt;img src="http://www.interactivebrokers.com/images/common/orders/peggedPrimary.gif" alt="" width="267" height="137" /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-6627572323146799949?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/6627572323146799949/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=6627572323146799949' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/6627572323146799949'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/6627572323146799949'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2008/11/pegged-to-primary-orders.html' title='Pegged-To-Primary Orders'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-5482517333387602561</id><published>2008-11-11T14:10:00.000-08:00</published><updated>2008-11-11T14:19:45.296-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Forex'/><title type='text'>"SMO (stop market order)" and "SLO (stop limit order)"</title><content type='html'>&lt;p&gt;Dear all, &lt;/p&gt;&lt;p&gt;This is a question with regard to the way to handle the following type of orders in FIX:&lt;br /&gt;"SMO (stop market order)" and "SLO (stop limit order)"&lt;br /&gt;Does anybody know the usage of FIX tags for the orders??? &lt;/p&gt;&lt;p&gt;==================&lt;br /&gt;1.Stop Market Order&lt;br /&gt;A market order to buy or sell a certain quantity of a certain security if a specified price (the stop price) is reached or passed. The stop price must be below (above) the current price if the order is a sell (buy). &lt;/p&gt;&lt;p&gt;2.Stop Limit Order&lt;br /&gt;This is a limit order to buy or sell at the specified limit price if the specified stop price is reached or passed. The stop price must be below (above) the current price if the order is a sell (buy).&lt;br /&gt;================== &lt;/p&gt;&lt;p&gt;#The direct reason is the 2nd biggest Japanese exchange market, OSE #Osaka Exchange Market)announced to adopt this type of order though... &lt;/p&gt;&lt;p&gt;I would be really happy if I get clues for this. &lt;/p&gt;&lt;p&gt;Best,&lt;br /&gt;Hiromasa&lt;/p&gt;&lt;p&gt;************************************************************************************&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Hiromasa, &lt;/p&gt;&lt;p&gt;In FIX 4.4:&lt;br /&gt;- a stop order is indicated using the OrdType (40) = 3 (Stop)&lt;br /&gt;- a stop limit order is indicated using OrdType (40) = 4 (Stop limit) &lt;/p&gt;&lt;p&gt;The stop price is carried in the StopPx (99) tag (required for OrdType = 3 and 4). &lt;/p&gt;&lt;p&gt;Good luck!&lt;br /&gt;&lt;/p&gt;&lt;p&gt;************************************************************************************&lt;/p&gt;&lt;p&gt;Hi K. Mahesh, &lt;/p&gt;&lt;p&gt;Yes, it requires three prices.&lt;br /&gt;The following is an example of "SLO" what Osaka Stock Exchange calls. &lt;/p&gt;&lt;p&gt;0) Current market condition&lt;br /&gt;Market price: JPY 11,460&lt;br /&gt;Code: Nikkei 225 &lt;/p&gt;&lt;p&gt;1) A trader orders a buy �Stop Limit Order�. On this occasion, she/he must indicate �limit price�, �trigger price� and �new price� in advance. &lt;/p&gt;&lt;p&gt;e.g.)&lt;br /&gt;Limit price: JPY 11,420&lt;br /&gt;Trigger Price: JPY 11,470&lt;br /&gt;New price: JPY 11,480 &lt;/p&gt;&lt;p&gt;2) Market price moves up to the �trigger price�. (by other participants) &lt;/p&gt;&lt;p&gt;3) Then, the first order is automatically changed to �new price�. (JPY 11,420 --&gt; JPY 11,480) &lt;/p&gt;&lt;p&gt;Is it clear? &lt;/p&gt;&lt;p&gt;I probably will use custom tags for this order. &lt;/p&gt;&lt;p&gt;Thanks,&lt;br /&gt;Hiromasa &lt;/p&gt;&lt;p&gt;************************************************************************************&lt;/p&gt;&lt;p&gt;Hi again Hiromasa, &lt;/p&gt;&lt;p&gt;I assume your stop orders are executable even before the stop price is reached (a kind of "Limit Stop Limit" or "Limit Stop" order that just changes price when the stop price is reached). &lt;/p&gt;&lt;p&gt;That third price (the new limit price) is currently not in FIX. However, there is a proposal which covers it (and a number of other issues). It is currently posted at the GTC page: &lt;a target="_blank" href="http://www.fixprotocol.org/documents/2442/ReserveOrd-PegInst-OrderTriggers%20proposal.pdf"&gt;http://www.fixprotocol.org/documents/2442/ReserveOrd-PegInst-OrderTriggers%20proposal.pdf&lt;/a&gt; &lt;/p&gt;&lt;p&gt;A modified version of the proposal is expected to be published any day as part of the "OMX Order Routing Requirements". Hopefully it can be added to a service pack later this year. &lt;/p&gt;&lt;p&gt;Regards &lt;/p&gt;&lt;p&gt;Rikard &lt;/p&gt;&lt;p&gt;************************************************************************************&lt;/p&gt;&lt;p&gt;************************************************************************************&lt;/p&gt;&lt;p&gt;************************************************************************************&lt;/p&gt;&lt;p&gt;************************************************************************************&lt;/p&gt;&lt;p&gt;************************************************************************************&lt;/p&gt;&lt;p&gt;************************************************************************************&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-5482517333387602561?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/5482517333387602561/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=5482517333387602561' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/5482517333387602561'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/5482517333387602561'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2008/11/smo-stop-market-order-and-slo-stop.html' title='&quot;SMO (stop market order)&quot; and &quot;SLO (stop limit order)&quot;'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-7895102438434629084</id><published>2008-10-24T07:26:00.001-07:00</published><updated>2008-10-24T07:26:41.490-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Forex'/><title type='text'>Automated Forex Execution Software  Directory Menu Automated Execution Software Forex Blogs Forex Brokers Central Banks Charting Software Contests Dat</title><content type='html'>&lt;span style="font-family:verdana;font-size:85%;"&gt;&lt;span class="class2"&gt;&lt;h1&gt;Automated Forex Execution Software&lt;/h1&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;p&gt;&lt;!--1st anchor link and menu --&gt;  &lt;span style="font-size:85%;"&gt;&lt;a href="http://www.goforex.net/forex-directory.htm" onclick="return clickreturnvalue()" onmouseover="dropdownmenu(this, event, 'anylinkmenu1')"&gt;Directory Menu&lt;/a&gt;    &lt;/span&gt;&lt;/p&gt;&lt;div style="visibility: hidden; left: 189px; top: 0px;" id="anylinkmenu1" class="anylinkcss"&gt; &lt;span style="font-size:85%;"&gt;&lt;a href="http://www.goforex.net/forex-directory/automated-forex.htm"&gt;Automated Execution Software&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/forex-blogs.htm"&gt;Forex Blogs&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/forex-brokers.htm"&gt;Forex Brokers&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/central-banks.htm"&gt;Central Banks&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/forex-software.htm"&gt;Charting Software&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/forex-contests.htm"&gt;Contests&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/forex-data.htm"&gt;Data&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/forex-education.htm"&gt;Education&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/financial-directories.htm"&gt;Financial Portals &amp;amp; Directories&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/forex-forums.htm"&gt;Forex Forums&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/forex-resources.htm"&gt;General Resources&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/forex-guides.htm"&gt;Forex Guides&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/forex-magazines.htm"&gt;Forex Magazines &amp;amp; Publications&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/managed-forex.htm"&gt;Managed Accounts&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/forex-news.htm"&gt;News Feeds&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/forex-newsletters.htm"&gt;Forex Newsletters&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/forex-portals.htm"&gt;Forex Portals&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/forex-programmers.htm"&gt;Forex Programmers&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/proprietary-forex.htm"&gt;Proprietary Trading&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/forex-regulation.htm"&gt;Regulatory Bodies &amp;amp; Associations&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/forex-search.htm"&gt;Forex Search Engines&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/stocks-futures.htm"&gt;Stocks &amp;amp; Futures&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/forex-tools.htm"&gt;Tools&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/forex-training.htm"&gt;Training&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/forex-signals.htm"&gt;Trading Signals&lt;/a&gt; &lt;a href="http://www.goforex.net/forex-directory/forex-trading-systems.htm"&gt;Forex Trading Systems&lt;/a&gt; &lt;/span&gt;&lt;/div&gt; &lt;span style="font-size:85%;"&gt;&lt;li&gt;&lt;a href="http://www.goforex.net/forex-programming.htm"&gt;GoForex&lt;/a&gt; - GoForex offers third-party programming services for system design and automation of your strategy into any major broker, custom designed automated trading platforms, or complete turn-key technical solutions for setting up your own brokerage with a MetaTrader to ECN bridge. &lt;a href="http://www.goforex.net/forex-programming.htm"&gt;Click Here for More&lt;/a&gt; &lt;ul&gt;&lt;li&gt;&lt;a href="http://www.fxtradestream.com/" target="_blank"&gt;FXTradeStream&lt;/a&gt; - Takes signals from emails and executes them in the MetaTrader platform. &lt;/li&gt;&lt;li&gt;&lt;a href="http://www.hypertrader.it/hyperorder.shtml" target="_blank"&gt;HyperOrder&lt;/a&gt; - Takes signals from TradeStation, MetaStock, ESignal or a custom application and sends them to a broker's API including FXCM, MB Trading, MetaTrader, Interactive Brokers and more. &lt;/li&gt;&lt;li&gt;&lt;a href="http://www.metaquotes.net/" target="_blank"&gt;MetaTrader 4&lt;/a&gt; - Run automated systems and execute them into supporting brokers &lt;/li&gt;&lt;li&gt;&lt;a href="http://tickquest.com/NeoTicker/automatedtrading.html" target="_blank"&gt;Neoticker&lt;/a&gt; - Create automated systems and execute them into MB Trading, Interactive Brokers or FXCM  &lt;/li&gt;&lt;li&gt;&lt;a href="http://www.ninjatrader.com/" target="_blank"&gt;NinjaTrader&lt;/a&gt; - Sends signals from TradeStation, ESignal or a custom application into Interactive Brokers, MB Trading or Gain Capital &lt;/li&gt;&lt;li&gt;&lt;a href="http://www.roboticforex.com/" target="_blank"&gt;Robotic Forex&lt;/a&gt; - Executes systems into MB Trading, CMS Forex, FXCM and more. &lt;/li&gt;&lt;li&gt;&lt;a href="http://www.snapdragon.co.uk/" target="_blank"&gt;SnapDragon&lt;/a&gt; - Sends signals from TradeStation to Oanda's API &lt;/li&gt;&lt;li&gt;&lt;a href="http://www.thinkingstuff.com/" target="_blank"&gt;Thinking Stuff&lt;/a&gt; - Backtest and automate your trading system into Gain Capital and Oanda with the click of a mouse. No programming knowledge required. &lt;/li&gt;&lt;li&gt;&lt;a href="http://www.investlabs.com/tradebolt.htm" target="_blank"&gt;Trade Bolt&lt;/a&gt; - Takes signals from TradeStation, ESignal, MetaStock or WealthBuilder and sends them to Interactive Brokers &lt;/li&gt;&lt;li&gt;&lt;a href="http://www.tradebullet.com/" target="_blank"&gt;TradeBullet&lt;/a&gt; - Sends orders from TradeStation, eSignal and custom applications into Interactive Brokers and MB Trading &lt;/li&gt;&lt;li&gt;&lt;a href="http://www.scalper.co.uk/" target="_blank"&gt;TradeCompanion&lt;/a&gt; - Automates your trading systems written in TradeStation, Excel, Visual Basic or any other proprietary platform and executes them into the BGCFX trading platform. &lt;/li&gt;&lt;li&gt;&lt;a href="http://www.tradeitself.com/" target="_blank"&gt;TradeItself&lt;/a&gt; - Takes trading signals from emails and sends them to the FXCM Trading Station &lt;/li&gt;&lt;li&gt;&lt;a href="http://www.trade-commander.org/twslink/twslink.htm" target="_blank"&gt;TWS Link&lt;/a&gt; - Sends signals from TradeStation, ESignal, MetaTrader and more to the Interactive Brokers trading platform  &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1459919476916734020-7895102438434629084?l=codemonkeyan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codemonkeyan.blogspot.com/feeds/7895102438434629084/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1459919476916734020&amp;postID=7895102438434629084' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/7895102438434629084'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1459919476916734020/posts/default/7895102438434629084'/><link rel='alternate' type='text/html' href='http://codemonkeyan.blogspot.com/2008/10/automated-forex-execution-software.html' title='Automated Forex Execution Software  Directory Menu Automated Execution Software Forex Blogs Forex Brokers Central Banks Charting Software Contests Dat'/><author><name>Yan</name><uri>http://www.blogger.com/profile/16351544741740517251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1459919476916734020.post-3622327371420314311</id><published>2008-09-03T08:27:00.001-07:00</published><updated>2008-09-03T08:27:59.239-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technique'/><title type='text'>The Java IAQ: Infrequently Answered Questions by Peter Norvig Q: What is an Infrequently Answered Question? A question is infrequently answered either</title><content type='html'>&lt;span style="color:brown;"&gt; &lt;h1&gt;The Java IAQ:&lt;br /&gt;Infrequently Answered Questions&lt;/h1&gt;  &lt;h2&gt;by Peter Norvig&lt;/h2&gt; &lt;/span&gt;   &lt;hr /&gt; &lt;h2&gt;&lt;span style="color:brown;"&gt;&lt;a name="iaq"&gt;Q:&lt;/a&gt; What is an Infrequently  Answered Question?&lt;/span&gt;&lt;/h2&gt;  A question is infrequently answered either because few people know the  answer or because it is about an obscure, subtle point (but a point that may be crucial to you).  I thought I had invented the term, but it also shows up at the very  informative &lt;a href="http://about.com/culture/urbanlegends/library/weekly/aa082497.htm"&gt; About.com Urban Legends&lt;/a&gt; site.  There are lots of Java FAQs around, but this is the only Java IAQ. (There are a few Infrequently &lt;i&gt;Asked&lt;/i&gt; Questions lists, including a satirical one on &lt;a href="http://www.plethora.net/%7Eseebs/faqs/c-iaq.html"&gt;C&lt;/a&gt;.)  &lt;hr /&gt; &lt;h2&gt;&lt;span style="color:brown;"&gt;&lt;a name="finally"&gt;Q:&lt;/a&gt;The code in a &lt;tt&gt;finally&lt;/tt&gt; clause will never fail to execute, right?&lt;/span&gt;&lt;/h2&gt;  Well, hardly ever.  But here's an example where the &lt;tt&gt;finally&lt;/tt&gt; code will not execute, regardless of the value of the boolean &lt;tt&gt;choice&lt;/tt&gt;:  &lt;p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt;&lt;pre&gt;  try {&lt;br /&gt;   if (choice) {&lt;br /&gt;     while (true) ;&lt;br /&gt;   } else {&lt;br /&gt;     System.exit(1);&lt;br /&gt;   }&lt;br /&gt; } finally {&lt;br /&gt;   code.to.cleanup();&lt;br /&gt; }&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p&gt;   &lt;/p&gt;&lt;hr /&gt; &lt;h2&gt;&lt;span style="color:brown;"&gt;&lt;a name="this.class"&gt;Q:&lt;/a&gt;Within a method &lt;tt&gt;m&lt;/tt&gt; in a class &lt;tt&gt;C&lt;/tt&gt;, isn't &lt;tt&gt;this.getClass()&lt;/tt&gt; always &lt;tt&gt;C&lt;/tt&gt;?&lt;/span&gt;&lt;/h2&gt;  No.  It's possible that for some object &lt;tt&gt;x&lt;/tt&gt; that is an instance of some subclass &lt;tt&gt;C1&lt;/tt&gt; of &lt;tt&gt;C&lt;/tt&gt; either there is no &lt;tt&gt;C1.m()&lt;/tt&gt; method, or some method on &lt;tt&gt;x&lt;/tt&gt; called &lt;tt&gt;super.m()&lt;/tt&gt;.  In either case, &lt;tt&gt;this.getClass()&lt;/tt&gt; is &lt;tt&gt;C1&lt;/tt&gt;, not &lt;tt&gt;C&lt;/tt&gt; within the body of &lt;tt&gt;C.m()&lt;/tt&gt;. If &lt;tt&gt;C&lt;/tt&gt; is &lt;tt&gt;final&lt;/tt&gt;, then you're ok.  &lt;hr /&gt;&lt;h2&gt;&lt;span style="color:brown;"&gt;&lt;a name="equals"&gt;Q:&lt;/a&gt; I defined an &lt;tt&gt;equals&lt;/tt&gt;  method, but &lt;tt&gt;Hashtable&lt;/tt&gt; ignores it.  Why?&lt;/span&gt;&lt;/h2&gt;  &lt;tt&gt;equals&lt;/tt&gt; methods are surprisingly hard to get right.  Here are the places to look first for a problem:  &lt;ol&gt;&lt;li&gt; You defined the wrong &lt;tt&gt;equals&lt;/tt&gt; method.  For example, you wrote:  &lt;p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt;&lt;pre&gt;public class &lt;b&gt;C&lt;/b&gt; {&lt;br /&gt; public boolean &lt;b&gt;equals&lt;/b&gt;(&lt;b&gt;C&lt;/b&gt; that) { return id(this) == id(that); }&lt;br /&gt;}&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p&gt;  But in order for &lt;tt&gt;table.get(c)&lt;/tt&gt; to work you need to make the &lt;tt&gt;equals&lt;/tt&gt; method take an &lt;tt&gt;Object&lt;/tt&gt; as the argument, not a &lt;tt&gt;C&lt;/tt&gt;:  &lt;/p&gt;&lt;p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt;&lt;pre&gt;public class &lt;b&gt;C&lt;/b&gt; {&lt;br /&gt; public boolean &lt;b&gt;equals&lt;/b&gt;(&lt;b&gt;Object&lt;/b&gt; that) {&lt;br /&gt;   return (that instanceof C) &amp;amp;&amp;amp; id(this) == id((C)that);&lt;br /&gt; }&lt;br /&gt;}&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p&gt;  Why? The code for &lt;tt&gt;Hashtable.get&lt;/tt&gt; looks something like this: &lt;/p&gt;&lt;p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt;&lt;pre&gt;public class &lt;b&gt;Hashtable&lt;/b&gt; {&lt;br /&gt; public Object &lt;b&gt;get&lt;/b&gt;(Object key) {&lt;br /&gt;   Object entry;&lt;br /&gt;   ...&lt;br /&gt;   if (entry.equals(key)) ...&lt;br /&gt; }&lt;br /&gt;}&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p&gt;  Now the method invoked by &lt;tt&gt;entry.equals(key)&lt;/tt&gt; depends upon the actual run-time type of the object referenced by &lt;tt&gt;entry&lt;/tt&gt;, and the declared, compile-time type of the variable &lt;tt&gt;key&lt;/tt&gt;.  So when you as a user call &lt;tt&gt;table.get(new C(...))&lt;/tt&gt;, this looks in class &lt;tt&gt;C&lt;/tt&gt; for the &lt;tt&gt;equals&lt;/tt&gt; method with argument of type &lt;tt&gt;Object&lt;/tt&gt;.  If you happen to have defined an &lt;tt&gt;equals&lt;/tt&gt; method with argument of type &lt;tt&gt;C&lt;/tt&gt;, that's irrelevent. It ignores that method, and looks for a method with signature &lt;tt&gt;equals(Object)&lt;/tt&gt;, eventually finding &lt;tt&gt;Object.equals(Object)&lt;/tt&gt;.  If you want to over-ride a method, you need to match argument types exactly.  In some cases, you may want to have two methods, so that you don't pay the overhead of casting when you know you have an object of the right class:  &lt;/p&gt;&lt;p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt;&lt;pre&gt;public class &lt;b&gt;C&lt;/b&gt; {&lt;br /&gt; public boolean &lt;b&gt;equals&lt;/b&gt;(&lt;b&gt;Object&lt;/b&gt; that) {&lt;br /&gt;   return (this == that)&lt;br /&gt;           || ((that instanceof C) &amp;amp;&amp;amp; this.equals((C)that));&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public boolean &lt;b&gt;equals&lt;/b&gt;(&lt;b&gt;C&lt;/b&gt; that) {&lt;br /&gt;   return id(this) == id(that); // Or whatever is appropriate for class C&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p&gt;  &lt;/p&gt;&lt;/li&gt;&lt;li&gt; You didn't properly implement &lt;tt&gt;equals&lt;/tt&gt; as an equality predicate: &lt;tt&gt;equals&lt;/tt&gt; must be symmetric, transitive, and reflexive.  Symmetric means &lt;tt&gt;a.equals(b)&lt;/tt&gt; must have the same value as &lt;tt&gt;b.equals(a)&lt;/tt&gt;.  (This is the one most people mess up.) Transitive means that if &lt;tt&gt;a.equals(b)&lt;/tt&gt; and &lt;tt&gt;b.equals(c)&lt;/tt&gt; then &lt;tt&gt;a.equals(c)&lt;/tt&gt; must be true.  Reflexive means that &lt;tt&gt;a.equals(a)&lt;/tt&gt; must be true, and is the reason for the &lt;tt&gt;(this == that)&lt;/tt&gt; test above (it's also often good practice to include this because of efficiency reasons: testing for &lt;tt&gt;==&lt;/tt&gt; is faster than looking at all the slots of an object, and to partially break the recursion problem on objects that might have circular pointer chains).  &lt;/li&gt;&lt;li&gt; You forgot the &lt;tt&gt;hashCode&lt;/tt&gt; method.  Anytime you define a &lt;tt&gt;equals&lt;/tt&gt; method, you should also define a &lt;tt&gt;hashCode&lt;/tt&gt; method.  You must make sure that two &lt;tt&gt;equal&lt;/tt&gt; objects have the same hashCode, and if you want better hashtable performance, you should try to make most non-equal objects have different hashCodes.  Some classes cache the hash code in a private slot of an object, so that it need be computed only once.  If that is the case then you will probably save time in &lt;tt&gt;equals&lt;/tt&gt; if you include a line that says &lt;tt&gt;if (this.hashSlot != that.hashSlot) return false&lt;/tt&gt;.  &lt;/li&gt;&lt;li&gt; You didn't handle inheritance properly.  First of all, consider if two objects of different class can be equal.  Before you say "NO! Of course not!"  consider a class &lt;tt&gt;Rectangle&lt;/tt&gt; with &lt;tt&gt;width&lt;/tt&gt; and &lt;tt&gt;height&lt;/tt&gt; fields, and a &lt;tt&gt;Box&lt;/tt&gt; class, which has the above two fields plus &lt;tt&gt;depth&lt;/tt&gt;.  Is a Box with &lt;tt&gt;depth == 0&lt;/tt&gt; equal to the equivalent Rectangle?  You might want to say yes.  If you are dealing with a non-&lt;tt&gt;final&lt;/tt&gt; class, then it is possible that your class might be subclassed, and you will want to be a good citizen with respect to your subclass.  In particular, you will want to allow an extender of your class &lt;tt&gt;C&lt;/tt&gt; to use your &lt;tt&gt;C.equals&lt;/tt&gt; method using &lt;tt&gt;super&lt;/tt&gt; as follows:  &lt;p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt;&lt;pre&gt;public class C2 extends C {&lt;br /&gt;&lt;br /&gt; int newField = 0;&lt;br /&gt;&lt;br /&gt; public boolean &lt;b&gt;equals&lt;/b&gt;(Object that) {&lt;br /&gt;   if (this == that) return true;&lt;br /&gt;   else if (!(that instanceof C2)) return false;&lt;br /&gt;   else return this.newField == ((C2)that).newField &amp;amp;&amp;amp; &lt;b&gt;super&lt;/b&gt;.equals(that);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;} &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p&gt;  To allow this to work, you have to be careful about how you treat classes in your definition of &lt;tt&gt;C.equals&lt;/tt&gt;.  For example, check for &lt;tt&gt;that instanceof C&lt;/tt&gt; rather than &lt;tt&gt;that.getClass() == C.class&lt;/tt&gt;.  See the previous IAQ question to learn why. Use &lt;tt&gt;this.getClass() == that.getClass()&lt;/tt&gt; if you are sure that two objects must be of the same class to be considered equals.  &lt;/p&gt;&lt;/li&gt;&lt;li&gt; You didn't handle circular references properly.  Consider:  &lt;p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt;&lt;pre&gt;public class LinkedList {&lt;br /&gt;&lt;br /&gt; Object contents;&lt;br /&gt; LinkedList next = null;&lt;br /&gt;&lt;br /&gt; public boolean &lt;b&gt;equals&lt;/b&gt;(Object that) {&lt;br /&gt;   return (this == that)&lt;br /&gt;     || ((that instanceof LinkedList) &amp;amp;&amp;amp; this.equals((LinkedList)that));&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public boolean &lt;b&gt;equals&lt;/b&gt;(LinkedList that) { // Buggy!&lt;br /&gt;  return Util.equals(this.contents, that.contents) &amp;amp;&amp;amp;&lt;br /&gt;         Util.equals(this.next, that.next);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;} &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p&gt;  Here I have assumed there is a &lt;tt&gt;Util&lt;/tt&gt; class with:  &lt;/p&gt;&lt;p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt;&lt;pre&gt;  public static boolean &lt;b&gt;equals&lt;/b&gt;(Object x, Object y) {&lt;br /&gt;   return (x == y) || (x != null &amp;amp;&amp;amp; x.equals(y));&lt;br /&gt; } &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p&gt;  I wish this method were in &lt;tt&gt;Object&lt;/tt&gt;; without it you always have to  throw in tests against null.  Anyway, the &lt;tt&gt;LinkedList.equals&lt;/tt&gt; method will never return if asked to compare  two LinkedLists with circular references in them (a pointer from one element of the linked list back to another element). See the description of the Common Lisp function &lt;a href="http://www.harlequin.com/support/books/HyperSpec/Body/fun_list-length.html#list-length"&gt;&lt;tt&gt;list-length&lt;/tt&gt;&lt;/a&gt; for an explanation of how to handle this problem in linear time with only  two words of extra storge.  (I don't give the answer here in case you want to try to figure it out for yourself first.)  &lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;hr /&gt; &lt;h2&gt;&lt;span style="color:brown;"&gt;&lt;a name="super"&gt;Q:&lt;/a&gt; I tried to forward a method to super, but it occasionally doesn't work.  Why?&lt;/span&gt;&lt;/h2&gt;  This is the code in question, simplified for this example:  &lt;p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt;&lt;pre&gt;/** A version of Hashtable that lets you do&lt;br /&gt;* table.put("dog", "canine");, and then have&lt;br /&gt;* table.get("dogs") return "canine". **/&lt;br /&gt;&lt;br /&gt;public class &lt;b&gt;HashtableWithPlurals&lt;/b&gt; extends Hashtable {&lt;br /&gt;&lt;br /&gt; /** Make the table map both key and key + "s" to value. **/&lt;br /&gt; public Object &lt;b&gt;put&lt;/b&gt;(Object key, Object value) {&lt;br /&gt;   super.put(key + "s", value);&lt;br /&gt;   return super.put(key, value);&lt;br /&gt; }&lt;br /&gt;}&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p&gt;  You need to be careful when passing to super that you fully understand what the super method does.  In this case, the contract for &lt;tt&gt;Hashtable.put&lt;/tt&gt; is that it will record a mapping between the key and the value in the table.  However, if the hashtable gets too full, then &lt;tt&gt;Hashtable.put&lt;/tt&gt; will allocate a larger array for the table, copy all the old objects over, and then recursively re-call &lt;tt&gt;table.put(key, value)&lt;/tt&gt;.  Now, because Java resolves methods based on the runtime type of the target, in our example this recursive call within the code for Hashtable will go to &lt;tt&gt;HashtableWithPlurals.put(key, value)&lt;/tt&gt;, and the net result is that occasionally (when the size of the table overflows at just the wrong time), you will get an entry for "dogss" as well as for "dogs" and "dog".  Now, does it state anywhere in the documentation for &lt;tt&gt;put&lt;/tt&gt; that doing this recursive call is a possibility? No.  In cases like this, it sure helps to have source code access to the JDK.   &lt;/p&gt;&lt;hr /&gt;  &lt;h2&gt;&lt;span style="color:brown;"&gt;&lt;a name="prop"&gt;Q:&lt;/a&gt; Why does my Properties object ignore the defaults when I do a &lt;tt&gt;get&lt;/tt&gt;?&lt;/span&gt;&lt;/h2&gt;  You shouldn't do a &lt;tt&gt;get&lt;/tt&gt; on a Properties object; you should do a &lt;tt&gt;getProperty&lt;/tt&gt; instead.  Many people assume that the only difference is that &lt;tt&gt;getProperty&lt;/tt&gt; has a declared return type of String, while &lt;tt&gt;get&lt;/tt&gt; is declared to return an Object.  But actually there is a bigger difference: &lt;tt&gt;getProperty&lt;/tt&gt; looks at the defaults. &lt;tt&gt;get&lt;/tt&gt; is inherited from Hashtable, and it ignores the default, thereby doing exactly what is documented in the Hashtable class, but probably not what you expect. Other methods that are inherited from Hashtable (like isEmpty and toString) will also ignore defaults. Example code:  &lt;p&gt;&lt;table&gt; &lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt; &lt;pre&gt;Properties defaults = new Properties();&lt;br /&gt;defaults.put("color", "black");&lt;br /&gt;&lt;br /&gt;Properties props = new Properties(defaults);&lt;br /&gt;&lt;br /&gt;System.out.println(props.&lt;b&gt;get&lt;/b&gt;("color") + ", " +&lt;br /&gt;props.&lt;b&gt;getProperty&lt;/b&gt;(color));&lt;br /&gt;// This prints "&lt;b&gt;null&lt;/b&gt;, &lt;b&gt;black&lt;/b&gt;"&lt;br /&gt;&lt;/pre&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt;&lt;p&gt; Is this justified by the documentation? Maybe. The documentation in Hashtable talks about entries in the table, and the behavior of Properties is consistent if you assume that defauls are not entries in the table.  If for some reason you thought defaults were entries (as you might be led to believe by the behavior of getProperty) then you will be confused.   &lt;/p&gt;&lt;hr /&gt;  &lt;h2&gt;&lt;span style="color:brown;"&gt;&lt;a name="del"&gt;Q:&lt;/a&gt;Inheritance seems error-prone.  How can I guard against these errors?&lt;/span&gt;&lt;/h2&gt;   The previous two questions show that a programmer neeeds to be very careful when extending a class, and sometimes just in using a class that extends another class. Problems like these two lead John Ousterhout to say "Implementation inheritance causes the same intertwining and brittleness that have been observed when goto statements are overused. As a result, OO systems often suffer from complexity and lack of reuse." (&lt;i&gt;Scripting&lt;/i&gt;, IEEE Computer, March 1998) and Edsger Dijkstra to allegedly say "Object-oriented programming is an exceptionally bad idea which could only have originated in California." (from a collection of signature files).  I don't think there's a general way to insure being safe, but there are a few things to be aware of:  &lt;ul&gt;&lt;li&gt; Extending a class that you don't have source code for is always risky; the documentation may be incomplete in ways you can't foresee.  &lt;/li&gt;&lt;li&gt; Calling super tends to make these unforeseen problems jump out.  &lt;/li&gt;&lt;li&gt; You need to pay as much attention to the methods that you don't over-ride as the methods that you do.  This is one of the big fallacies of Object-Oriented design using inheritance.  It is true that inheritance lets you write less code.  But you still have to think about the code you &lt;i&gt;don't&lt;/i&gt; write.  &lt;/li&gt;&lt;li&gt; You're especially looking for trouble if the subclass changes the contract of any of the methods, or of the class as a whole. It is difficult to tell when a contract is changed, since contracts are informal (there is a formal part in the type signature, but the rest appears only in comments). In the Properties example, it is not clear if a contract is being broken, because it is not clear if the defaults are to be considered "entries" in the table or not.  &lt;/li&gt;&lt;/ul&gt;  &lt;hr /&gt;  &lt;h2&gt;&lt;span style="color:brown;"&gt;&lt;a name="del2"&gt;Q:&lt;/a&gt;What are some alternatives to  inheritance?&lt;/span&gt;&lt;/h2&gt;  &lt;i&gt;Delegation&lt;/i&gt; is an alternative to inheritance.  Delegation means that you include an instance of another class as an instance variable, and forward messages to the instance.  It is often safer than inheritance because it forces you to think about each message you forward, because the instance is of a known class, rather than a new class, and because it doesn't force you to accept all the methods of the super class: you can provide only the methods that really make sense.  On the other hand, it makes you write more code, and it is harder to re-use (because it is not a subclass).  &lt;p&gt;For the HashtableWithPlurals example, delegation would give you this (note: as of JDK 1.2, Dictionary is considered obsolete; use Map instead):  &lt;/p&gt;&lt;p&gt;&lt;table&gt; &lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt; &lt;pre&gt;/** A version of Hashtable that lets you do&lt;br /&gt;* table.put("dog", "canine");, and then have&lt;br /&gt;* table.get("dogs") return "canine". **/&lt;br /&gt;&lt;br /&gt;public class &lt;b&gt;HashtableWithPlurals&lt;/b&gt; extends Dictionary {&lt;br /&gt;&lt;br /&gt; Hashtable table = new Hashtable();&lt;br /&gt;&lt;br /&gt; /** Make the table map both key and key + "s" to value. **/&lt;br /&gt; public Object &lt;b&gt;put&lt;/b&gt;(Object key, Object value) {&lt;br /&gt;   table.put(key + "s", value);&lt;br /&gt;   return table.put(key, value);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; ... // Need to implement other methods as well&lt;br /&gt;}&lt;/pre&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt;&lt;p&gt;The Properties example, if you wanted to enforce the interpretation that default values are entries, would be better done with delegation. Why was it done with inheritance, then? Because the Java implementation team was rushed, and took the course that required writing less code.  &lt;/p&gt;&lt;hr /&gt;  &lt;h2&gt;&lt;span style="color:brown;"&gt;&lt;a name="global"&gt;Q:&lt;/a&gt; Why are there no global  variables in Java?&lt;/span&gt;&lt;/h2&gt;  Global variables are considered bad form for a variety of reasons: &lt;ul&gt;&lt;li&gt; Adding state variables breaks referential transparency (you no longer  can understand a statement or expression on its own: you need to  understand it in the context of the settings of the global variables).   &lt;/li&gt;&lt;li&gt; State variables lessen the cohesion of a program: you need to know  more to understand how something works. A major point of Object-Oriented programming is to break up global state into more easily  understood collections of local state. &lt;/li&gt;&lt;li&gt;When you add &lt;i&gt;one&lt;/i&gt; variable, you limit the use of your program to one instance.  What you thought was global, someone else might think of as local: they may want to run two copies of your program at once. &lt;/li&gt;&lt;/ul&gt; For these reasons, Java decided to ban global variables.  &lt;hr /&gt;  &lt;h2&gt;&lt;span style="color:brown;"&gt;&lt;a name="global2"&gt;Q:&lt;/a&gt; I still miss global  variables.  What can I do instead?&lt;/span&gt;&lt;/h2&gt;  That depends on what you want to do.  In each case, you need to decide two things: how many copies of this so-called global variable do I need?  And where would be a convenient place to put it?  Here are some common  solutions: &lt;p&gt; &lt;table border="1" cellpadding="2" cellspacing="1"&gt;  &lt;tbody&gt;&lt;tr&gt;&lt;td&gt; If you really want only one copy per each time a user invokes Java by starting up a Java virtual machine, then you probably want a static instance variable.  For example, you have a MainWindow class in your application, and you want to count the number of windows that the user has opened, and initiate the "Really quit?" dialog when the user has closed the last one.  For that, you want:  &lt;/td&gt;&lt;td bgcolor="#c0c0c0"&gt; &lt;pre&gt;// &lt;i&gt;One variable per class (per JVM)&lt;/i&gt;&lt;br /&gt;public Class MainWindow {&lt;br /&gt; &lt;b&gt;static int numWindows&lt;/b&gt; = 0;&lt;br /&gt; ...&lt;br /&gt; // when opening: &lt;b&gt;MainWindow.numWindows++&lt;/b&gt;; &lt;br /&gt; // when closing: &lt;b&gt;MainWindow.numWindows--&lt;/b&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;  &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt; In many cases, you really want a class instance variable. For example, suppose you wrote a web browser and wanted to have the history list as a global variable.  In Java, it would make more sense to have the history list be an instance variable in the Browser class. Then a user could run two copies of the browser at once, in the same JVM, without having them step on each other.  &lt;/td&gt;&lt;td bgcolor="#c0c0c0"&gt; &lt;pre&gt;// &lt;i&gt;One variable per instance&lt;/i&gt;&lt;br /&gt;public class Browser {&lt;br /&gt; &lt;b&gt;HistoryList history&lt;/b&gt; = new HistoryList();&lt;br /&gt; ...&lt;br /&gt; // Make entries in &lt;b&gt;this.history&lt;/b&gt;&lt;br /&gt;}&lt;/pre&gt;    &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt; Now suppose that you have completed the design and most of the implementation of your browser, and you discover that, deep down in the details of, say, the Cookie class, inside the Http class, you want to display an error message.  But you don't know where to display the message.  You could easily add an instance variable to the Browser class to hold the display stream or frame, but you haven't passed the  current instance of the browser down into the methods in the Cookie class. You  don't want to change the signatures of many methods to pass the browser along. You can't use a static variable, because there might be multiple browsers running.  However, if you can guarantee that there will be only one browser running per thread (even if each browser may have multiple threads) then there is a good solution: store a table of thread-to-browser mappings as a static variable in the Browser class, and look up the right browser (and hence display) to use via the current thread:  &lt;/td&gt;&lt;td bgcolor="#c0c0c0"&gt; &lt;pre&gt;// &lt;i&gt;One "variable" per thread&lt;/i&gt;&lt;br /&gt;public class Browser {&lt;br /&gt; &lt;b&gt;static Hashtable browsers&lt;/b&gt; = new Hashtable();&lt;br /&gt; public Browser() { // Constructor&lt;br /&gt;   browsers.put(Thread.currentThread(), this);&lt;br /&gt; }&lt;br /&gt; ...&lt;br /&gt; public void reportError(String message) {&lt;br /&gt;   Thread t = Thread.currentThread();&lt;br /&gt;   ((Browser)Browser.&lt;b&gt;browsers.get(t)&lt;/b&gt;)&lt;br /&gt;     .show(message)&lt;br /&gt; }&lt;br /&gt;}&lt;/pre&gt;  &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Finally, suppose you want the value of a global variable to persist between invocations of the JVM, or to be shared among multiple JVMs in a network of machines.  Then you probably should use a database which you  access through JDBC, or you should serialize data and write it to a file. &lt;/td&gt;&lt;td&gt;  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt;&lt;hr /&gt; &lt;h2&gt;&lt;span style="color:brown;"&gt;&lt;a name="math"&gt;Q: Can I write &lt;tt&gt;sin(x)&lt;/tt&gt;  instead of &lt;tt&gt;Math.sin(x)&lt;/tt&gt;?&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;  Short answer: Before Java 1.5, no. As of Java 1.5, yes, using &lt;a href="http://java.sun.com/j2se/1.5.0/docs/guide/language/static-import.html"&gt;static imports&lt;/a&gt;; you can now write &lt;tt&gt;import static java.lang.Math.*&lt;/tt&gt; and then use &lt;tt&gt;sin(x)&lt;/tt&gt; with impunity.  But note the warning from Sun:  "So when should you use static import? &lt;b&gt;Very sparingly!&lt;/b&gt;"  &lt;p&gt;Here are some of the options that could be used before Java 1.5:  &lt;/p&gt;&lt;p&gt; &lt;table border="1" cellpadding="2" cellspacing="1"&gt; &lt;tbody&gt;&lt;tr&gt;&lt;td&gt; If you only want a few methods, you can put in calls to them within your own class: &lt;/td&gt;&lt;td bgcolor="#c0c0c0"&gt; &lt;pre&gt;public static double &lt;b&gt;sin&lt;/b&gt;(double x) { return Math.sin(x); }&lt;br /&gt;public static double &lt;b&gt;cos&lt;/b&gt;(double x) { return Math.cos(x); }&lt;br /&gt;...&lt;br /&gt;sin(x)&lt;br /&gt;&lt;/pre&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt; Static methods take a target (thing to the left of the dot) that is either a class name, or is an object whose value is ignored, but must be  declared to be of the right class.  So you could save three characters per call by  doing: &lt;/td&gt;&lt;td bgcolor="#c0c0c0"&gt; &lt;pre&gt;// Can't instantiate Math, so it must be null.&lt;br /&gt;Math m = null;&lt;br /&gt;...&lt;br /&gt;m.sin(x)&lt;br /&gt;&lt;/pre&gt;  &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;  java.lang.Math is a final class, so you can't inherit from it, but if you have your own set of static methods that you would like to share among many of your own classes, then you can package them up and inherit them:  &lt;/td&gt;&lt;td bgcolor="#c0c0c0"&gt; &lt;pre&gt;public abstract class &lt;b&gt;MyStaticMethods&lt;/b&gt; {&lt;br /&gt; public static double mysin(double x) { ... }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class &lt;b&gt;MyClass1&lt;/b&gt; extends MyStaticMethods {&lt;br /&gt; ...&lt;br /&gt; mysin(x)&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.best.com/%7Epvdl/"&gt;Peter van der Linden&lt;/a&gt;, author of &lt;i&gt;Just Java&lt;/i&gt;, recommends against both of the last two  practices in his &lt;a href="http://www.best.com/%7Epvdl/javafaq.html"&gt;FAQ&lt;/a&gt;. I agree with him that &lt;tt&gt;Math m = null&lt;/tt&gt; is a bad idea in most cases, but I'm not convinced that the &lt;tt&gt;MyStaticMethods&lt;/tt&gt; demonstrates &lt;i&gt;"very poor OOP style to use inheritance to obtain a trivial name abbreviation (rather than to express a type hierarchy)."&lt;/i&gt; First of all, trivial is in the eye of the beholder; the abbreviation may be substantial. (See &lt;a href="http://www.norvig.com/jscheme-design.html"&gt;an example&lt;/a&gt; of how I used this approach to what I thought was good effect.) Second, it is rather presumptuous to say that this is very bad &lt;i&gt;OOP&lt;/i&gt; style. You could make a case that it is bad &lt;i&gt;Java&lt;/i&gt; style, but in languages with multiple inheritance, this idiom would be more acceptable.  &lt;/p&gt;&lt;p&gt;Another way of looking at it is that features of Java (and any language) necessarily involve trade-offs, and conflate many issues. I agree it is bad to use inheritance in such a way that you mislead the user into thinking that &lt;tt&gt;MyClass1&lt;/tt&gt; is inheriting behavior from &lt;tt&gt;MyStaticMethods&lt;/tt&gt;, and it is bad to prohibit &lt;tt&gt;MyClass1&lt;/tt&gt; from extending whatever other class it really wants to extend.  But in Java the class is also the unit of encapsulation, compilation (mostly), and name scope.  The &lt;tt&gt;MyStaticMethod&lt;/tt&gt; approach scores negative points on the type hierarchy front, but positive points on the name scope front.  If you say that the type hierarchy view is more important, I won't argue with you. But I will argue if you think of a class as doing only one thing, rather than many things at once, and if you think of style guides as absolute rather than as trade-offs.  &lt;/p&gt;&lt;hr /&gt; &lt;h2&gt;&lt;span style="color:brown;"&gt;&lt;a name="null"&gt;Q:&lt;/a&gt; Is null an Object?&lt;/span&gt;&lt;/h2&gt;  Absolutely not.  By that, I mean &lt;tt&gt;(null instanceof Object)&lt;/tt&gt; is false.  Some other things you should know about &lt;tt&gt;null&lt;/tt&gt;:  &lt;ol&gt;&lt;li&gt; You can't call a method on null: &lt;tt&gt;x.m()&lt;/tt&gt; is an error when &lt;tt&gt;x&lt;/tt&gt; is null and &lt;tt&gt;m&lt;/tt&gt; is a non-static method. (When &lt;tt&gt;m&lt;/tt&gt; is a static method it is fine, because it is the class of x that matters; the value is ignored.)  &lt;/li&gt;&lt;li&gt; There is only one null, not one for each class.  Thus, &lt;tt&gt;((String) null == (Hashtable) null)&lt;/tt&gt;, for example.  &lt;/li&gt;&lt;li&gt; It is ok to pass null as an argument to a method, as long as the method is expecting it.  Some methods do; some do not.  So, for example, &lt;tt&gt;System.out.println(null)&lt;/tt&gt; is ok, but &lt;tt&gt;string.compareTo(null)&lt;/tt&gt; is not. For methods you write, your javadoc comments should say whether null is ok, unless it is obvious.  &lt;/li&gt;&lt;li&gt;In JDK 1.1 to 1.1.5, passing &lt;tt&gt;null&lt;/tt&gt; as the literal argument to a constructor of an anonymous inner class (e.g., &lt;tt&gt;new SomeClass(null) { ...}&lt;/tt&gt; caused a compiler error.  It's ok to pass an expression whose value is null, or to pass a coerced null, like &lt;tt&gt;new SomeClass((String) null) { ...}&lt;/tt&gt;  &lt;/li&gt;&lt;li&gt;There are at least three different meanings that null is commonly used  to  express: &lt;ul&gt;&lt;li&gt; Uninitialized. A variable or slot that hasn't yet been assigned its real value.  &lt;/li&gt;&lt;li&gt; Non-existant/not applicable.  For example, terminal nodes in a binary tree might be represented by a regular node with null child  pointers.  &lt;/li&gt;&lt;li&gt; Empty. For example, you might use null to represent the empty tree.  Note that this is subtly different from the previous case, although some people make the mistake of confusing the two cases.  The difference is whether null is an acceptable tree node, or whether it is a signal to not treat the value as a tree node.  Compare the following three implementations of binary tree nodes with an in-order print method:  &lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;/ol&gt;   &lt;p&gt;&lt;table cellpadding="4" cellspacing="4"&gt;&lt;tbody&gt;&lt;tr&gt;  &lt;td valign="top" bgcolor="#c0c0c0"&gt;&lt;pre&gt;// null means not applicable&lt;br /&gt;// There is no empty tree.&lt;br /&gt;&lt;br /&gt;class &lt;b&gt;Node&lt;/b&gt; {&lt;br /&gt; Object data;&lt;br /&gt; Node left, right;&lt;br /&gt;&lt;br /&gt; void &lt;b&gt;print&lt;/b&gt;() {&lt;br /&gt;   if (left != null)&lt;br /&gt;     left.print();&lt;br /&gt;   System.out.println(data);&lt;br /&gt;   if (right != null)&lt;br /&gt;     right.print();&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;  &lt;/td&gt;&lt;td valign="top" bgcolor="#c0c0c0"&gt;&lt;pre&gt;// null means empty tree&lt;br /&gt;// Note static, non-static methods&lt;br /&gt;&lt;br /&gt;class &lt;b&gt;Node&lt;/b&gt; {&lt;br /&gt; Object data;&lt;br /&gt; Node left, right;&lt;br /&gt;&lt;br /&gt; void &lt;b&gt;static print&lt;/b&gt;(Node node) {&lt;br /&gt;   if (node != null) node.print();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; void &lt;b&gt;print&lt;/b&gt;() {&lt;br /&gt;   print(left);&lt;br /&gt;   System.out.println(data);&lt;br /&gt;   print(right);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;  &lt;/td&gt;&lt;td valign="top" bgcolor="#c0c0c0"&gt;&lt;pre&gt;// Separate class for Empty&lt;br /&gt;// null is never used&lt;br /&gt;&lt;br /&gt;interface &lt;b&gt;Node&lt;/b&gt; { void print(); }&lt;br /&gt;&lt;br /&gt;class &lt;b&gt;DataNode&lt;/b&gt; implements Node{&lt;br /&gt; Object data;&lt;br /&gt; Node left, right;&lt;br /&gt;&lt;br /&gt; void &lt;b&gt;print&lt;/b&gt;() {&lt;br /&gt;   left.print();&lt;br /&gt;   System.out.println(data);&lt;br /&gt;   right.print();&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class &lt;b&gt;EmptyNode&lt;/b&gt; implements Node {&lt;br /&gt; void &lt;b&gt;print&lt;/b&gt;() { }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt;&lt;hr /&gt; &lt;h2&gt;&lt;span style="color:brown;"&gt;&lt;a name="sizeof"&gt;Q:&lt;/a&gt; How big is an Object? Why is  there no &lt;tt&gt;sizeof&lt;/tt&gt;?&lt;/span&gt;&lt;/h2&gt;  C has a &lt;tt&gt;sizeof&lt;/tt&gt; operator, and it needs to have one, because the user has to manage calls to &lt;tt&gt;malloc&lt;/tt&gt;, and because the size of primitive types (like &lt;tt&gt;long&lt;/tt&gt;) is not standardized. Java doesn't &lt;i&gt;need&lt;/i&gt; a sizeof, but it would still have been a convenient aid. Since it's not there, you can do this:  &lt;p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt;&lt;pre&gt;static Runtime runtime = Runtime.getRuntime();&lt;br /&gt;...&lt;br /&gt;long start, end;&lt;br /&gt;Object obj;&lt;br /&gt;runtime.gc();&lt;br /&gt;start = runtime.freememory();&lt;br /&gt;&lt;b&gt;obj = new Object&lt;/b&gt;(); // Or whatever you want to look at&lt;br /&gt;end =  runtime.freememory();&lt;br /&gt;System.out.println("That took " + (start-end) + "&lt;br /&gt;bytes.");&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p&gt;  This method is not foolproof, because a garbage collection could occur in  the middle of the code you are instrumenting, throwing off the byte count.   Also, if you are using a just-in-time compiler, some bytes may come from  generating code. &lt;/p&gt;&lt;p&gt; You might be surprised to find that an Object takes 16 bytes, or 4 words, in the Sun JDK VM. This breaks down as follows: There is a two-word header, where one word is a pointer to the object's class, and the other points to the instance variables.  Even though Object has no instance variables, Java still allocates one word for the variables.  Finally, there is a "handle", which is another pointer to the two-word header.  Sun says that this extra level of indirection makes garbage collection simpler. (There have been high performance Lisp and Smalltalk garbage collectors that do not use the extra level for at least 15 years. I have heard but have not confirmed that the Microsoft JVM does not have the extra level of indirection.)  &lt;/p&gt;&lt;p&gt; An empty &lt;tt&gt;new String()&lt;/tt&gt; takes 40 bytes, or 10 words: 3 words of pointer overhead, 3 words for the instance variables (the start index, end index, and character array), and 4 words for the empty char array.  Creating a substring of an existing string takes "only" 6 words, because the char array is shared. Putting an Integer key and Integer value into a Hashtable takes 64 bytes (in addition to the four bytes that were pre-allocated in the Hashtable array): I'll let  you work out why.  &lt;/p&gt;&lt;hr /&gt; &lt;h2&gt;&lt;span style="color:brown;"&gt;&lt;a name="init"&gt;Q:&lt;/a&gt; In what order is initialization code executed?  What should I put where?&lt;/span&gt;&lt;/h2&gt;  Instance variable initialization code can go in three places within a  class:  &lt;p&gt; &lt;table border="1" cellspacing="0"&gt; &lt;tbody&gt;&lt;tr&gt; &lt;td&gt; In an instance variable initializer for a class (or a superclass). &lt;/td&gt;&lt;td&gt; &lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt;&lt;pre&gt;class &lt;b&gt;C&lt;/b&gt; {&lt;br /&gt;   String &lt;b&gt;var = "val";&lt;/b&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt; &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt; &lt;td&gt; In a constructor for a class (or a superclass). &lt;/td&gt;&lt;td&gt; &lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt;&lt;pre&gt;    public &lt;b&gt;C&lt;/b&gt;() { &lt;b&gt;var = "val";&lt;/b&gt; }&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;  &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt; &lt;td&gt; In an object initializer block. This is new in Java 1.1; its just like a static initializer block but without the keyword &lt;tt&gt;static&lt;/tt&gt;. &lt;/td&gt;&lt;td&gt; &lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt;&lt;pre&gt;    &lt;b&gt;{ var = "val"; }&lt;/b&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p&gt;  The order of evaluation (ignoring out of memory problems) when you say &lt;tt&gt;new C()&lt;/tt&gt; is:  &lt;/p&gt;&lt;ol&gt;&lt;li&gt; Call a constructor for C's superclass (unless C is &lt;tt&gt;Object&lt;/tt&gt;, in which case it has no superclass).  It will always be the no-argument constructor, unless the programmer explicitly coded &lt;tt&gt;super(...)&lt;/tt&gt; as the very first statement of the constructor.  &lt;/li&gt;&lt;li&gt; Once the super constructor has returned, execute any instance variable initializers and object initializer blocks in textual (left-to-right) order.  Don't be confused by the fact that &lt;tt&gt;javadoc&lt;/tt&gt; and &lt;tt&gt;javap&lt;/tt&gt; use alphabetical ordering; that's not important here.  &lt;/li&gt;&lt;li&gt; Now execute the remainder of the body for the constructor.  This can  set instance variables or do anything else.  &lt;/li&gt;&lt;/ol&gt;  In general, you have a lot of freedom to choose any of these three forms.  My recommendation is to use instance variable initailizers in cases where there is a variable that takes the same value regardless of which constructor is used.  Use object initializer blocks only when initialization is complex (e.g. it requires a loop) and you don't want to repeat it in multiple constructors.  Use a constructor for the rest.  &lt;p&gt; Here's another example:  &lt;table border="1" cellspacing="0"&gt; &lt;tbody&gt;&lt;tr&gt;&lt;td&gt; &lt;b&gt;Program:&lt;/b&gt; &lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt;&lt;pre&gt;class &lt;b&gt;A&lt;/b&gt; {&lt;br /&gt;   String a1 = ABC.echo(" 1: a1");&lt;br /&gt;   String a2 = ABC.echo(" 2: a2");&lt;br /&gt;   public A() {ABC.echo(" 3: A()");}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class &lt;b&gt;B&lt;/b&gt; extends A {&lt;br /&gt;   String b1 = ABC.echo(" 4: b1");&lt;br /&gt;   String b2;&lt;br /&gt;   public B() {&lt;br /&gt;       ABC.echo(" 5: B()");&lt;br /&gt;       b1 = ABC.echo(" 6: b1 reset");&lt;br /&gt;       a2 = ABC.echo(" 7: a2 reset");&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class &lt;b&gt;C&lt;/b&gt; extends B {&lt;br /&gt;   String c1;&lt;br /&gt;   { c1 = ABC.echo(" 8: c1"); }&lt;br /&gt;   String c2;&lt;br /&gt;   String c3 = ABC.echo(" 9: c3");&lt;br /&gt;&lt;br /&gt;   public C() {&lt;br /&gt;       ABC.echo("10: C()");&lt;br /&gt;       c2 = ABC.echo("11: c2");&lt;br /&gt;       b2 = ABC.echo("12: b2");&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class &lt;b&gt;ABC&lt;/b&gt; {&lt;br /&gt;   static String &lt;b&gt;echo&lt;/b&gt;(String arg) {&lt;br /&gt;       System.out.println(arg);&lt;br /&gt;       return arg;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public static void &lt;b&gt;main&lt;/b&gt;(String[] args) {&lt;br /&gt;       new C();&lt;br /&gt;   }&lt;br /&gt;}&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt; &lt;/p&gt;&lt;/td&gt;&lt;td valign="top"&gt; &lt;b&gt;Output:&lt;/b&gt; &lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt;&lt;pre&gt; 1: a1&lt;br /&gt;2: a2&lt;br /&gt;3: A()&lt;br /&gt;4: b1&lt;br /&gt;5: B()&lt;br /&gt;6: b1 reset&lt;br /&gt;7: a2 reset&lt;br /&gt;8: c1&lt;br /&gt;9: c3&lt;br /&gt;10: C()&lt;br /&gt;11: c2&lt;br /&gt;12: b2&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt; &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p&gt;    &lt;/p&gt;&lt;hr /&gt; &lt;h2&gt;&lt;span style="color:brown;"&gt;&lt;a name="init2"&gt;Q:&lt;/a&gt; What about class  initialization?&lt;/span&gt;&lt;/h2&gt;  It is important to distinguish class initialization from instance creation.  An instance is created when you call a constructor with &lt;tt&gt;new&lt;/tt&gt;.  A class &lt;i&gt;C&lt;/i&gt; is initialized the first time it is actively used.  At that time, the initialization code for the class is run, in textual order.  There are two kinds of class initialization code: static initializer blocks (&lt;tt&gt;static { ... }&lt;/tt&gt;), and class variable initializers (&lt;tt&gt;static String var = ...&lt;/tt&gt;).  &lt;p&gt; &lt;i&gt;Active use&lt;/i&gt; is defined as the first time you do any one of the following:  &lt;/p&gt;&lt;ol&gt;&lt;li&gt; Create an instance of &lt;i&gt;C&lt;/i&gt; by calling a constructor;  &lt;/li&gt;&lt;li&gt; Call a static method that is defined in &lt;i&gt;C&lt;/i&gt; (not inherited);  &lt;/li&gt;&lt;li&gt; Assign or access a static variable that is declared (not inherited) in &lt;i&gt;C&lt;/i&gt;.  It does not count if the static variable is initialized with a constant expression (one involving only primitive operators (like + or ||), literals, and static final variables), because these are initialized at compile time.  &lt;/li&gt;&lt;/ol&gt;  &lt;p&gt; Here is an example:  &lt;/p&gt;&lt;p&gt;&lt;table border="1" cellspacing="0"&gt; &lt;tbody&gt;&lt;tr&gt;&lt;td&gt; &lt;b&gt;Program:&lt;/b&gt; &lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt;&lt;pre&gt;class &lt;b&gt;A&lt;/b&gt; {&lt;br /&gt;   static String a1 = ABC.echo(" 1: a1");&lt;br /&gt;   static String a2 = ABC.echo(" 2: a2");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class &lt;b&gt;B&lt;/b&gt; extends A {&lt;br /&gt;   static String b1 = ABC.echo(" 3: b1");&lt;br /&gt;   static String b2;&lt;br /&gt;   static {&lt;br /&gt;       ABC.echo(" 4: B()");&lt;br /&gt;       b1 = ABC.echo(" 5: b1 reset");&lt;br /&gt;       a2 = ABC.echo(" 6: a2 reset");&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class &lt;b&gt;C&lt;/b&gt; extends B {&lt;br /&gt;   static String c1;&lt;br /&gt;   static { c1 = ABC.echo(" 7: c1"); }&lt;br /&gt;   static String c2;&lt;br /&gt;   static String c3 = ABC.echo(" 8: c3");&lt;br /&gt;&lt;br /&gt;   static {&lt;br /&gt;       ABC.echo(" 9: C()");&lt;br /&gt;       c2 = ABC.echo("10: c2");&lt;br /&gt;       b2 = ABC.echo("11: b2");&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class &lt;b&gt;ABC&lt;/b&gt; {&lt;br /&gt;   static String &lt;b&gt;echo&lt;/b&gt;(String arg) {&lt;br /&gt;       System.out.println(arg);&lt;br /&gt;       return arg;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public static void &lt;b&gt;main&lt;/b&gt;(String[] args) {&lt;br /&gt;       new C();&lt;br /&gt;   }&lt;br /&gt;}&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt; &lt;/p&gt;&lt;/td&gt;&lt;td valign="top"&gt; &lt;b&gt;Output:&lt;/b&gt; &lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt;&lt;pre&gt; 1: a1&lt;br /&gt;2: a2&lt;br /&gt;3: b1&lt;br /&gt;4: B()&lt;br /&gt;5: b1 reset&lt;br /&gt;6: a2 reset&lt;br /&gt;7: c1&lt;br /&gt;8: c3&lt;br /&gt;9: C()&lt;br /&gt;10: c2&lt;br /&gt;11: b2&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt; &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p&gt;  &lt;/p&gt;&lt;hr /&gt; &lt;h2&gt;&lt;span style="color:brown;"&gt;&lt;a name="constructors"&gt;Q:&lt;/a&gt; I have a class with  six instance variables, each of which could be initialized or not.  Should  I write 64  constructors?&lt;/span&gt;&lt;/h2&gt;  Of course you don't need (2&lt;sup&gt;6&lt;/sup&gt;) constructors. Let's say you have  a class &lt;tt&gt;C&lt;/tt&gt; defined as follows: &lt;p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt;&lt;pre&gt;public class &lt;b&gt;C&lt;/b&gt; { int a,b,c,d,e,f; }&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p&gt; Here are some things you can do for constructors: &lt;/p&gt;&lt;ol&gt;&lt;li&gt; Guess at what combinations of variables will likely be wanted, and provide constructors for those combinations. &lt;b&gt;Pro:&lt;/b&gt; That's how it's usually done. &lt;b&gt;Con:&lt;/b&gt; Difficult to guess correctly; lots of redundant code to  write.&lt;p&gt;  &lt;/p&gt;&lt;/li&gt;&lt;li&gt; Define setters that can be cascaded because they return &lt;tt&gt;this&lt;/tt&gt;. That is, define a setter for each instance variable, then use them after a call to the default constructor: &lt;p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt;&lt;pre&gt;public &lt;b&gt;C&lt;/b&gt; setA(int val) { a = val; return this; }&lt;br /&gt;...&lt;br /&gt;new C().setA(1).setC(3).setE(5);&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;Pro:&lt;/b&gt; This is a reasonably simple and efficient approach. A similar  idea is discussed by Bjarne Stroustrop on page 156 of &lt;i&gt;The Design and  Evolution of C++&lt;/i&gt;. &lt;b&gt;Con:&lt;/b&gt; You need to write all the little setters, they aren't JavaBean-compliant (since they return &lt;tt&gt;this&lt;/tt&gt;, not &lt;tt&gt;void&lt;/tt&gt;), they don't work if there are interactions between two values.&lt;/p&gt;&lt;p&gt;  &lt;/p&gt;&lt;/li&gt;&lt;li&gt; Use the default constructor for an anonymous sub-class with a non-static initializer: &lt;p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt;&lt;pre&gt;new C() {{ a = 1; c = 3; e = 5; }}&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;Pro:&lt;/b&gt; Very concise; no mess with setters. &lt;b&gt;Con:&lt;/b&gt; The instance variables can't be private, you have the overhead  of a sub-class, your object won't actually have C as its class (although it will still be an instanceof C), it only works if you have accessible instance variables, and many  people, including experienced Java programmers, won't understand it.  Actually, its quite simple:  You are defining a new, unnamed (anonymous) subclass of C, with no new methods or variables, but with an initialization block that initializes a, c, and e.  Along with defining this class, you are also making an instance.  When I showed  this to Guy Steele, he said &lt;i&gt;"heh, heh!  That's pretty cute, all right,  but I'm not sure I would advocate widespread use..."&lt;/i&gt; As usual, Guy is right. (By the way, you can also use this to create and initialize a vector. You know how great it is to create and initialize, say, a String array with &lt;tt&gt;new String[] {"one", "two", "three"}&lt;/tt&gt;.  Now with inner classes you can do the same thing for a vector, where previously you thought you'd have to use assignement statements: &lt;tt&gt;new Vector(3) {{add("one"); add("two"); add("three")}}&lt;/tt&gt;.) &lt;/p&gt;&lt;p&gt;   &lt;/p&gt;&lt;/li&gt;&lt;li&gt; You can switch to a language that directly supports this idiom..  For  example,  C++ has &lt;i&gt;optional arguments&lt;/i&gt;.  So you can do this: &lt;p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#c0c0c0"&gt;&lt;pre&gt;class &lt;b&gt;C&lt;/b&gt; {&lt;br /&gt;public: C(int a=1, int b=2, int c=3, int d=4, int e=5);&lt;br /&gt;}&lt;br /&gt;...&lt;br /&gt;new C(10); //&lt;i&gt; Construct an instance with defaults for b,c,d,e&lt;/i&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&
