android培训文档提纲(一)

最近项目快要进入开发阶段了,杂七杂八的事情比较多,另外还要兼顾一下android的培训和struts2的源码,有点忙不过来了,要多努力才行

这2天在准备android的培训文档,其实就是把《Androidinaction》上的要点归纳一下,之前做技术预研的时候买了几本android相关的书,感觉这本最好,虽然配套的代码差一些,所以就打算主要用这本书做培训材料了

只是把书里的要点摘要出来,作为培训内容的提纲,所以就不往论坛上帖了,免得被人投了隐藏,大家太喜欢投隐藏了,哎

1、内置应用和开发的应用,没有区别

2、LinuxKernel-->DalvikVM-->Applications

3、Kernel:硬件抽象层,同时提供了进程、内存、文件系统管理等核心服务

Runtime:DalvikVM,运行时环境

Codelibraries:浏览器、数据库、绘图、影音

Managers:Activities、Views、Telephony等管理器

Hardware-->LinuxKernel-->Runtime&Libraries-->ApplicationManagers-->Applications

4、Android基于LinuxKernel,运行在DalvikVM里

5、四种核心组件:Activity、Service、Provider、Receiver

6、AbestpracticeistolaunchServicesonaperiodicoras-neededbasis,triggeredbyasystemalarm,andthenhavetheServiceterminatewhenitstaskiscomplete

7、在manifest.xml文件里注册的Receiver组件,不需要应用启动,就可以被触发

8、每个AndroidApplication跑在一个单独的进程里

9、在OS资源短缺的时候,Application所在的进程,有可能会被kill,不同状态的进程的优先级有区别

10、android应用不是跑在jvm里,而是跑在DalvikVM里,所有java字节码要转换成.dex文件格式

11、strings这些资源也是被编译成binary

12、YoucandefinelayoutandviewsdirectlyincodeorinalayoutXMLresourcefile

13、youdon’thavetouseanXMLfileatall;instead,youcandefineallyourlayoutandViewconfigurationdirectlyincode,asJavaobjects.ThistechniqueisusedinapplicationswhereadynamicGUIisrequired.Generallyspeaking,it’softeneasier(andbetterpractice)touseanXMLlayoutresourceforeachActivity.AnXMLlayoutfiledefinesViewobjects,organizedintoahierarchicaltreestructure.Afterthey’redefinedinrelationtotheparentlayout,eachviewcanthenbeinflatedatruntime

14、Androidemploysahandyadapterconceptusedtolinkviewsthatcontaincollectionswithanunderlyingdatasource

15、AnAdapterisacollectionhandlerthatreturnseachiteminthecollectionasaView

16、EveryprocessrunningontheAndroidplatformisplacedonastack.WhenyouuseanActivityintheforeground,thesystemprocessthathoststhatActivityisplacedatthetopofthestack,andthepreviousprocess(theonehostingwhateverActivitywaspreviouslyintheforeground)ismoveddownonenotch

17、Itdecideswhichonestogetridofbasedonasimplesetofpriorities:

1TheprocesshostingtheforegroundActivityisthemostimportant.

2AnyprocesshostingavisiblebutnotforegroundActivityisnextinline.

3AnyprocesshostingabackgroundActivityisnextinline.

4AnyprocessnothostinganyActivity(orServiceorBroadcastReceiver)isknownasanemptyprocessandislastinline.

18、adbshelldumpsysactivity

19、IftheprocessyourActivityisinfallsoutoftheforeground,it’seligibletobekilledandit’snotuptoyou;it’suptotheplatform’salgorithm,basedonavailableresourcesandrelativepriorities

20、

1onCreate()

CalledwhentheActivityiscreated.Setupisdonehere.AlsoprovidedisaccesstoanypreviouslystoredstateintheformofaBundle

2onRestart()

CallediftheActivityisbeingrestarted,ifit’sstillinthestack,ratherthanstartingnew

3onStart()

CalledwhentheActivityisbecomingvisibleonthescreentotheuser

4onResume()

CalledwhentheActivitystartsinteractingwiththeuser(Thismethodisalwayscalled,whetherstartingorrestarting)

5onPause()

CalledwhentheActivityispausingorreclaimingCPUandotherresources.ThismethodiswhereyoushouldsavestateinformationsothatwhenanActivityisrestarted,itcanstartfromthesamestateitwasinwhenitquit

6onStop()

CalledtostoptheActivityandtransitionittoanonvisiblephaseandsubsequent

lifecycleevents

7onDestroy()

CalledwhenanActivityisbeingcompletelyremovedfromsystemmemory.ThismethodiscalledeitherbecauseonFinish()isdirectlyinvokedorthesystemdecidestostoptheActivitytofreeupresources

21、it’simportanttoknowthatonPause()isthelastopportunityyouhavetocleanupandsavestateinformation.TheprocessesthathostyourActivityclasseswon’tbekilledbytheplatformuntilaftertheonPause()methodhascompleted,buttheymightbekilledthereafter

22、Thesystemwillattempttorunthroughallofthelifecyclemethodseverytime,butifresourcesarespiralingoutofcontrol,asdeterminedbytheplatform,afirealarmmightbesoundedandtheprocessesthatarehostingactivitiesthatarebeyondtheonPause()methodmightbekilledatanypoint

23、Inadditiontopersistentstate,youshouldbefamiliarwithonemorescenario:instancestate.InstancestatereferstothestateoftheUIitself.TheonSaveInstanceState()methodiscalledwhenanActivitymightbedestroyed,sothatatafuturetimetheinterfacestatecanberestored

24、耗时比较多的工作,应该在UIThread之外完成,实现的方法是使用Handler类

25、android支持自定义View组件

26、InAndroid,screenlayoutisdefinedintermsofViewGroupand

LayoutParamsobjects.ViewGroupisaViewthatcontainsotherviews(haschildren)andalsodefinesandprovidesaccesstothelayout

相关推荐