??xml version="1.0" encoding="utf-8" standalone="yes"?>久久亚洲一区二区,亚洲av综合avav中文,亚洲偷偷自拍高清http://m.tkk7.com/zhaojianhua/category/47877.htmlzh-cnTue, 23 Jun 2015 03:34:53 GMTTue, 23 Jun 2015 03:34:53 GMT60Activity四种启动模式http://m.tkk7.com/zhaojianhua/archive/2015/06/23/425836.html建华建华Tue, 23 Jun 2015 03:04:00 GMThttp://m.tkk7.com/zhaojianhua/archive/2015/06/23/425836.htmlhttp://m.tkk7.com/zhaojianhua/comments/425836.htmlhttp://m.tkk7.com/zhaojianhua/archive/2015/06/23/425836.html#Feedback0http://m.tkk7.com/zhaojianhua/comments/commentRss/425836.htmlhttp://m.tkk7.com/zhaojianhua/services/trackbacks/425836.htmlActivity启动方式有四U,分别是:

standard
singleTop
singleTask
singleInstance

可以Ҏ实际的需求ؓActivity讄对应的启动模式,从而可以避免创建大量重复的Activity{问题?br />
讄Activity的启动模式,只需要在AndroidManifest.xml里对应的<activity>标签讄android:launchMode属性,例如Q?br />

  1. <activity  
  2.     android:name=".A1"  
  3.     android:launchMode="standard" />  

下面是这四种模式的作用:

standard
默认模式Q可以不用写配置。在q个模式下,都会默认创徏一个新的实例。因此,在这U模式下Q可以有多个相同的实例,也允许多个相同Activity叠加?/span>

例如Q?/span>
若我有一个Activity名ؓA1, 上面有一个按钮可跌{到A1。那么如果我点击按钮Q便会新启一个Activity A1叠在刚才的A1之上Q再点击Q又会再新启一个在它之?#8230;…
点back键会依照栈顺序依ơ退出?/span>

singleTop
可以有多个实例,但是不允许多个相同Activity叠加。即Q如果Activity在栈的时候,启动相同的ActivityQ不会创建新的实例,而会调用其onNewIntentҎ?/span>

例如Q?/span>
若我有两个Activity名ؓB1,B2,两个Activity内容功能完全相同Q都有两个按钮可以蟩到B1或者B2Q唯一不同的是B1为standardQB2为singleTop?/span>
若我意图打开的顺序ؓB1->B2->B2Q则实际打开的顺序ؓB1->B2Q后一ơ意图打开B2Q实际只调用了前一个的onNewIntentҎQ?/span>
若我意图打开的顺序ؓB1->B2->B1->B2Q则实际打开的顺序与意图的一_为B1->B2->B1->B2?/span>


singleTask
只有一个实例。在同一个应用程序中启动他的时候,若Activity不存在,则会在当前task创徏一个新的实例,若存在,则会把task中在其之上的其它Activity destory掉ƈ调用它的onNewIntentҎ?/span>
如果是在别的应用E序中启动它Q则会新Z个taskQƈ在该task中启动这个ActivityQsingleTask允许别的Activity与其在一个task中共存,也就是说Q如果我在这个singleTask的实例中再打开新的ActivityQ这个新的Activityq是会在singleTask的实例的task中?/span>

例如Q?/span>
若我的应用程序中有三个Activity,C1,C2,C3Q三个Activity可互相启动,其中C2为singleTask模式Q那么,无论我在q个E序中如何点d动,如:C1->C2->C3->C2->C3->C1-C2QC1,C3可能存在多个实例Q但是C2只会存在一个,q且q三个Activity都在同一个task里面?/span>
但是C1->C2->C3->C2->C3->C1-C2Q这L操作q程实际应该是如下这LQ因为singleTask会把task中在其之上的其它Activity destory掉?/span>
操作QC1->C2          C1->C2->C3          C1->C2->C3->C2            C1->C2->C3->C2->C3->C1             C1->C2->C3->C2->C3->C1-C2
实际QC1->C2          C1->C2->C3          C1->C2                              C1->C2->C3->C1                               C1->C2

若是别的应用E序打开C2Q则会新启一个task?/span>
如别的应用Other中有一个activityQtaskId?00Q从它打开C2Q则C2的taskIdI不会?00Q例如C2的taskId?01Q那么再从C2打开C1、C3Q则C2、C3的taskId仍ؓ201?/span>
注意Q如果此时你点击homeQ然后再打开OtherQ发现这时显C的肯定会是Other应用中的内容Q而不会是我们应用中的C1 C2 C3中的其中一个?/span>


singleInstance
只有一个实例,q且q个实例独立q行在一个task中,q个task只有q个实例Q不允许有别的Activity存在?/span>

例如Q?/span>
E序有三个ActivityD1,D2,D3Q三个Activity可互相启动,其中D2为singleInstance模式。那么程序从D1开始运行,假设D1的taskId?00Q那么从D1启动D2ӞD2会新启动一个taskQ即D2与D1不在一个task中运行。假设D2的taskId?01Q再从D2启动D3ӞD3的taskId?00Q也是说它被压CD1启动的Q务栈中?/span>

若是在别的应用程序打开D2Q假设Other的taskId?00Q打开D2QD2会新Z个taskq行Q假讑֮的taskId?01Q那么如果这时再从D2启动D1或者D3Q则又会再创Z个taskQ因此,若操作步骤ؓother->D2->D1Q这q程涉及到?个task了?/span>

建华 2015-06-23 11:04 发表评论
]]>
蓝牙发送文?/title><link>http://m.tkk7.com/zhaojianhua/archive/2013/02/20/395435.html</link><dc:creator>建华</dc:creator><author>建华</author><pubDate>Wed, 20 Feb 2013 00:45:00 GMT</pubDate><guid>http://m.tkk7.com/zhaojianhua/archive/2013/02/20/395435.html</guid><wfw:comment>http://m.tkk7.com/zhaojianhua/comments/395435.html</wfw:comment><comments>http://m.tkk7.com/zhaojianhua/archive/2013/02/20/395435.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/zhaojianhua/comments/commentRss/395435.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/zhaojianhua/services/trackbacks/395435.html</trackback:ping><description><![CDATA[<div><span style="white-space: pre;">pȝ4.0.3以后?/span><br />      File file=new File("");</div><div><span style="white-space:pre"> </span> Uri uri1 = Uri.fromFile(file);</div><div><span style="white-space:pre"> </span> Intent intent = new Intent();    </div><div><span style="white-space:pre"> </span>intent.setAction(Intent.ACTION_SEND);   </div><div><span style="white-space:pre"> </span> //intent.setType("audio/*"); </div><div><span style="white-space: pre;">  </span>intent.setType("application/octet-stream");</div><div><span style="white-space:pre"> </span>ComponentName comp=new ComponentName("com.mediatek.bluetooth","com.mediatek.bluetooth.BluetoothShareGatewayActivity");</div><div><span style="white-space:pre"> </span>intent.setComponent(comp);</div><div><span style="white-space:pre"> </span> intent.putExtra(Intent.EXTRA_STREAM, uri1);</div><div><span style="white-space:pre"> </span>startActivity(intent);</div><div><span style="white-space:pre"> </span></div><div><span style="white-space: pre;">pȝ4.0.3以前?/span><span style="white-space:pre"> </span></div><div><span style="white-space:pre"> </span>Intent intent = new Intent();</div><div><span style="white-space:pre"> </span>intent.setAction(Intent.ACTION_SEND);</div><div><span style="white-space:pre"> </span>//q个cd函数是自己工L的方法,你可以自p|文件类型,例如囄文gQimage/*  </div><div><span style="white-space: pre;">  </span>//不想写类型直?/*也是可以?/div><div><span style="white-space:pre"> </span>intent.setType("audio/*");</div><div><span style="white-space:pre"> </span>//q里setClassName是指定蓝牙Q不写这句就弹出选择用什么发?/div><div><span style="white-space: pre;">  </span>//有蓝牙啊Qgmail啊,彩信之类?/div><div><span style="white-space:pre"> </span>intent.setClassName("com.android.bluetooth" , "com.android.bluetooth.opp.BluetoothOppLauncherActivity");</div><div><span style="white-space:pre"> </span>intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("")));</div><div><span style="white-space:pre"> </span>startActivity(intent);<br /><br /><br /><div>  ArrayList<Uri> uris = new ArrayList<Uri>();</div><div><span style="white-space:pre"> </span>    uris.add(Uri.fromFile(new File("/sdcard/111.txt")));</div><div><span style="white-space:pre"> </span>    uris.add(Uri.fromFile(new File("/sdcard/222.txt")));</div><div><span style="white-space:pre"> </span>    </div><div><span style="white-space:pre"> </span>                Intent intent = new Intent();</div><div><span style="white-space:pre"> </span>intent.setAction(Intent.ACTION_SEND_MULTIPLE);</div><div><span style="white-space:pre"> </span>intent.setType("video/*");</div><div><span style="white-space:pre"> </span>intent.setClassName("com.android.bluetooth" , "com.android.bluetooth.opp.BluetoothOppLauncherActivity");</div><div><span style="white-space:pre"> </span>//intent.setClassName("com.mediatek.bluetooth","com.mediatek.bluetooth.BluetoothShareGatewayActivity");</div><div><span style="white-space:pre"> </span>//intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/111.txt")) );</div><div><span style="white-space:pre"> </span>//intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/222.txt")));</div><div><span style="white-space:pre"> </span>intent.putExtra(Intent.EXTRA_STREAM, uris);</div><div><span style="white-space:pre"> </span>startActivity(intent);</div></div><div></div><img src ="http://m.tkk7.com/zhaojianhua/aggbug/395435.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/zhaojianhua/" target="_blank">建华</a> 2013-02-20 08:45 <a href="http://m.tkk7.com/zhaojianhua/archive/2013/02/20/395435.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>surfaceView 与View 的区?/title><link>http://m.tkk7.com/zhaojianhua/archive/2012/03/23/372555.html</link><dc:creator>建华</dc:creator><author>建华</author><pubDate>Fri, 23 Mar 2012 08:33:00 GMT</pubDate><guid>http://m.tkk7.com/zhaojianhua/archive/2012/03/23/372555.html</guid><wfw:comment>http://m.tkk7.com/zhaojianhua/comments/372555.html</wfw:comment><comments>http://m.tkk7.com/zhaojianhua/archive/2012/03/23/372555.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/zhaojianhua/comments/commentRss/372555.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/zhaojianhua/services/trackbacks/372555.html</trackback:ping><description><![CDATA[<div><div class="bkndgcg" id="sina_keyword_ad_area2" "=""><wbr> 如果你的游戏不吃CPUQ用View比较好Q符合标?a >Android</a>操作方式Q由pȝ军_hsurface的时机?<div> <p><span style="font-size:14px">  但如果很不幸的,你做不到不让你的E序吃CPUQ你只好用SurfaceView来强制刷新surface了,不然pȝ?a >UI</a>q程很可能抢不过你那些吃CPU的线E?/span></p> <p>  当然其实不止q两U方法来hSurface的,q两U只是纯<a >Java</a>应用比较常见的方法?/p> <p>   SurfaceView和View最本质的区别在于,surfaceView是在一个新L单独U程中可以重新绘制画面而View必须在UI的主U程中更新画面?/p> <p>  那么在UI的主U程中更新画?可能会引发问题,比如你更新画面的旉q长Q那么你的主UIU程会被你正在画的函数阻塞。那么将无法响应按键Q触屏等消息?/p> <p>   当用surfaceView ׃是在新的U程中更新画面所以不会阻塞你的UIȝE。但q也带来了另外一个问题,是事g同步。比如你触屏了一下,你需要surfaceView?thread处理Q一般就需要有一个event queue的设计来保存touch eventQ这会稍E复杂一点,因ؓ涉及到线E同步?/p> <p>  所以基于以上,Ҏ游戏特点Q一般分成两cR?/p> <p>  1 被动更新画面的。比如棋c,q种用view好了。因为画面的更新是依赖于 onTouch 来更斎ͼ可以直接使用 invalidate?因ؓq种情况下,q一ơTouch和下一ơ的Touch需要的旉比较长些Q不会生媄响?/p> <p>  2 d更新。比如一个h在一直跑动。这需要一个单独的thread不停的重lh的状态,避免dmain UI thread。所以显然view不合适,需要surfaceView来控制?/p> </div></div></div><img src ="http://m.tkk7.com/zhaojianhua/aggbug/372555.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/zhaojianhua/" target="_blank">建华</a> 2012-03-23 16:33 <a href="http://m.tkk7.com/zhaojianhua/archive/2012/03/23/372555.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>如果task中已l有q个activity AQ那么就把A拿到task的最层Q而不是创Z个新的activityhttp://m.tkk7.com/zhaojianhua/archive/2011/12/20/366880.html建华建华Tue, 20 Dec 2011 11:31:00 GMThttp://m.tkk7.com/zhaojianhua/archive/2011/12/20/366880.htmlhttp://m.tkk7.com/zhaojianhua/comments/366880.htmlhttp://m.tkk7.com/zhaojianhua/archive/2011/12/20/366880.html#Feedback0http://m.tkk7.com/zhaojianhua/comments/commentRss/366880.htmlhttp://m.tkk7.com/zhaojianhua/services/trackbacks/366880.htmlIntent.FLAG_ACTIVITY_REORDER_TO_FRONT的意思是Q如果task中已l有q个activity AQ那么就把A拿到task的最层Q而不是创Z个新的activity?br />
所以不加flag也不会媄响界面的切过去,只是会媄响task的顺序而已?/div>

