<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>其实我是一个程序员</title>
	<atom:link href="http://liubin.nanshapo.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://liubin.nanshapo.com</link>
	<description>编程是一种乐趣</description>
	<lastBuildDate>Thu, 08 Dec 2011 12:31:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>永远免费的Paas云平台总结（2011年版）</title>
		<link>http://liubin.nanshapo.com/2011/12/08/forever-free-paas-cloud-2011-version/</link>
		<comments>http://liubin.nanshapo.com/2011/12/08/forever-free-paas-cloud-2011-version/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 12:24:56 +0000</pubDate>
		<dc:creator>liubin</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[paas]]></category>

		<guid isPermaLink="false">http://liubin.nanshapo.com/?p=413</guid>
		<description><![CDATA[这是一篇翻译文，原文见： http://www.publickey1.jp/blog/11/paas2011.html &#160; PHP fog是以PHP语言为开发工具的Paas云计算平台，近日，他们在blog上宣布 ， 运营公司宣布废除之前的6个月免费使用限制，变为永远免费，而且， 还可以免费的部署3个应用。 当然，免费使用的服务有很多资源上的限制，但是， 像Wordpress等软件还是能自由部署运营的。 实际上，永久免费的Paas型云平台除了PHP fog之外，还有几个， 这里顺便一块介绍一下。 PHP fog 就像它的名字里暗示的一样，它主要是提供PHP执行环境的平台，除了PHP， 当然更少不了Mysql。此外，还可以安装WordPress，Drupal，Sugar CRM， Joomla等常用程序。 免费使用的资源包括：内存和CPU为公用，存储空间为100MB， 数据库大小为20MB；最多可以部署安装3个应用。 网址：https://phpfog.com/ Heroku HeroKu支持Ruby on Rails，Clojure，Java，Node.js等几种编程语言（系统）， 数据库为PostgreSQL。它也是作为Facebook应用的平台，广泛被使用的Paas平台。 在Heroku上，对于每一个进程采用一个叫Dyno的单位来进行性能管理， 增加这个值，则能提高应用的相应速度和吞吐量。有适用于Web server的 Web dyno和作为后台进程的Worker dyno。 如果一个月使用时间在750小时以下的话，Dyno是免费的， 数据库的大小则限制为5MB以下免费。 不过，仔细算算，即使一个月有31天，算下来也只有744小时而已， 所以如果不使用Worker dyno，只做Web应用的话，也可以说的上是免费的了。 网址：http://www.heroku.com cloudControl cloudControl是德国的一个创业公司运营的支持PHP的Paas平台， 数据库支持Mysql和MongoDB，Xeround等。 在cloudControl上，以BOX为单位对应用进行管理， 一个BOX由在不同的虚拟机上的两个进程组成，即使一台机器出问题， 以可以自动检测到问题并且还到可用的虚拟机上。可以通过增加BOX来提高应用的性能。 cloudControl，对于一个部署，提供一个免费的BOX和memcached。 虽然可以使用mysql或MongoDB，但是关于这方面的限制规定等没有找到。 网址：http://cloudcontrol.com dotCloud dotCloud支持PHP，Perl，Java，Python，数据库则支持Mysql， PostgreSQL，Cassandra，MongoDB，CounchDB，Redis等， 且支持Memcached，RabbitMQ，Hadoop等各种环境。 不管选择哪种语言和数据库环境，用户都可以免费建立两个应用， 且支持SSL和EMAIL系统。 而且，这个平台对于OpenSource的黑客，学生，创业者， [...]]]></description>
			<content:encoded><![CDATA[<p>这是一篇翻译文，原文见： <a href="http://www.publickey1.jp/blog/11/paas2011.html" target="_blank">http://www.publickey1.jp/blog/11/paas2011.html</a></p>
<p>&nbsp;</p>
<p>PHP fog是以PHP语言为开发工具的Paas云计算平台，近日，他们在blog上<a href="http://blog.phpfog.com/" target="_blank">宣布</a> ，<br />
运营公司宣布废除之前的6个月免费使用限制，变为永远免费，而且，<br />
还可以免费的部署3个应用。<br />
当然，免费使用的服务有很多资源上的限制，但是，<br />
像Wordpress等软件还是能自由部署运营的。<br />
实际上，永久免费的Paas型云平台除了PHP fog之外，还有几个，</p>
<p>这里顺便一块介绍一下。</p>
<h3>PHP fog</h3>
<p>就像它的名字里暗示的一样，它主要是提供PHP执行环境的平台，除了PHP，<br />
当然更少不了Mysql。此外，还可以安装WordPress，Drupal，Sugar CRM，<br />
Joomla等常用程序。<br />
免费使用的资源包括：内存和CPU为公用，存储空间为100MB，<br />
数据库大小为20MB；最多可以部署安装3个应用。</p>
<p>网址：<a href="https://phpfog.com/" target="_blank">https://phpfog.com/</a></p>
<h3>Heroku</h3>
<p>HeroKu支持Ruby on Rails，Clojure，Java，Node.js等几种编程语言（系统），<br />
数据库为PostgreSQL。它也是作为Facebook应用的平台，广泛被使用的Paas平台。</p>
<p>在Heroku上，对于每一个进程采用一个叫Dyno的单位来进行性能管理，<br />
增加这个值，则能提高应用的相应速度和吞吐量。有适用于Web server的<br />
Web dyno和作为后台进程的Worker dyno。<br />
如果一个月使用时间在750小时以下的话，Dyno是免费的，<br />
数据库的大小则限制为5MB以下免费。<br />
不过，仔细算算，即使一个月有31天，算下来也只有744小时而已，<br />
所以如果不使用Worker dyno，只做Web应用的话，也可以说的上是免费的了。</p>
<p>网址：<a href="http://www.heroku.com" target="_blank">http://www.heroku.com</a></p>
<h3>cloudControl</h3>
<p>cloudControl是德国的一个创业公司运营的支持PHP的Paas平台，<br />
数据库支持Mysql和MongoDB，Xeround等。<br />
在cloudControl上，以BOX为单位对应用进行管理，<br />
一个BOX由在不同的虚拟机上的两个进程组成，即使一台机器出问题，<br />
以可以自动检测到问题并且还到可用的虚拟机上。可以通过增加BOX来提高应用的性能。</p>
<p>cloudControl，对于一个部署，提供一个免费的BOX和memcached。<br />
虽然可以使用mysql或MongoDB，但是关于这方面的限制规定等没有找到。</p>
<p>网址：<a href="http://cloudcontrol.com" target="_blank">http://cloudcontrol.com</a></p>
<h3>dotCloud</h3>
<p>dotCloud支持PHP，Perl，Java，Python，数据库则支持Mysql，<br />
PostgreSQL，Cassandra，MongoDB，CounchDB，Redis等，<br />
且支持Memcached，RabbitMQ，Hadoop等各种环境。</p>
<p>不管选择哪种语言和数据库环境，用户都可以免费建立两个应用，<br />
且支持SSL和EMAIL系统。</p>
<p>而且，这个平台对于OpenSource的黑客，学生，创业者，<br />
NPO等还有其它的免费套餐可以选用。</p>
<p>网址：<a href="http://www.dotcloud.com" target="_blank">http://www.<em>dotcloud</em>.com</a></p>
<h3>FluxFlex</h3>
<p>FluxFlex由日本的同名公司开发维护，这个Paas平台完全支持LAMP的开发。<br />
它有一个叫做AppGarage的库（应用）群，可以方便的一键安装WordPress或者Pukiwiki等应用。</p>
<p>该平台还支持用facebook和twitter帐号登录，免费的支持2个应用，<br />
250MB的存储空间和25MB的数据库空间。<br />
不过1天的请求数如果是在1万以下的话是免费的，超过的话就要另收费了。</p>
<p>该平台最吸引人的还是和Github完全互通了。</p>
<p>网址：<a href="http://www.fluxflex.com/">http://www.fluxflex.com/</a></p>
<h3>Force.com</h3>
<p>Force.com是著名的salesforce.com公司提供的世界上比较早的Paas服务。<br />
同时，salesforce还为业务应用提供了ISVforce，为Web服务提供了Siteforce，<br />
为SNS应用提供了Appforce等云服务。该平台可以使用salesforce自己的database.com作为数据库。</p>
<p>在force.com上部署应用的时候，可以使用<a href="http://wiki.developerforce.com/page/JP:Developer_Edition">Force.com Developer Edition</a>。<br />
这个版本的服务，可以使用20MB的存储空间，5MB的数据库空间和24小时500MB的数据传输量。</p>
<p>在Developer Edition下开发的应用，可以免费的在产品环境（Free Edition）下使用。<br />
Free Edition上可以免费支持的应用只有一个，且限制在100用户以下，<br />
存储空间则增加到1GB，1个用户可以利用10个自定义对象。在pv方面，则有1个月25万pv的限制。</p>
<p>网址：<a href="http://www.force.com/">http://www.force.com/</a></p>
<h3>Google App Engine</h3>
<p>Google提供的Paas平台。可以使用的语言有Python，java和Go，<br />
数据库则是Google自有的NoSQL数据BigTable。</p>
<p>免费的内容包括1GB的存储空间和1个月500万PV所需的CPU和带宽。</p>
<p>网址：<a href="http://appengine.google.com" target="_blank">http://appengine.google.com</a></p>
<h3>Cloud Foundry（β版）</h3>
<p>这是VMware提供的opensource的开放平台，这既是其运营产品的名称，<br />
也是这个open source的项目的名称。</p>
<p>目前，该平台只是作为β版公开，可以免费使用。支持的语言包括<br />
Java、Ruby、Node.js、Java、Groovy、Grails、Scala等，<br />
数据库包括MySQL、Redis、MongoDB和RabbitMQ等。</p>
<p>此平台最大的特点是，还提供了在PC上的虚拟机运行的环境<a href="https://my.cloudfoundry.com/micro">Micro Cloud Foundry</a>，<br />
有了这个环境，可以在自己的PC上实现Paas服务了。</p>
<p>网址：<a href="http://www.cloudfoundry.com/">http://www.cloudfoundry.com/</a></p>
<h3>OpenShift（Developer Preview）</h3>
<p>这是RedHat提供的PaaS平台，支持Java、Perl、PHP、Python、Ruby等各种语言，<br />
以及MySQL、SQLite、MongoDB等数据库。<br />
而且，就像Cloud Foundry一样，RedHat也在打算把OpenShift开源，不过目前还没有动静。</p>
<p>网址：<a href="https://openshift.redhat.com/app/">https://openshift.redhat.com/app/</a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://liubin.nanshapo.com/2011/12/08/forever-free-paas-cloud-2011-version/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>doctrine和mysql的timestamp问题</title>
		<link>http://liubin.nanshapo.com/2011/06/20/doctrine-timestamp-mysql/</link>
		<comments>http://liubin.nanshapo.com/2011/06/20/doctrine-timestamp-mysql/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 14:03:23 +0000</pubDate>
		<dc:creator>liubin</dc:creator>
				<category><![CDATA[技术]]></category>

		<guid isPermaLink="false">http://liubin.nanshapo.com/?p=410</guid>
		<description><![CDATA[如果在mysql里定义为timestamp，默认的mapping会作为datetime类型的： /** * @var datetime $calendarTs * * @ORM\Column(name=&#8221;calendar_ts&#8221;, type=&#8221;datetime&#8221;, nullable=false) */ 如果在php里这样设置: $obj->setMyTsField(date(&#8216;Y-m-d H:i:s&#8217;)); 会出错： atal error: Call to a member function format() on a non-object in /vendor/doctrine-dbal/lib/Doctrine/DBAL/Types/DateTimeType.php on line 44 原因在于，date() 返回字的数据类型为符串类型，而 &#8220;datetime&#8221;的属性只能设置为 DateTime 对象。 如下修改，就可以了： $obj->setMyTsField(new \DateTime());]]></description>
			<content:encoded><![CDATA[<p>如果在mysql里定义为timestamp，默认的mapping会作为datetime类型的：</p>
<p><coolcode lang="php"><br />
    /**<br />
     * @var datetime $calendarTs<br />
     *<br />
     * @ORM\Column(name=&#8221;calendar_ts&#8221;, type=&#8221;datetime&#8221;, nullable=false)<br />
     */</p>
</php>
<p>如果在php里这样设置:<br />
<coolcode lang="php"><br />
    $obj->setMyTsField(date(&#8216;Y-m-d H:i:s&#8217;));
</php>
会出错：<br />
atal error: Call to a member function format() on a non-object in /vendor/doctrine-dbal/lib/Doctrine/DBAL/Types/DateTimeType.php on line 44</p>
<p>原因在于，date() 返回字的数据类型为符串类型，而 &#8220;datetime&#8221;的属性只能设置为 DateTime 对象。</p>
<p>如下修改，就可以了：<br />
<coolcode lang="php"><br />
    $obj->setMyTsField(new \DateTime());
</php>
]]></content:encoded>
			<wfw:commentRss>http://liubin.nanshapo.com/2011/06/20/doctrine-timestamp-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>howto do git replace</title>
		<link>http://liubin.nanshapo.com/2011/03/04/howto-do-git-replace/</link>
		<comments>http://liubin.nanshapo.com/2011/03/04/howto-do-git-replace/#comments</comments>
		<pubDate>Fri, 04 Mar 2011 05:39:13 +0000</pubDate>
		<dc:creator>liubin</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://liubin.nanshapo.com/?p=406</guid>
		<description><![CDATA[代码提交后，如果还要再改一次，如何修改？ 首先在本地修改代码 再执行如下命令： git add ./ git commit &#8211;amend repo upload ./ &#8211;replace]]></description>
			<content:encoded><![CDATA[<p>代码提交后，如果还要再改一次，如何修改？</p>
<p>首先在本地修改代码<br />
再执行如下命令：</p>
<p>git add ./</p>
<p>git commit &#8211;amend</p>
<p>repo upload ./ &#8211;replace</p>
]]></content:encoded>
			<wfw:commentRss>http://liubin.nanshapo.com/2011/03/04/howto-do-git-replace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>android的收彩信通知的过程解析</title>
		<link>http://liubin.nanshapo.com/2011/02/19/android-mms-receive/</link>
		<comments>http://liubin.nanshapo.com/2011/02/19/android-mms-receive/#comments</comments>
		<pubDate>Sat, 19 Feb 2011 09:48:13 +0000</pubDate>
		<dc:creator>liubin</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://liubin.nanshapo.com/?p=400</guid>
		<description><![CDATA[这里对froyo(非标准)里mms模块收彩信的函数调用关系进行一点解说。这里只说的是收到彩信，但是还没有下载（设为手工下载） 首先，mms是通过WAPPUSH实现的，具体在com.android.internal.telephony包里的WapPushOverSms类。 这个类里除了构造函数，另一个public的就是dispatchWapPdu()了 仔细查看下，就会找到dispatchWapPdu_MMS()这个函数 private void dispatchWapPdu_MMS(byte[] pdu, int transactionId, int pduType, &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; int&#160;headerStartIndex, int headerLength) { &#160; &#160; &#160; &#160; byte[]&#160;header = new byte[headerLength]; &#160; &#160; &#160; &#160; System.arraycopy(pdu, headerStartIndex, header, 0, header.length); &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>这里对froyo(非标准)里mms模块收彩信的函数调用关系进行一点解说。这里只说的是收到彩信，但是还没有下载（设为手工下载）<br />
首先，mms是通过WAPPUSH实现的，具体在com.android.internal.telephony包里的WapPushOverSms类。<br />
这个类里除了构造函数，另一个public的就是dispatchWapPdu()了</p>
<p>仔细查看下，就会找到dispatchWapPdu_MMS()这个函数</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Green;">private</span><span style="color: Gray;"> </span><span class="hl-types">void</span><span style="color: Gray;"> </span><span style="color: Blue;">dispatchWapPdu_MMS</span><span style="color: Olive;">(</span><span class="hl-types">byte</span><span style="color: Olive;">[]</span><span style="color: Gray;"> </span><span style="color: Blue;">pdu</span><span style="color: Gray;">, </span><span class="hl-types">int</span><span style="color: Gray;"> </span><span style="color: Blue;">transactionId</span><span style="color: Gray;">, </span><span class="hl-types">int</span><span style="color: Gray;"> </span><span style="color: Blue;">pduType</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="hl-types">int</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">headerStartIndex</span><span style="color: Gray;">, </span><span class="hl-types">int</span><span style="color: Gray;"> </span><span style="color: Blue;">headerLength</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="hl-types">byte</span><span style="color: Olive;">[]</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">header</span><span style="color: Gray;"> = </span><span style="color: Green;">new</span><span style="color: Gray;"> </span><span class="hl-types">byte</span><span style="color: Olive;">[</span><span style="color: Blue;">headerLength</span><span style="color: Olive;">]</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">System</span><span style="color: Gray;">.</span><span style="color: Blue;">arraycopy</span><span style="color: Olive;">(</span><span style="color: Blue;">pdu</span><span style="color: Gray;">, </span><span style="color: Blue;">headerStartIndex</span><span style="color: Gray;">, </span><span style="color: Blue;">header</span><span style="color: Gray;">, </span><span style="color: Maroon;">0</span><span style="color: Gray;">, </span><span style="color: Blue;">header</span><span style="color: Gray;">.</span><span style="color: Blue;">length</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="hl-types">int</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">dataIndex</span><span style="color: Gray;"> = </span><span style="color: Blue;">headerStartIndex</span><span style="color: Gray;"> + </span><span style="color: Blue;">headerLength</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="hl-types">byte</span><span style="color: Olive;">[]</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">data</span><span style="color: Gray;"> = </span><span style="color: Green;">new</span><span style="color: Gray;"> </span><span class="hl-types">byte</span><span style="color: Olive;">[</span><span style="color: Blue;">pdu</span><span style="color: Gray;">.</span><span style="color: Blue;">length</span><span style="color: Gray;"> - </span><span style="color: Blue;">dataIndex</span><span style="color: Olive;">]</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">System</span><span style="color: Gray;">.</span><span style="color: Blue;">arraycopy</span><span style="color: Olive;">(</span><span style="color: Blue;">pdu</span><span style="color: Gray;">, </span><span style="color: Blue;">dataIndex</span><span style="color: Gray;">, </span><span style="color: Blue;">data</span><span style="color: Gray;">, </span><span style="color: Maroon;">0</span><span style="color: Gray;">, </span><span style="color: Blue;">data</span><span style="color: Gray;">.</span><span style="color: Blue;">length</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">Intent</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">intent</span><span style="color: Gray;"> = </span><span style="color: Green;">new</span><span style="color: Gray;"> </span><span style="color: Blue;">Intent</span><span style="color: Olive;">(</span><span style="color: Blue;">Intents</span><span style="color: Gray;">.</span><span style="color: Blue;">WAP_PUSH_RECEIVED_ACTION</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">intent</span><span style="color: Gray;">.</span><span style="color: Blue;">setType</span><span style="color: Olive;">(</span><span style="color: Blue;">WspTypeDecoder</span><span style="color: Gray;">.</span><span style="color: Blue;">CONTENT_MIME_TYPE_B_MMS</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">intent</span><span style="color: Gray;">.</span><span style="color: Blue;">putExtra</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">transactionId</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: Blue;">transactionId</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">intent</span><span style="color: Gray;">.</span><span style="color: Blue;">putExtra</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">pduType</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: Blue;">pduType</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">intent</span><span style="color: Gray;">.</span><span style="color: Blue;">putExtra</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">header</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: Blue;">header</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">intent</span><span style="color: Gray;">.</span><span style="color: Blue;">putExtra</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">data</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: Blue;">data</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">mSmsDispatcher</span><span style="color: Gray;">.</span><span style="color: Blue;">dispatch</span><span style="color: Olive;">(</span><span style="color: Blue;">intent</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">android.permission.RECEIVE_MMS</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">}</span></li></ol></div>
<p>注意别混了， mSmsDispatcher.dispatch的第二个参数不是action的意思，而是权限，实际这个intent的action就是Intents.WAP_PUSH_RECEIVED_ACTION</p>
<p>然后，mms包（com.android.mms.transaction）下的onReceive会得到这个intent，进行处理<br />
在这个onReceive里，会调用内部类去执行：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Green;">new</span><span style="color: Gray;"> </span><span style="color: Blue;">ReceivePushTask</span><span style="color: Olive;">(</span><span style="color: Blue;">context</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">execute</span><span style="color: Olive;">(</span><span style="color: Blue;">intent</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li></ol></div>
<p>在这个内部类的doInBackground方法里，则会再继续根据pdu类型，来判断如何处理</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Blue;">Uri</span><span style="color: Gray;"> </span><span style="color: Blue;">uri</span><span style="color: Gray;"> = </span><span style="color: Blue;">p</span><span style="color: Gray;">.</span><span style="color: Blue;">persist</span><span style="color: Olive;">(</span><span style="color: Blue;">pdu</span><span style="color: Gray;">, </span><span style="color: Blue;">Inbox</span><span style="color: Gray;">.</span><span style="color: Blue;">CONTENT_URI</span><span style="color: Gray;">, </span><span style="color: Blue;">phoneId</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">// Start service to finish the notification transaction.</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">Intent</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">svc</span><span style="color: Gray;"> = </span><span style="color: Green;">new</span><span style="color: Gray;"> </span><span style="color: Blue;">Intent</span><span style="color: Olive;">(</span><span style="color: Blue;">mContext</span><span style="color: Gray;">, </span><span style="color: Blue;">TransactionService</span><span style="color: Gray;">.</span><span style="color: Green;">class</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">svc</span><span style="color: Gray;">.</span><span style="color: Blue;">putExtra</span><span style="color: Olive;">(</span><span style="color: Blue;">TransactionBundle</span><span style="color: Gray;">.</span><span style="color: Blue;">URI</span><span style="color: Gray;">, </span><span style="color: Blue;">uri</span><span style="color: Gray;">.</span><span style="color: Blue;">toString</span><span style="color: Olive;">())</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">svc</span><span style="color: Gray;">.</span><span style="color: Blue;">putExtra</span><span style="color: Olive;">(</span><span style="color: Blue;">TransactionBundle</span><span style="color: Gray;">.</span><span style="color: Blue;">TRANSACTION_TYPE</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">Transaction</span><span style="color: Gray;">.</span><span style="color: Blue;">NOTIFICATION_TRANSACTION</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">mContext</span><span style="color: Gray;">.</span><span style="color: Blue;">startService</span><span style="color: Olive;">(</span><span style="color: Blue;">svc</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li></ol></div>
<p>在TransactionService里，实际上会最终调用NotificationTransaction</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span class="hl-types">int</span><span style="color: Gray;"> </span><span style="color: Blue;">type</span><span style="color: Gray;"> = </span><span style="color: Blue;">PduHeaders</span><span style="color: Gray;">.</span><span style="color: Blue;">MESSAGE_TYPE_NOTIFICATION_IND</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">if</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">((</span><span style="color: Blue;">ind</span><span style="color: Gray;"> != </span><span style="color: Green;">null</span><span style="color: Olive;">)</span><span style="color: Gray;"> &amp;&amp; </span><span style="color: Olive;">(</span><span style="color: Blue;">ind</span><span style="color: Gray;">.</span><span style="color: Blue;">getMessageType</span><span style="color: Olive;">()</span><span style="color: Gray;"> == </span><span style="color: Blue;">type</span><span style="color: Olive;">))</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">transaction</span><span style="color: Gray;"> = </span><span style="color: Green;">new</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">NotificationTransaction</span><span style="color: Olive;">(</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">TransactionService</span><span style="color: Gray;">.</span><span style="color: Green;">this</span><span style="color: Gray;">, </span><span style="color: Blue;">serviceId</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">transactionSettings</span><span style="color: Gray;">, </span><span style="color: Olive;">(</span><span style="color: Blue;">NotificationInd</span><span style="color: Olive;">)</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">ind</span><span style="color: Gray;">, </span><span style="color: Blue;">phoneId</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></li></ol></div>
<p>在NotificationTransaction里，则会完成Notification事务</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: #ffa500;">// Don't try to download when data is suspended, as it will fail, so defer download</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">if</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">(</span><span style="color: Gray;">!</span><span style="color: Blue;">autoDownload</span><span style="color: Gray;"> || </span><span style="color: Blue;">dataSuspended</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">downloadManager</span><span style="color: Gray;">.</span><span style="color: Blue;">markState</span><span style="color: Olive;">(</span><span style="color: Blue;">mUri</span><span style="color: Gray;">, </span><span style="color: Blue;">DownloadManager</span><span style="color: Gray;">.</span><span style="color: Blue;">STATE_UNSTARTED</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">sendNotifyRespInd</span><span style="color: Olive;">(</span><span style="color: Blue;">status</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">return</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></li></ol></div>
<p>到这里（sendNotifyRespInd），这个事务应该算结束了。</p>
]]></content:encoded>
			<wfw:commentRss>http://liubin.nanshapo.com/2011/02/19/android-mms-receive/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XXX烧鸡步骤</title>
		<link>http://liubin.nanshapo.com/2011/02/14/xxx_flash/</link>
		<comments>http://liubin.nanshapo.com/2011/02/14/xxx_flash/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 06:40:07 +0000</pubDate>
		<dc:creator>liubin</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://liubin.nanshapo.com/?p=398</guid>
		<description><![CDATA[1。关机，拔电池 2。按住相机按钮的同时按电源键 3。sudo ./fastboot devices 确认设备链接成功 4。sudo ./fastboot erase userdata 删除用户数据 5。sudo ./fastboot flash boot boot_xxx.img 烧写boot信息 6。sudo ./fastboot flast system system_xxx.img 烧写 system镜像]]></description>
			<content:encoded><![CDATA[<p>1。关机，拔电池<br />
2。按住相机按钮的同时按电源键<br />
3。sudo ./fastboot devices 确认设备链接成功<br />
4。sudo ./fastboot erase userdata  删除用户数据<br />
5。sudo ./fastboot flash boot boot_xxx.img 烧写boot信息<br />
6。sudo ./fastboot flast system system_xxx.img 烧写 system镜像</p>
]]></content:encoded>
			<wfw:commentRss>http://liubin.nanshapo.com/2011/02/14/xxx_flash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何让自己的应用在应用程序列表里排在前面</title>
		<link>http://liubin.nanshapo.com/2011/02/10/order-first-of-all-apps/</link>
		<comments>http://liubin.nanshapo.com/2011/02/10/order-first-of-all-apps/#comments</comments>
		<pubDate>Thu, 10 Feb 2011 05:12:32 +0000</pubDate>
		<dc:creator>liubin</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://liubin.nanshapo.com/?p=389</guid>
		<description><![CDATA[普通的android的home程序里的应用一览，应该是按照字母顺序升续排列的，不光是android，其它平台可能也类似，很多东西都有按字母排列这一功能，这也是angry bird起名的由来吧，a怎么排都靠前。那么我们自己的程序必须要遵守这个规则吗？如果用汉字岂不是要排到很后面去了？ 答案是有小窍门，可以把你的“汉字”的应用名排到前面去，那就是修改app_name的值 先看看如何做吧，以应用汇为例 在values/string.xml里有如下代码 &#60;resources&#62; &#160; &#60;string&#160;name=&#34;app_name&#34;&#62;\u0020掌上应用汇&#60;/string&#62; &#160; &#60;string&#160;name=&#34;label&#34;&#62;掌上应用汇&#60;/string&#62; &#60;/resources&#62; 怎么样，一下子就明白了吧，app_name前面应该是有个空格，这样可以保证这个程序甚至可以排到a开头的程序的前面 掌上应用汇做的比较巧妙]]></description>
			<content:encoded><![CDATA[<p>普通的android的home程序里的应用一览，应该是按照字母顺序升续排列的，不光是android，其它平台可能也类似，很多东西都有按字母排列这一功能，这也是angry bird起名的由来吧，a怎么排都靠前。那么我们自己的程序必须要遵守这个规则吗？如果用汉字岂不是要排到很后面去了？</p>
<p>答案是有小窍门，可以把你的“汉字”的应用名排到前面去，那就是修改app_name的值</p>
<p>先看看如何做吧，以应用汇为例<br />
在values/string.xml里有如下代码</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">&lt;</span><span style="color: Green;">resources</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">string</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">app_name</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">\u0020掌上应用汇</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">string</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">string</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">label</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">掌上应用汇</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">string</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Olive;">&lt;/</span><span style="color: Green;">resources</span><span style="color: Olive;">&gt;</span></li></ol></div>
<p>怎么样，一下子就明白了吧，app_name前面应该是有个空格，这样可以保证这个程序甚至可以排到a开头的程序的前面</p>
<p>掌上应用汇做的比较巧妙</p>
]]></content:encoded>
			<wfw:commentRss>http://liubin.nanshapo.com/2011/02/10/order-first-of-all-apps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用Handler也能同步操作</title>
		<link>http://liubin.nanshapo.com/2011/01/31/synchronous-operation-with-handler/</link>
		<comments>http://liubin.nanshapo.com/2011/01/31/synchronous-operation-with-handler/#comments</comments>
		<pubDate>Mon, 31 Jan 2011 08:07:32 +0000</pubDate>
		<dc:creator>liubin</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[技术]]></category>

		<guid isPermaLink="false">http://liubin.nanshapo.com/?p=385</guid>
		<description><![CDATA[用Handler多数是为了异步操作，不阻塞UI线程的操作，可以防止ANR等。 今天看com.android.internal.telephony.gsm.SimSmsInterfaceManager的实现发现如下操作： Handler mHandler = new Handler() { &#160; &#160; &#160; &#160; @Override &#160; &#160; &#160; &#160; public&#160;void handleMessage(Message msg) { &#160; &#160; &#160; &#160; &#160; &#160; switch&#160;(msg.what) { &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; case&#160;EVENT_UPDATE_DONE: &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; synchronized&#160;(mLock) { &#160; &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>用Handler多数是为了异步操作，不阻塞UI线程的操作，可以防止ANR等。<br />
今天看com.android.internal.telephony.gsm.SimSmsInterfaceManager的实现发现如下操作：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Blue;">Handler</span><span style="color: Gray;"> </span><span style="color: Blue;">mHandler</span><span style="color: Gray;"> = </span><span style="color: Green;">new</span><span style="color: Gray;"> </span><span style="color: Blue;">Handler</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; @</span><span style="color: Blue;">Override</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">public</span><span style="color: Gray;">&nbsp;</span><span class="hl-types">void</span><span style="color: Gray;"> </span><span style="color: Blue;">handleMessage</span><span style="color: Olive;">(</span><span style="color: Blue;">Message</span><span style="color: Gray;"> </span><span style="color: Blue;">msg</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">switch</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">(</span><span style="color: Blue;">msg</span><span style="color: Gray;">.</span><span style="color: Blue;">what</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">case</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">EVENT_UPDATE_DONE</span><span style="color: Gray;">:</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">synchronized</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">(</span><span style="color: Blue;">mLock</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">// ..................</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">mLock</span><span style="color: Gray;">.</span><span style="color: Blue;">notifyAll</span><span style="color: Olive;">()</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">break</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">case</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">EVENT_LOAD_DONE</span><span style="color: Gray;">:</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">synchronized</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">(</span><span style="color: Blue;">mLock</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">// ..................</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">mLock</span><span style="color: Gray;">.</span><span style="color: Blue;">notifyAll</span><span style="color: Olive;">()</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">break</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">}</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: #ffa500;">// ..................</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Green;">public</span><span style="color: Gray;">&nbsp;</span><span class="hl-types">boolean</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Blue;">updateMessageOnIccEf</span><span style="color: Olive;">(</span><span class="hl-types">int</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">index</span><span style="color: Gray;">, </span><span class="hl-types">int</span><span style="color: Gray;"> </span><span style="color: Blue;">status</span><span style="color: Gray;">, </span><span class="hl-types">byte</span><span style="color: Olive;">[]</span><span style="color: Gray;"> </span><span style="color: Blue;">pdu</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">// ........................</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">synchronized</span><span style="color: Olive;">(</span><span style="color: Blue;">mLock</span><span style="color: Olive;">)</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">Message</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">response</span><span style="color: Gray;"> = </span><span style="color: Blue;">mHandler</span><span style="color: Gray;">.</span><span style="color: Blue;">obtainMessage</span><span style="color: Olive;">(</span><span style="color: Blue;">EVENT_UPDATE_DONE</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">if</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">(</span><span style="color: Blue;">status</span><span style="color: Gray;"> == </span><span style="color: Blue;">STATUS_ON_ICC_FREE</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">// Special case FREE: call deleteSmsOnSim instead of</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">// manipulating the SIM record</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">mPhone</span><span style="color: Gray;">.</span><span style="color: Blue;">mCM</span><span style="color: Gray;">.</span><span style="color: Blue;">deleteSmsOnSim</span><span style="color: Olive;">(</span><span style="color: Blue;">index</span><span style="color: Gray;">, </span><span style="color: Blue;">response</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp;</span><span style="color: Green;">else</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </span><span style="color: #ffa500;">// ........................</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">try</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">mLock</span><span style="color: Gray;">.</span><span style="color: Blue;">wait</span><span style="color: Olive;">()</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp;</span><span style="color: Green;">catch</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Blue;">InterruptedException</span><span style="color: Gray;"> </span><span style="color: Blue;">e</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">log</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">interrupted while trying to update by index</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">return</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">mSuccess</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">}</span></li></ol></div>
<p>感觉很是巧妙<br />
在操作函数中（updateMessageOnIccEf），发送消息之后调用mLock.wait(),而在handler里处理消息结果的时候notifyAll()，感觉很是巧妙。</p>
<p>大家不一定能在实际中有什么用处，但是可以参考下</p>
]]></content:encoded>
			<wfw:commentRss>http://liubin.nanshapo.com/2011/01/31/synchronous-operation-with-handler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>从android的framebuffer里取图</title>
		<link>http://liubin.nanshapo.com/2011/01/13/grab-a-frame-in-android-frame-buffer/</link>
		<comments>http://liubin.nanshapo.com/2011/01/13/grab-a-frame-in-android-frame-buffer/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 10:00:42 +0000</pubDate>
		<dc:creator>liubin</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[freebuffer]]></category>

		<guid isPermaLink="false">http://liubin.nanshapo.com/?p=382</guid>
		<description><![CDATA[在网上看到的 只需要如下命令即可： $ adb shell # cat /dev/graphics/fb0 > /sdcard/frame.raw 然后用FFMPEG转换为png $ IMAGE_RES=320&#215;480 $ RAW_IMAGE=frame.raw $ OUT_IMAGE=frame-%d.png $ #Download the raw data $ adb pull /sdcard/$RAW_IMAGE . $ ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgb565 -s $IMAGE_RES \ -i $RAW_IMAGE -f image2 -vcodec png $OUT_IMAGE 可以参考http://my.opera.com/otaku_2r/blog/grab-a-frame-in-android-frame-buffer]]></description>
			<content:encoded><![CDATA[<p>在网上看到的</p>
<p>只需要如下命令即可：<br />
$ adb shell<br />
# cat /dev/graphics/fb0 > /sdcard/frame.raw</p>
<p>然后用FFMPEG转换为png<br />
$ IMAGE_RES=320&#215;480<br />
$ RAW_IMAGE=frame.raw<br />
$ OUT_IMAGE=frame-%d.png<br />
$ #Download the raw data<br />
$ adb pull /sdcard/$RAW_IMAGE .<br />
$ ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgb565 -s $IMAGE_RES \<br />
-i $RAW_IMAGE -f image2 -vcodec png $OUT_IMAGE</p>
<p> 可以参考<a href="http://my.opera.com/otaku_2r/blog/grab-a-frame-in-android-frame-buffer">http://my.opera.com/otaku_2r/blog/grab-a-frame-in-android-frame-buffer</a></p>
]]></content:encoded>
			<wfw:commentRss>http://liubin.nanshapo.com/2011/01/13/grab-a-frame-in-android-frame-buffer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>线程问题引起的内存泄露</title>
		<link>http://liubin.nanshapo.com/2010/12/28/memory-leak-for-the-thread/</link>
		<comments>http://liubin.nanshapo.com/2010/12/28/memory-leak-for-the-thread/#comments</comments>
		<pubDate>Tue, 28 Dec 2010 06:15:34 +0000</pubDate>
		<dc:creator>liubin</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[leak]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[run]]></category>
		<category><![CDATA[start]]></category>
		<category><![CDATA[thread]]></category>

		<guid isPermaLink="false">http://liubin.nanshapo.com/?p=375</guid>
		<description><![CDATA[最近解决的一个内存泄露，竟然是由于线程问题引起的 看看下面代码，如何？ new Thread(new Runnable() { &#160; &#160; &#160; &#160; &#160; &#160; public&#160;void run() { &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; MessagingNotification.updateSendFailedNotificationForThread(ComposeMessageActivity.this, threadId); &#160; &#160; &#160; &#160; &#160; &#160; } &#160; &#160; &#160; &#160; }).run(); 有什么问题吗？ 对，这段代码生成了一个thread的对象，竟然调用了run方法，这引起了内存泄露。 必须改为start才行。 而run方法，只是调用了Runnable的run方法而已： // Thread.class public void run() { &#160; &#160; if&#160;(target != null) { &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>最近解决的一个内存泄露，竟然是由于线程问题引起的</p>
<p>看看下面代码，如何？</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Green;">new</span><span style="color: Gray;"> </span><span style="color: Blue;">Thread</span><span style="color: Olive;">(</span><span style="color: Green;">new</span><span style="color: Gray;"> </span><span style="color: Blue;">Runnable</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">public</span><span style="color: Gray;">&nbsp;</span><span class="hl-types">void</span><span style="color: Gray;"> </span><span style="color: Blue;">run</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">MessagingNotification</span><span style="color: Gray;">.</span><span style="color: Blue;">updateSendFailedNotificationForThread</span><span style="color: Olive;">(</span><span style="color: Blue;">ComposeMessageActivity</span><span style="color: Gray;">.</span><span style="color: Green;">this</span><span style="color: Gray;">, </span><span style="color: Blue;">threadId</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">})</span><span style="color: Gray;">.</span><span style="color: Blue;">run</span><span style="color: Olive;">()</span><span style="color: Gray;">;</span></li></ol></div>
<p>有什么问题吗？</p>
<p>对，这段代码生成了一个thread的对象，竟然调用了run方法，这引起了内存泄露。<br />
必须改为start才行。</p>
<p>而run方法，只是调用了Runnable的run方法而已：<br />
// Thread.class</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Green;">public</span><span style="color: Gray;"> </span><span class="hl-types">void</span><span style="color: Gray;"> </span><span style="color: Blue;">run</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Green;">if</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">(</span><span style="color: Blue;">target</span><span style="color: Gray;"> != </span><span style="color: Green;">null</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">target</span><span style="color: Gray;">.</span><span style="color: Blue;">run</span><span style="color: Olive;">()</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">}</span></li></ol></div>
<p>而start方法则不同</p>
<p>低版本的java有这个问题，不知道为什么Android2.2还有这个问题：<br />
<a href="http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=5869e03fee226ffffffffc40d4fa881a86e3:WuuT?bug_id=4533087">http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=5869e03fee226ffffffffc40d4fa881a86e3:WuuT?bug_id=4533087</a></p>
<p>按上面说法，生产一个Thread对象，会在构造器调用init方法，这个方法会把线程加入到一个group里，而从group里删除实在exit方法里做的，如果只调用run，这个exit方法则不会被调用。</p>
<p>结论就是如果用Thread，尽量都用start()<br />
myThread = new Thread(myRunnable);<br />
myThread.start();</p>
<p>如果是Runnable，可以用run<br />
myRunnable.run()</p>
]]></content:encoded>
			<wfw:commentRss>http://liubin.nanshapo.com/2010/12/28/memory-leak-for-the-thread/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>activity的启动方式（launch mode）</title>
		<link>http://liubin.nanshapo.com/2010/12/23/activity-launch-mode/</link>
		<comments>http://liubin.nanshapo.com/2010/12/23/activity-launch-mode/#comments</comments>
		<pubDate>Thu, 23 Dec 2010 11:14:38 +0000</pubDate>
		<dc:creator>liubin</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[launch]]></category>
		<category><![CDATA[mode]]></category>
		<category><![CDATA[singleInstance]]></category>
		<category><![CDATA[singleTask]]></category>
		<category><![CDATA[singleTop]]></category>
		<category><![CDATA[standard]]></category>

		<guid isPermaLink="false">http://liubin.nanshapo.com/?p=372</guid>
		<description><![CDATA[在android里，有4种activity的启动模式，分别为： &#8220;standard&#8221; (默认) &#8220;singleTop&#8221; &#8220;singleTask&#8221; &#8220;singleInstance&#8221; 它们主要有如下不同： 1. 如何决定所属task &#8220;standard&#8221;和&#8221;singleTop&#8221;的activity的目标task，和收到的Intent的发送者在同一个task内，除非intent包括参数FLAG_ACTIVITY_NEW_TASK。 如果提供了FLAG_ACTIVITY_NEW_TASK参数，会启动到别的task里。 &#8220;singleTask&#8221;和&#8221;singleInstance&#8221;总是把activity作为一个task的根元素，他们不会被启动到一个其他task里。 2. 是否允许多个实例 &#8220;standard&#8221;和&#8221;singleTop&#8221;可以被实例化多次，并且存在于不同的task中，且一个task可以包括一个activity的多个实例； &#8220;singleTask&#8221;和&#8221;singleInstance&#8221;则限制只生成一个实例，并且是task的根元素。 singleTop要求如果创建intent的时候栈顶已经有要创建 的Activity的实例，则将intent发送给该实例，而不发送给新的实例。 3. 是否允许其它activity存在于本task内 &#8220;singleInstance&#8221;独占一个task，其它activity不能存在那个task里；如果它启动了一个新的activity，不管新的activity的launch mode 如何，新的activity都将会到别的task里运行（如同加了FLAG_ACTIVITY_NEW_TASK参数）。 而另外三种模式，则可以和其它activity共存。 4. 是否每次都生成新实例 &#8220;standard&#8221;对于没一个启动Intent都会生成一个activity的新实例； &#8220;singleTop&#8221;的activity如果在task的栈顶的话，则不生成新的该activity的实例，直接使用栈顶的实例，否则，生成该activity的实例。 比如现在task栈元素为A-B-C-D（D在栈顶），这时候给D发一个启动intent，如果D是 &#8220;standard&#8221;的，则生成D的一个新实例，栈变为A－B－C－D－D。 如果D是singleTop的话，则不会生产D的新实例，栈状态仍为A-B-C-D 如果这时候给B发Intent的话，不管B的launchmode是&#8221;standard&#8221; 还是 &#8220;singleTop&#8221; ，都会生成B的新实例，栈状态变为A-B-C-D-B。 &#8220;singleInstance&#8221;是其所在栈的唯一activity，它会每次都被重用。 &#8220;singleTask&#8221;如果在栈顶，则接受intent，否则，该intent会被丢弃，但是该task仍会回到前台。 当已经存在的activity实例处理新的intent时候，会调用onNewIntent()方法 如果收到intent生成一个activity实例，那么用户可以通过back键回到上一个状态；如果是已经存在的一个activity来处理这个intent的话，用户不能通过按back键返回到这之前的状态。]]></description>
			<content:encoded><![CDATA[<p>在android里，有4种activity的启动模式，分别为：<br />
&#8220;standard&#8221; (默认)<br />
&#8220;singleTop&#8221;<br />
&#8220;singleTask&#8221;<br />
&#8220;singleInstance&#8221;</p>
<p>它们主要有如下不同：</p>
<p><strong>1. 如何决定所属task</strong><br />
&#8220;standard&#8221;和&#8221;singleTop&#8221;的activity的目标task，和收到的Intent的发送者在同一个task内，除非intent包括参数FLAG_ACTIVITY_NEW_TASK。<br />
如果提供了FLAG_ACTIVITY_NEW_TASK参数，会启动到别的task里。<br />
&#8220;singleTask&#8221;和&#8221;singleInstance&#8221;总是把activity作为一个task的根元素，他们不会被启动到一个其他task里。</p>
<p><strong>2. 是否允许多个实例</strong><br />
&#8220;standard&#8221;和&#8221;singleTop&#8221;可以被实例化多次，并且存在于不同的task中，且一个task可以包括一个activity的多个实例；<br />
&#8220;singleTask&#8221;和&#8221;singleInstance&#8221;则限制只生成一个实例，并且是task的根元素。<br />
singleTop要求如果创建intent的时候栈顶已经有要创建 的Activity的实例，则将intent发送给该实例，而不发送给新的实例。</p>
<p><strong>3. 是否允许其它activity存在于本task内</strong><br />
&#8220;singleInstance&#8221;独占一个task，其它activity不能存在那个task里；如果它启动了一个新的activity，不管新的activity的launch mode 如何，新的activity都将会到别的task里运行（如同加了FLAG_ACTIVITY_NEW_TASK参数）。<br />
而另外三种模式，则可以和其它activity共存。</p>
<p><strong>4. 是否每次都生成新实例</strong><br />
&#8220;standard&#8221;对于没一个启动Intent都会生成一个activity的新实例；<br />
&#8220;singleTop&#8221;的activity如果在task的栈顶的话，则不生成新的该activity的实例，直接使用栈顶的实例，否则，生成该activity的实例。<br />
比如现在task栈元素为A-B-C-D（D在栈顶），这时候给D发一个启动intent，如果D是 &#8220;standard&#8221;的，则生成D的一个新实例，栈变为A－B－C－D－D。<br />
如果D是singleTop的话，则不会生产D的新实例，栈状态仍为A-B-C-D<br />
如果这时候给B发Intent的话，不管B的launchmode是&#8221;standard&#8221; 还是 &#8220;singleTop&#8221; ，都会生成B的新实例，栈状态变为A-B-C-D-B。</p>
<p>&#8220;singleInstance&#8221;是其所在栈的唯一activity，它会每次都被重用。</p>
<p>&#8220;singleTask&#8221;如果在栈顶，则接受intent，否则，该intent会被丢弃，但是该task仍会回到前台。</p>
<p>当已经存在的activity实例处理新的intent时候，会调用onNewIntent()方法<br />
如果收到intent生成一个activity实例，那么用户可以通过back键回到上一个状态；如果是已经存在的一个activity来处理这个intent的话，用户不能通过按back键返回到这之前的状态。</p>
]]></content:encoded>
			<wfw:commentRss>http://liubin.nanshapo.com/2010/12/23/activity-launch-mode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