建华 2011-12-20 19:31 发表评论
]]>
Android开发小知识 ListView几个比较特别的属?/title><link>http://m.tkk7.com/zhaojianhua/archive/2011/12/14/366371.html</link><dc:creator>建华</dc:creator><author>建华</author><pubDate>Wed, 14 Dec 2011 12:14:00 GMT</pubDate><guid>http://m.tkk7.com/zhaojianhua/archive/2011/12/14/366371.html</guid><wfw:comment>http://m.tkk7.com/zhaojianhua/comments/366371.html</wfw:comment><comments>http://m.tkk7.com/zhaojianhua/archive/2011/12/14/366371.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/zhaojianhua/comments/commentRss/366371.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/zhaojianhua/services/trackbacks/366371.html</trackback:ping><description><![CDATA[<div>Android:stackFromBottom="true" 讄该属性之后你做好的列表就会显C在列表的最下面Qgؓtrue和false <br />android:transcriptMode="alwaysScroll" 要用ListView或者其它显C大量Items的控件实时跟t或者查看信息,q且希望最新的条目可以自动滚动到可视范围内。通过讄的控?transcriptMode属性可以将Androidq_的控Ӟ支持ScrollBarQ自动滑动到最底部?c<br />acheColorHint属性,很多人希望能够改变一下它的背景,使他能够W合整体的UI设计Q改变背景背很简单只需要准备一张图片然后指定属? <br />android:background="@drawable/bg"Q不q当你这么做以后Q发现背景是变了Q但是当你拖动,或者点击listI白位置?时候发现ListItem都变成黑色的了,破坏了整体效果?如果只是换背景的颜色的话Q可以直接指?br />android:cacheColorHintZ所要的颜色Q如果你是用囄做背景的话,那也只要?<br />android:cacheColorHint指定为透明Q?00000000Q就可以?<br />android:divider="@drawable/list_driver" 其中 @drawable/list_driver 是一个图片资源,如果不想昄分割U则只要讄为android:divider="@drawable/@null" 可以了 android:scrollbars="none"与setVerticalScrollBarEnabled(true);的效果是一LQ不zd?时候隐藏,zd的时候也隐藏 android:fadeScrollbars="true" 配置ListView布局的时候,讄q个属性ؓtrue可以实现滚动条的自动隐藏和昄?fadingEdge属性,上边和下Ҏ黑色的阴?android:fadingEdge="none" 讄后没有阴׃<img src="http://woshao.com/articles/4dc780bc-ce7f-11e0-8585-000c2959fd2a/stats/reads.png" alt="" /></div><img src ="http://m.tkk7.com/zhaojianhua/aggbug/366371.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/zhaojianhua/" target="_blank">建华</a> 2011-12-14 20:14 <a href="http://m.tkk7.com/zhaojianhua/archive/2011/12/14/366371.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>做一个透明的activityhttp://m.tkk7.com/zhaojianhua/archive/2011/12/13/366230.html建华建华Tue, 13 Dec 2011 06:13:00 GMThttp://m.tkk7.com/zhaojianhua/archive/2011/12/13/366230.htmlhttp://m.tkk7.com/zhaojianhua/comments/366230.htmlhttp://m.tkk7.com/zhaojianhua/archive/2011/12/13/366230.html#Feedback0http://m.tkk7.com/zhaojianhua/comments/commentRss/366230.htmlhttp://m.tkk7.com/zhaojianhua/services/trackbacks/366230.html
<activity android:name=".usual.activity.Declaration" android:theme="@android:style/Theme.Translucent.NoTitleBar" />


建华 2011-12-13 14:13 发表评论
]]>
draw9patch不失真背?/title><link>http://m.tkk7.com/zhaojianhua/archive/2011/11/24/364729.html</link><dc:creator>建华</dc:creator><author>建华</author><pubDate>Thu, 24 Nov 2011 07:00:00 GMT</pubDate><guid>http://m.tkk7.com/zhaojianhua/archive/2011/11/24/364729.html</guid><wfw:comment>http://m.tkk7.com/zhaojianhua/comments/364729.html</wfw:comment><comments>http://m.tkk7.com/zhaojianhua/archive/2011/11/24/364729.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://m.tkk7.com/zhaojianhua/comments/commentRss/364729.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/zhaojianhua/services/trackbacks/364729.html</trackback:ping><description><![CDATA[<div><p><strong>1.背景自适应且不q问题的存?/strong><br />      制作自适应背景囄是UI开发的一个广泛问题,也是界面设计师望解决的问题Q我怿我们彼此都深有体会?br />      比如,列表的背景图一定,但是列表的高度随着列表数据会发生变化Q标题栏的背景,无论横屏q是竖屏Q高分L率还是低分L率,都能自动填充满,而且不失真等{背景问题?br />      Ҏ以往的经验,我们一般采用先切图后拼凑的做法Q这U做法本来我惛_q里和大家介l一下,其实有的时候还是很有用的,但是说v来会比较ȝQ就不说q个非重点了Q略去,如果大家真的要介l,在回复中说明Q我再考虑一下?br />     Android针对q种情况Q专门制作了一U?9.PNG格式来解册个问题?/p> <p><strong>2.9.PNG格式?/strong><br />      我不惛_q里q多的讨论PNG格式的定义问题。但?9.PNG实是标准的PNG格式Q只是在最外面一圈额外增?px的边框,q个1px的边框就?用来定义囄中可扩展的和静态不变的区域。特别说明,left和topҎ中交叉部分是可拉伔R分,未选中部分是静态区域部分。right和bottom Ҏ中交叉部分则是内定w分(变相的相当于定义看一个内边距Q神似padding功能Q后面我会单独介l一下)Q这个参数是可选的, 如下图?br /><img style="display: block; margin-left: auto; margin-right: auto;" src="http://pic002.cnblogs.com/images/2011/31770/2011041623103426.png" alt="" />     在Android中以9.PNG格式的图片未背景Q则能够自定义拉伸而不qQ比如系l的Button是一个典型的例子?nbsp;<br />     其实呢,无论是left和topQ还是right和bottom都是把图片分??(边角四块是不能羃攄Q其他的四块则是允许~放?Q所以叫?.PNG?/p> <p><strong>3. 使用Draw9Patch.jar制作9.PNG囄之定义拉伸区域?/strong><br />      前面已经了解?.PNG格式的工作方式,下面我们使用h提供的Draw9Patch(q行android-sdk-windows\tools目录下的Draw9Patch.bat)来制?9.PNG囄?br />      <strong><em>W一步:准备要拉伸的囄?/em></strong><br />                                                           <img src="http://pic002.cnblogs.com/images/2011/31770/2011041700115098.png" style="display: block; margin-left: auto; margin-right: auto;" alt="" /><br />      非常的一张图片,我希望以此ؓ背景Q中间部分填充文章内宏V?br />      <strong><em>W二步:制作.9.PNG囄</em></strong>?br />      打开Draw9Patch,把图片拖q去Q如下:<br /><img src="http://pic002.cnblogs.com/images/2011/31770/2011041700231231.png" style="display: block; margin-left: auto; margin-right: auto;" alt="" /><br />      默认的拉伸是整体拉Q其实边框部分我们ƈ不想拉Q好Q我们自己来定义拉区域Q如下图Q?br /><img src="http://pic002.cnblogs.com/images/2011/31770/2011041700343167.png" style="display: block; margin-left: auto; margin-right: auto;" alt="" /><img src="http://pic002.cnblogs.com/images/2011/31770/2011041700393082.png" style="display: block; margin-left: auto; margin-right: auto;" alt="" /></p> <p>       然后点击File,导出为content.9.png?br />       <em><strong>W三步:在layout文g中用制作的 .9.PNG囄.</strong></em><br />       新徏工程Draw9PatchQ默认主Activity为Draw9PatchActivity.java:</p> <div> <div "="" id="highlighter_844734"><div><div alt1"=""><table><tbody><tr><td><code>1</code></td><td><code>@Override</code></td></tr></tbody></table></div><div alt2"=""><table><tbody><tr><td><code>2</code></td><td><code>public</code> <code>void</code> <code>onCreate(Bundle savedInstanceState)</code></td></tr></tbody></table></div><div alt1"=""><table><tbody><tr><td><code>3</code></td><td><code>{</code></td></tr></tbody></table></div><div alt2"=""><table><tbody><tr><td><code>4</code></td><td><code>    </code><code>super</code><code>.onCreate(savedInstanceState);</code></td></tr></tbody></table></div><div alt1"=""><table><tbody><tr><td><code>5</code></td><td><code>    </code><code>setContentView(R.layout.main);</code></td></tr></tbody></table></div><div alt2"=""><table><tbody><tr><td><code>6</code></td><td><code>}</code></td></tr></tbody></table></div></div></div> </div> <p>      我们把content.9.png文g拯?res/drawable文g夹下Q打开/res/layout目录下的main.xmlQ申明如下:</p> <div> <div "="" id="highlighter_86540"><div><div alt1"=""><table><tbody><tr><td><code>01</code></td><td><code><?</code><code>xml</code> <code>version</code><code>=</code><code>"1.0"</code> <code>encoding</code><code>=</code><code>"utf-8"</code><code>?></code></td></tr></tbody></table></div><div alt2"=""><table><tbody><tr><td><code>02</code></td><td><code><</code><code>LinearLayout</code> <code>xmlns:android</code><code>=</code><code>"<a </code></td></tr></tbody></table></div><div alt1"=""><table><tbody><tr><td><code>03</code></td><td><code>    </code><code>android:orientation</code><code>=</code><code>"vertical"</code></td></tr></tbody></table></div><div alt2"=""><table><tbody><tr><td><code>04</code></td><td><code>    </code><code>android:layout_width</code><code>=</code><code>"fill_parent"</code></td></tr></tbody></table></div><div alt1"=""><table><tbody><tr><td><code>05</code></td><td><code>    </code><code>android:layout_height</code><code>=</code><code>"fill_parent"</code></td></tr></tbody></table></div><div alt2"=""><table><tbody><tr><td><code>06</code></td><td><code>    </code><code>android:background</code><code>=</code><code>"#777"</code></td></tr></tbody></table></div><div alt1"=""><table><tbody><tr><td><code>07</code></td><td><code>    </code><code>android:padding</code><code>=</code><code>"8dip"</code></td></tr></tbody></table></div><div alt2"=""><table><tbody><tr><td><code>08</code></td><td><code>    </code><code>></code></td></tr></tbody></table></div><div alt1"=""><table><tbody><tr><td><code>09</code></td><td><code>    </code><code><</code><code>TextView</code></td></tr></tbody></table></div><div alt2"=""><table><tbody><tr><td><code>10</code></td><td><code>    </code><code>android:layout_width</code><code>=</code><code>"fill_parent"</code></td></tr></tbody></table></div><div alt1"=""><table><tbody><tr><td><code>11</code></td><td><code>    </code><code>android:layout_height</code><code>=</code><code>"wrap_content"</code></td></tr></tbody></table></div><div alt2"=""><table><tbody><tr><td><code>12</code></td><td><code>    </code><code>android:text</code><code>=</code><code>"正文:A NinePatchDrawable graphic is a stretchable bitmap image."</code></td></tr></tbody></table></div><div alt1"=""><table><tbody><tr><td><code>13</code></td><td><code>    </code><code>android:background</code><code>=</code><code>"@drawable/content"</code></td></tr></tbody></table></div><div alt2"=""><table><tbody><tr><td><code>14</code></td><td><code>    </code><code>android:textColor</code><code>=</code><code>"#000"</code></td></tr></tbody></table></div><div alt1"=""><table><tbody><tr><td><code>15</code></td><td><code>    </code><code>/></code></td></tr></tbody></table></div><div alt2"=""><table><tbody><tr><td><code>16</code></td><td><code></</code><code>LinearLayout</code><code>></code></td></tr></tbody></table></div></div></div> </div> <p>     如图Q?br /><img src="http://pic002.cnblogs.com/images/2011/31770/2011041700574383.png" style="display: block; margin-left: auto; margin-right: auto;" alt="" /><br />     我们修改textQ?/p> <div> <div "="" id="highlighter_190688"><div><div alt1"=""><table><tbody><tr><td><code>01</code></td><td><code><?</code><code>xml</code> <code>version</code><code>=</code><code>"1.0"</code> <code>encoding</code><code>=</code><code>"utf-8"</code><code>?></code></td></tr></tbody></table></div><div alt2"=""><table><tbody><tr><td><code>02</code></td><td><code><</code><code>LinearLayout</code> <code>xmlns:android</code><code>=</code><code>"<a </code></td></tr></tbody></table></div><div alt1"=""><table><tbody><tr><td><code>03</code></td><td><code>    </code><code>android:orientation</code><code>=</code><code>"vertical"</code></td></tr></tbody></table></div><div alt2"=""><table><tbody><tr><td><code>04</code></td><td><code>    </code><code>android:layout_width</code><code>=</code><code>"fill_parent"</code></td></tr></tbody></table></div><div alt1"=""><table><tbody><tr><td><code>05</code></td><td><code>    </code><code>android:layout_height</code><code>=</code><code>"fill_parent"</code></td></tr></tbody></table></div><div alt2"=""><table><tbody><tr><td><code>06</code></td><td><code>    </code><code>android:background</code><code>=</code><code>"#777"</code></td></tr></tbody></table></div><div alt1"=""><table><tbody><tr><td><code>07</code></td><td><code>    </code><code>android:padding</code><code>=</code><code>"8dip"</code></td></tr></tbody></table></div><div alt2"=""><table><tbody><tr><td><code>08</code></td><td><code>    </code><code>></code></td></tr></tbody></table></div><div alt1"=""><table><tbody><tr><td><code>09</code></td><td><code><</code><code>TextView</code></td></tr></tbody></table></div><div alt2"=""><table><tbody><tr><td><code>10</code></td><td><code>    </code><code>android:layout_width</code><code>=</code><code>"fill_parent"</code></td></tr></tbody></table></div><div alt1"=""><table><tbody><tr><td><code>11</code></td><td><code>    </code><code>android:layout_height</code><code>=</code><code>"wrap_content"</code></td></tr></tbody></table></div><div alt2"=""><table><tbody><tr><td><code>12</code></td><td><code>    </code><code>android:text</code><code>=</code><code>" 正文:A NinePatchDrawable graphic is a stretchable bitmap image, which Android will automatically resize to accommodate the contents of the View in which you have placed it as the background. A NinePatch drawable is a standard PNG image that includes an extra 1-pixel-wide border."</code></td></tr></tbody></table></div><div alt1"=""><table><tbody><tr><td><code>13</code></td><td><code>    </code><code>android:background</code><code>=</code><code>"@drawable/content"</code></td></tr></tbody></table></div><div alt2"=""><table><tbody><tr><td><code>14</code></td><td><code>    </code><code>android:textColor</code><code>=</code><code>"#000"</code></td></tr></tbody></table></div><div alt1"=""><table><tbody><tr><td><code>15</code></td><td><code>    </code><code>/></code></td></tr></tbody></table></div><div alt2"=""><table><tbody><tr><td><code>16</code></td><td><code></</code><code>LinearLayout</code><code>></code></td></tr></tbody></table></div></div></div> </div> <p>      如图Q?br /><img src="http://pic002.cnblogs.com/images/2011/31770/2011041700595145.png" style="display: block; margin-left: auto; margin-right: auto;" alt="" /></p> <p>      可以看出Q边框非常的清晰。下图是未?9.PNG的对比图Q而且也不是我们要的效果:</p> <p><img src="http://pic002.cnblogs.com/images/2011/31770/2011041701062374.png" style="display: block; margin-left: auto; margin-right: auto;" alt="" />      到这里ؓ止,我们已经基本会制?9.PNG囄了。ؓ了知识体pȝ全面性和深入性,我们l箋?/p> <p>4.<strong>使用Draw9Patch.jar制作9.PNG囄之定义内容区域?/strong><br />      是不是觉得文字和边距挨的太近Q好Q我们用right和bottom边的U来定义内容区域Q来辑ֈ增大内边距的目的?br /><img src="http://pic002.cnblogs.com/images/2011/31770/2011041701293991.png" style="display: block; margin-left: auto; margin-right: auto;" alt="" /><br />      我们定义了一个很的内容区域Q其他的地方则自动充当边框,从而内边距显的很大,如下图,<br /><img src="http://pic002.cnblogs.com/images/2011/31770/2011041701364646.png" style="display: block; margin-left: auto; margin-right: auto;" alt="" /><br />      在这里,我要特别说明Q一开始ؓ了增大内边距Q很Ҏ惯性思维Q在<TextView>中申?android:padding="10dip" 之类的,我在q里劝告朋友们不要这么做Q一是你无法预知你的显C,二是q比较؜淆,因ؓ讄内容区域是定paddingQ所以我在前面部分说他们?似。我个h认ؓ通过内容区域讑֮padding比在布局xml中定义padding更优雅,更简z!<br />      关于Draw9Patch工具的其他用说明,我在ơ不再篏qͼ因ؓ要说的话太多Qؓ了节省篇q,请参考官Ҏ档?/p> <p><strong>5.制作.9.PNG的高U技巧?/strong><br />       对于初学Draw9Patch的h来说Q这可以是高技巧,那就是:<span style="text-decoration: underline;"><em>拉区域Q可以不是连l的Q可以不止一块,而且是和自定义的ҎU的长度成正比?/em></span><br />       直接上图说明Q?br /><img style="display: block; margin-left: auto; margin-right: auto;" src="http://pic002.cnblogs.com/images/2011/31770/2011041702021279.png" alt="" /> </p> <p><strong>6.SDK中如何处?.PNG囄?/strong><br />      SDK专门针对9.PNG做了定义和处理,q里我们只是做个单的程分析QBitmap在读取图像流数据的时候,会把判断囄?NinePatchChunk(9Patch数据?Q如果NinePatchChunk不ؓI,则是 NinePatchDrawableQNinePatchDrawable则又会交lNinePatch处理Q?/p> <div> <div "="" id="highlighter_652929"><div><div alt1"=""><table><tbody><tr><td><code>1</code></td><td><code>setNinePatchState(</code><code>new</code> <code>NinePatchState(</code></td></tr></tbody></table></div><div alt2"=""><table><tbody><tr><td><code>2</code></td><td><code>               </code><code>new</code> <code>NinePatch(bitmap, bitmap.getNinePatchChunk(), </code><code>"XML 9-patch"</code><code>),</code></td></tr></tbody></table></div><div alt1"=""><table><tbody><tr><td><code>3</code></td><td><code>               </code><code>padding, dither), r);</code></td></tr></tbody></table></div></div></div> </div> <p>      NinePatch验成功则调用本地ҎQ绘制出最l的囄Q?/p> <div> <div "="" id="highlighter_816842"><div><div alt1"=""><table><tbody><tr><td><code>1</code></td><td><code>nativeDraw(canvas.mNativeCanvas, location,</code></td></tr></tbody></table></div><div alt2"=""><table><tbody><tr><td><code>2</code></td><td><code>                </code><code>mBitmap.ni(), mChunk, paint != </code><code>null</code> <code>? paint.mNativePaint : </code><code>0</code><code>,</code></td></tr></tbody></table></div><div alt1"=""><table><tbody><tr><td><code>3</code></td><td><code>                </code><code>canvas.mDensity, mBitmap.mDensity);</code></td></tr></tbody></table></div></div></div> </div> <p><strong>7.androidpȝ中大量应用了9.PNG囄?/strong><br />     通过解压随便一个romQ找到里面的framework_res.apk,里面有大量的9.PNG格式文gQ被q泛的应用v来,比如常见的有Q?br />     按钮Q?img src="http://pic002.cnblogs.com/images/2011/31770/2011041702450222.png" alt="" /> <img src="http://pic002.cnblogs.com/images/2011/31770/2011041702453263.png" alt="" /> <img src="http://pic002.cnblogs.com/images/2011/31770/2011041702454963.png" alt="" /><br />     解锁Q?img src="http://pic002.cnblogs.com/images/2011/31770/2011041702484148.png" alt="" /> <img src="http://pic002.cnblogs.com/images/2011/31770/2011041702490242.png" alt="" /> <img src="http://pic002.cnblogs.com/images/2011/31770/2011041702491557.png" alt="" /><br />     下拉框:<img src="http://pic002.cnblogs.com/images/2011/31770/2011041702465816.png" alt="" /> <img src="http://pic002.cnblogs.com/images/2011/31770/2011041702472347.png" alt="" /> <img src="http://pic002.cnblogs.com/images/2011/31770/2011041702473728.png" alt="" /><br />     标题栏:<img src="http://pic002.cnblogs.com/images/2011/31770/2011041702424231.png" alt="" /><br />     ToastQ?img src="http://pic002.cnblogs.com/images/2011/31770/2011041702520097.png" alt="" /><br />      q有搜烦Q键盘,攑֤~小控gQ时间加减等{,我就不一一列D?/p> <strong>8.最后送上一些图例,以飨读者,以做后鉴Q?/strong><br /><img src="http://pic002.cnblogs.com/images/2011/31770/2011041702054926.png" alt="" /> <br />赏图1 本h之作<br /><img src="http://pic002.cnblogs.com/images/2011/31770/2011041702115762.jpg" alt="" /><br /> 赏图2 下拉按钮<br /><img src="http://pic002.cnblogs.com/images/2011/31770/2011041702134696.jpg" alt="" /> <br />赏图3 文章头部背景 <br /><img src="http://pic002.cnblogs.com/images/2011/31770/2011041702154997.jpg" alt="" /> <br />赏图4 pȝ头部背景<br /><img src="http://pic002.cnblogs.com/images/2011/31770/2011041702164420.jpg" alt="" /></div>转蝲?div>http://www.cnblogs.com/qianxudetianxia/archive/2011/04/17/2017591.html</div><img src ="http://m.tkk7.com/zhaojianhua/aggbug/364729.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/zhaojianhua/" target="_blank">建华</a> 2011-11-24 15:00 <a href="http://m.tkk7.com/zhaojianhua/archive/2011/11/24/364729.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>android 保存囄到数据库http://m.tkk7.com/zhaojianhua/archive/2011/11/17/364077.html建华建华Thu, 17 Nov 2011 06:09:00 GMThttp://m.tkk7.com/zhaojianhua/archive/2011/11/17/364077.htmlhttp://m.tkk7.com/zhaojianhua/comments/364077.htmlhttp://m.tkk7.com/zhaojianhua/archive/2011/11/17/364077.html#Feedback0http://m.tkk7.com/zhaojianhua/comments/commentRss/364077.htmlhttp://m.tkk7.com/zhaojianhua/services/trackbacks/364077.html Ҏ一Q?
Java代码 复制代码
  1. public void saveIcon(Bitmap icon) {   
  2.         if (icon == null) {   
  3.             return;   
  4.         }   
  5.   
  6.         // 最l图标要保存到浏览器的内部数据库中,pȝE序均保存ؓSQLite格式QBrowser也不例外Q因为图片是二进制的所以用字节数l存储数据库?  
  7.         // BLOBcd   
  8.         final ByteArrayOutputStream os = new ByteArrayOutputStream();   
  9.         // Bitmap压羃成PNG~码Q质量ؓ100%存储           
  10.         icon.compress(Bitmap.CompressFormat.PNG, 100, os);    
  11.         // 构造SQLite的Content对象Q这里也可以使用raw   
  12.         ContentValues values = new ContentValues();    
  13.         // 写入数据库的Browser.BookmarkColumns.TOUCH_ICON字段   
  14.         values.put(Browser.BookmarkColumns.TOUCH_ICON, os.toByteArray());    
  15.            
  16.         DBUtil.update(....);//调用更新或者插入到数据库的Ҏ   
  17.     } 


Ҏ二:如果数据表入口时一个content:URI

 

Java代码 复制代码
  1. import android.provider.MediaStore.Images.Media;   
  2. import android.content.ContentValues;   
  3. import java.io.OutputStream;   
  4.   
  5. // Save the name and description of an image in a ContentValues map.     
  6. ContentValues values = new ContentValues(3);   
  7. values.put(Media.DISPLAY_NAME, "road_trip_1");   
  8. values.put(Media.DESCRIPTION, "Day 1, trip to Los Angeles");   
  9. values.put(Media.MIME_TYPE, "image/jpeg");   
  10.   
  11. // Add a new record without the bitmap, but with the values just set.   
  12. // insert() returns the URI of the new record.   
  13. Uri uri = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values);   
  14.   
  15. // Now get a handle to the file for that record, and save the data into it.   
  16. // Here, sourceBitmap is a Bitmap object representing the file to save to the database.   
  17. try {   
  18.     OutputStream outStream = getContentResolver().openOutputStream(uri);   
  19.     sourceBitmap.compress(Bitmap.CompressFormat.JPEG, 50, outStream);   
  20.     outStream.close();   
  21. catch (Exception e) {   
  22.     Log.e(TAG, "exception while writing image", e);   




建华 2011-11-17 14:09 发表评论
]]>
android 使用contentobserver监听数据库内容变?/title><link>http://m.tkk7.com/zhaojianhua/archive/2011/10/27/362204.html</link><dc:creator>建华</dc:creator><author>建华</author><pubDate>Thu, 27 Oct 2011 14:11:00 GMT</pubDate><guid>http://m.tkk7.com/zhaojianhua/archive/2011/10/27/362204.html</guid><wfw:comment>http://m.tkk7.com/zhaojianhua/comments/362204.html</wfw:comment><comments>http://m.tkk7.com/zhaojianhua/archive/2011/10/27/362204.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://m.tkk7.com/zhaojianhua/comments/commentRss/362204.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/zhaojianhua/services/trackbacks/362204.html</trackback:ping><description><![CDATA[     摘要: android 使用contentobserver监听数据库内容变化在android中经怼用到改变数据库内容后再去使用数据库更新的内容Q很多h会重新去query一遍,但是q样的问题就是程序会特别占内存,而且有可能会搂关cursor而导致程序内存未释放{等。其实android内部提供了一UContentObserver的东西来监听数据库内容的变化。ContentObserver的构造函数需要一个参...  <a href='http://m.tkk7.com/zhaojianhua/archive/2011/10/27/362204.html'>阅读全文</a><img src ="http://m.tkk7.com/zhaojianhua/aggbug/362204.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/zhaojianhua/" target="_blank">建华</a> 2011-10-27 22:11 <a href="http://m.tkk7.com/zhaojianhua/archive/2011/10/27/362204.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Activity的生命周?/title><link>http://m.tkk7.com/zhaojianhua/archive/2011/08/03/355680.html</link><dc:creator>建华</dc:creator><author>建华</author><pubDate>Wed, 03 Aug 2011 07:41:00 GMT</pubDate><guid>http://m.tkk7.com/zhaojianhua/archive/2011/08/03/355680.html</guid><wfw:comment>http://m.tkk7.com/zhaojianhua/comments/355680.html</wfw:comment><comments>http://m.tkk7.com/zhaojianhua/archive/2011/08/03/355680.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/zhaojianhua/comments/commentRss/355680.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/zhaojianhua/services/trackbacks/355680.html</trackback:ping><description><![CDATA[<span id="vxxnsoi" class="Apple-style-span" style="color: #333333; font-family: Arial; line-height: 26px; ">注意到在Activity的API中有大量的onXXXX形式的函数定义,除了我们前面用到的onCreate以外Q还有onStartQonStop以及onPause{等。从字面上看Q它们是一些事件回调,那么ơ序又是如何的呢Q其实这U事情,自己做个实验最明白不过了。在做这个实验之前,我们先得扑ֈ在Android中的Log是如何输出的?br /><br />昄Q我们要用的是android.util.logc,q个cȝ当的单易用,因ؓ它提供的全是一些静态方法:<br /><div style="border-top-width: 0.5pt; border-right-width: 0.5pt; border-bottom-width: 0.5pt; border-left-width: 0.5pt; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: windowtext; border-right-color: windowtext; border-bottom-color: windowtext; border-left-color: windowtext; padding-top: 4px; padding-right: 5.4pt; padding-bottom: 4px; padding-left: 5.4pt; background-image: none; background-attachment: scroll; background-origin: initial; background-clip: initial; background-color: #e6e6e6; width: 659px; background-position: 0% 50%; background-repeat: repeat repeat; "><div><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " /><span style="color: #000000; ">Log.v(String tag, String msg);        //VERBOSE<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />Log.d(String tag, String msg);       //DEBUG    <br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />Log.i(String tag, String msg);        //INFO<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />Log.w(String tag, String msg);     //WARN<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />Log.e(String tag, String msg);      //ERROR<br /></span></div></div>前面的tag是由我们定义的一个标识,一般可以用“cd_Ҏ?#8220;来定义?br />输出的LOG信息Q如果用Eclipse+ADT开发,在LogCat中就可以看到Q否则用adb logcat也行Q不q我是从来都依赖于IDE环境的?br /><br />好了Q现在我们修改前面的HelloThree代码Q?br /><div style="border-top-width: 0.5pt; border-right-width: 0.5pt; border-bottom-width: 0.5pt; border-left-width: 0.5pt; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: windowtext; border-right-color: windowtext; border-bottom-color: windowtext; border-left-color: windowtext; padding-top: 4px; padding-right: 5.4pt; padding-bottom: 4px; padding-left: 5.4pt; background-image: none; background-attachment: scroll; background-origin: initial; background-clip: initial; background-color: #e6e6e6; width: 659px; background-position: 0% 50%; background-repeat: repeat repeat; "><div><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " /><span style="color: #000000; ">   </span><span style="color: #0000ff; ">public</span><span style="color: #000000; "> </span><span style="color: #0000ff; ">void</span><span style="color: #000000; "> onStart()<br /><img align="top" alt="" id="_29_84_Open_Image" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />    </span><span id="_29_84_Open_Text"><span style="color: #000000; ">{<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />        </span><span style="color: #0000ff; ">super</span><span style="color: #000000; ">.onStart();<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />        Log.v(TAG,</span><span style="color: #000000; ">"</span><span style="color: #000000; ">onStart</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />    }</span></span><span style="color: #000000; "><br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />    </span><span style="color: #0000ff; ">public</span><span style="color: #000000; "> </span><span style="color: #0000ff; ">void</span><span style="color: #000000; "> onStop()<br /><img align="top" alt="" id="_115_168_Open_Image" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />    </span><span id="_115_168_Open_Text"><span style="color: #000000; ">{<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />        </span><span style="color: #0000ff; ">super</span><span style="color: #000000; ">.onStop();<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />        Log.v(TAG,</span><span style="color: #000000; ">"</span><span style="color: #000000; ">onStop</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />    }</span></span><span style="color: #000000; "><br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />    </span><span style="color: #0000ff; ">public</span><span style="color: #000000; "> </span><span style="color: #0000ff; ">void</span><span style="color: #000000; "> onResume()<br /><img align="top" alt="" id="_201_258_Open_Image" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />    </span><span id="_201_258_Open_Text"><span style="color: #000000; ">{<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />        </span><span style="color: #0000ff; ">super</span><span style="color: #000000; ">.onResume();<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />        Log.v(TAG,</span><span style="color: #000000; ">"</span><span style="color: #000000; ">onResume</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />    }</span></span><span style="color: #000000; "><br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />    </span><span style="color: #0000ff; ">public</span><span style="color: #000000; "> </span><span style="color: #0000ff; ">void</span><span style="color: #000000; "> onRestart()<br /><img align="top" alt="" id="_292_351_Open_Image" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />    </span><span id="_292_351_Open_Text"><span style="color: #000000; ">{<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />        </span><span style="color: #0000ff; ">super</span><span style="color: #000000; ">.onRestart();<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />        Log.v(TAG,</span><span style="color: #000000; ">"</span><span style="color: #000000; ">onReStart</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />    }</span></span><span style="color: #000000; "><br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />    </span><span style="color: #0000ff; ">public</span><span style="color: #000000; "> </span><span style="color: #0000ff; ">void</span><span style="color: #000000; "> onPause()<br /><img align="top" alt="" id="_383_438_Open_Image" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />    </span><span id="_383_438_Open_Text"><span style="color: #000000; ">{<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />        </span><span style="color: #0000ff; ">super</span><span style="color: #000000; ">.onPause();<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />        Log.v(TAG,</span><span style="color: #000000; ">"</span><span style="color: #000000; ">onPause</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />    }</span></span><span style="color: #000000; "><br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />    </span><span style="color: #0000ff; ">public</span><span style="color: #000000; "> </span><span style="color: #0000ff; ">void</span><span style="color: #000000; "> onDestroy()<br /><img align="top" alt="" id="_472_531_Open_Image" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />    </span><span id="_472_531_Open_Text"><span style="color: #000000; ">{<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />        </span><span style="color: #0000ff; ">super</span><span style="color: #000000; ">.onDestroy();<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />        Log.v(TAG,</span><span style="color: #000000; ">"</span><span style="color: #000000; ">onDestroy</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />    }</span></span><span style="color: #000000; "><br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />    </span><span style="color: #0000ff; ">public</span><span style="color: #000000; "> </span><span style="color: #0000ff; ">void</span><span style="color: #000000; "> onFreeze(Bundle outState)<br /><img align="top" alt="" id="_579_644_Open_Image" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />    </span><span id="_579_644_Open_Text"><span style="color: #000000; ">{<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />        </span><span style="color: #0000ff; ">super</span><span style="color: #000000; ">.onFreeze(outState);<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />        Log.v(TAG,</span><span style="color: #000000; ">"</span><span style="color: #000000; ">onFreeze</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br /><img align="top" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " />    }</span></span></div></div>在HelloThreeB中也同样增加q样的代码,~译Q运行一下,从logcat中分析输出的日志?br />在启动第一个界面Activity OneӞ它的ơ序是:<br /><span style="color: #ff6600; font-style: italic; ">onCreate (ONE) - onStart (ONE) - onResume(ONE) </span><span style="color: #ff6600; "></span><span style="color: #ff6600; "></span><br /><span style="color: #ff6600; font-style: italic; "></span>虽然是第一ơ启动,也要C遍这个resume事g。然后,我们点goto跛_W二个Activity Two中(前一个没有关闭)Q这时走的次序是Q?br /><span style="color: #ff6600; font-style: italic; ">onFreeze(ONE) - onPause(ONE) - onCreate(TWO) - onStart(TWO) - onResume(TWO) - onStop(ONE)</span><br />说明Q第二个Activity Two在启动前QOne会经历一个:ȝ、暂停的q程Q在启动Two后,One才会被停止?<br />然后Q我们再点back回到W一个界面,q时走的ơ序是:<br /><span style="color: #ff6600; font-style: italic; ">onPause(TWO) - onActivityResult(ONE) - onStart(ONE) - onRestart(ONE) - onResume(ONE) - onStop(TWO) - onDestroy(TWO)</span><br />说明Q返回时QTwo没有l历ȝq接暂停了Q在One接收参数Q重启后QTwo停止ƈ被销毁了?br />最后,我们点一下Exit退出应用,它的ơ序是:<br /><span style="font-style: italic; color: #ff6600; ">onPause(ONE) - onStop(ONE) - onDestroy(ONE)</span><br />说明如果我们用了finish的话Q不会有freezeQ但是仍会经历pause - stop才被销毁?br /><br />q里有点疑问的是Qؓ什么回来时先是Start才是RestartQ可是文中的图上画的却是先restart再start的啊Q不q,后面的表g的描q好象是正确的,start后面L跟着resumeQ如果是W一ơ)或者restartQ如果原来被stop掉了Q这U情况会在start与resume中插一个restartQ?br /><br />下面不跑例子了,看看文档吧?br /><br />1.Android用Activity Stack来管理多个ActivityQ所以呢Q同一时刻只会有最上的那个Activity是处于active或者running状态。其它的Activity都被压在下面了?br /><br />2.如果非活动的Activity仍是可见的(卛_果上面压着的是一个非全屏的Activity或透明的ActivityQ,它是处于paused状态的。在pȝ内存不的情况下Qpaused状态的Activity是有可被pȝ杀掉的。只是不明白Q如果它被干掉了Q界面上的显C又会变成什么模P看来下回有必要研I一下这U情况了?br /><br />3.几个事g的配对可以比较清楚地理解它们的关pRCreate与Destroy配成一对,叫entrie lifetimeQ在创徏时分配资源,则在销毁时释放资源Q往上一点还有Start与Stop一对,叫visible lifetimeQ表辄是可见与非可见这么一个过E;最上的就是Resume和Pauseq一对了Q叫foreground lifetimeQ表辄了是否处于激zȝ态的q程?br /><br />4.因此Q我们实现的Activityzc,要重载两个重要的ҎQonCreate()q行初始化操作,onPause()保存当前操作的结果?br /><br />除了Activity Lifecycle以外QAndroidq有一个Process Lifecycle的说明:<br /><br />在内存不的时候,Android是会d清理门户的,那它又是如何判断哪个process是可以清掉的呢?文中也提到了它的重要性排序:<br /><br />1.最Ҏ被清掉的是empty processQ空q程是指那些没有Activity与之l定Q也没有M应用E序lgQ如Services或者IntentReceiverQ与之绑定的q程Q也是说在q个process中没有Q何activity或者service之类的东西,它们仅仅是作Z个cacheQ在启动新的Activity时可以提高速度。它们是会被优先清掉的。因此徏议,我们的后台操作,最好是作成Service的Ş式,也就是说应该在Activity中启动一个ServiceL行这些操作?br /><br />2.接下来就是background activity了,也就是被stop掉了那些activity所处的processQ那些不可见的Activity被清掉的是安全的,pȝl持着一个LRU列表Q多个处于background的activity都在q里面,pȝ可以ҎLRU列表判断哪些activity是可以被清掉的,以及其中哪一个应该是最先被清掉。不q,文中提到在q个已被清掉的Activity又被重新创徏的时候,它的onCreate会被调用Q参数就是onFreeze时的那个Bundle。不q这里有一点不明白的是Q难道这个Activity被killedӞAndroid会帮它保留着q个Bundle吗?<br /><br />3.然后p到service process了,q是一个与Servicel定的进E,由startServiceҎ启动。虽然它们不为用h见,但一般是在处理一些长旉的操作(例如MP3的播放)Q系l会保护它,除非真的没有内存可用了?br /><br />4.接着又轮到那些visible activity了,或者说visible process。前面也谈到q个情况Q被Paused的Activity也是有可能会被系l清掉,不过相对来说Q它已经是处于一个比较安全的位置了?br /><br />5.最安全应该是那个foreground activity了,不到q不得已它是不会被清掉的。这Uprocess不仅包括resume之后的activityQ也包括那些onReceiveIntent之后的IntentReceiver实例?br /><br />在Android Application的生命周期的讨论中,文档也提C一些需要注意的事项Q因为Android应用E序的生存期q不是由应用本n直接控制的,而是由Androidpȝq_q行理的,所以,对于我们开发者而言Q需要了解不同的lgActivity、Service和IntentReceiver的生命,切记的是Q如果组件的选择不当Q很有可能系l会杀掉一个正在进行重要工作的q程?/span><img src ="http://m.tkk7.com/zhaojianhua/aggbug/355680.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/zhaojianhua/" target="_blank">建华</a> 2011-08-03 15:41 <a href="http://m.tkk7.com/zhaojianhua/archive/2011/08/03/355680.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>android 的短信数据库的读?/title><link>http://m.tkk7.com/zhaojianhua/archive/2011/02/23/344977.html</link><dc:creator>建华</dc:creator><author>建华</author><pubDate>Wed, 23 Feb 2011 07:25:00 GMT</pubDate><guid>http://m.tkk7.com/zhaojianhua/archive/2011/02/23/344977.html</guid><wfw:comment>http://m.tkk7.com/zhaojianhua/comments/344977.html</wfw:comment><comments>http://m.tkk7.com/zhaojianhua/archive/2011/02/23/344977.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/zhaojianhua/comments/commentRss/344977.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/zhaojianhua/services/trackbacks/344977.html</trackback:ping><description><![CDATA[android 的短信数据库的读?br /> android短信的数据库的Uri是不公开? dh时灰怸方便? q里做了下ȝ. <br /> 用adb指ommssms.db?data/data/com.android.providers.telephony/databases中pull出来<br /> l常使用到的表有<br /> canonical_addresses, sms, threads三个表格<br /> sms是存储着所有的短信, 主要的列有_id, thread_id, address, person, date, read, type, body <br /> 关于的sms的Uri?br /> 发g?content://sms/outbox<br /> 收g?content://sms/inbox<br /> 草稿?content://sms/draft<br /> conversations content://sms/conversations<br /> threads表存储着每一个短信对话的U程. 主要列有_id, date, message_count, recipient_ids, snippet, read<br /> recipient_ids 存放的是参与此次对话的person的id, 然而这个id不是通讯录里面的id, 而是canonical_addresses 的id. q就是canonical_addresses 表格的作?br /> threads ?uri: content://mms-sms/conversations?simple=true<br /> canonical_addresses ?uri content://mms-sms/canonical-addresses<br /> <img src ="http://m.tkk7.com/zhaojianhua/aggbug/344977.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/zhaojianhua/" target="_blank">建华</a> 2011-02-23 15:25 <a href="http://m.tkk7.com/zhaojianhua/archive/2011/02/23/344977.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>лǵվܻԴȤ</p> <a href="http://m.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> վ֩ģ壺 <a href="http://cswangli.com" target="_blank">ղ2021</a>| <a href="http://zzjiji.com" target="_blank">պav</a>| <a href="http://yxjcgs.com" target="_blank">鶹һѲվ</a>| <a href="http://wushicn.com" target="_blank">þþþþ޾ƷӰԺ</a>| <a href="http://zzz477.com" target="_blank">jjzz߲Ź</a>| <a href="http://8953y.com" target="_blank">AVվ</a>| <a href="http://guanxianedu.com" target="_blank">av뾫Ʒþþ </a>| <a href="http://77tok.com" target="_blank">67194ҹ</a>| <a href="http://ksyanhui.com" target="_blank">޹ƷYW߹ۿ</a>| <a href="http://miya77772.com" target="_blank">ɫվapp߹ۿ</a>| <a href="http://liulian88.com" target="_blank">AV߹ۿ</a>| <a href="http://www55xx.com" target="_blank">ѹ߹ۿ</a>| <a href="http://902578.com" target="_blank">98ƷȫѹۿƵ</a>| <a href="http://222xx8.com" target="_blank">Ʒ߹ۿ</a>| <a href="http://yanyingqiang.com" target="_blank">þþŷղa</a>| <a href="http://720880.com" target="_blank">Ů߿ѹۿ</a>| <a href="http://tianmao920.com" target="_blank">þþƷ</a>| <a href="http://hkcdk.com" target="_blank">AVһԧӰԺ </a>| <a href="http://se969.com" target="_blank">ĻĴȫƵ</a>| <a href="http://hivzx.com" target="_blank">У԰޴ɫС˵ϼ</a>| <a href="http://jsky163.com" target="_blank">91۲˽˳ӰԺ</a>| <a href="http://yw323.com" target="_blank">޳˸</a>| <a href="http://xiaochidaquan.com" target="_blank">114һëƬ</a>| <a href="http://72c5.com" target="_blank">ƷѦvƵ</a>| <a href="http://25gh.com" target="_blank">ҹþþþС˵ </a>| <a href="http://shnisda.com" target="_blank">Ƶ߹ۿ</a>| <a href="http://51cga.com" target="_blank">˳Ƶ</a>| <a href="http://xsdggzs.com" target="_blank">߳ˬaëƬ</a>| <a href="http://34007c.com" target="_blank">Ƶ</a>| <a href="http://wwwyy763.com" target="_blank">Ůwwwһ</a>| <a href="http://bj-tkld.com" target="_blank">ŷղۺ</a>| <a href="http://junyehome.com" target="_blank">޾ƷA߹ۿ</a>| <a href="http://dukane1688.com" target="_blank">ëƬƵѹۿ</a>| <a href="http://8mav1007.com" target="_blank">þþþƷ2019ѹۿ </a>| <a href="http://www55nana.com" target="_blank">Ļĸ </a>| <a href="http://0967c.com" target="_blank">ƷһëƬƵۿ</a>| <a href="http://chenglide.com" target="_blank">ձɫվwwwþ </a>| <a href="http://hnshlt.com" target="_blank">Ƶһ߲</a>| <a href="http://123470c.com" target="_blank">ɫһëƬ޻Ƭȫ</a>| <a href="http://xingqiu1.com" target="_blank">ҹҹƵ</a>| <a href="http://wenfaka.com" target="_blank">Aѹۿ</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>