ImageVerifierCode 换一换
格式:DOC , 页数:10 ,大小:117.50KB ,
资源ID:6624922      下载积分:10 金币
快捷注册下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/6624922.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请

   平台协调中心        【在线客服】        免费申请共赢上传

权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。

注意事项

本文(Android 基本组件.doc)为本站上传会员【xrp****65】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

Android 基本组件.doc

1、Application Fundamentals(应用程序基本原理) Android applications are written in the Java programming language. The compiled Java code — along with any data and resource files required by the application — is bundled by the aapt tool into an Android package, an archive file marked by an .apk suffix. This fil

2、e is the vehicle for distributing the application and installing it on mobile devices; it's the file users download to their devices. All the code in a single .apk file is considered to be one application. In many ways, each Android application lives in its own world: · By default, every applicati

3、on runs in its own Linux process. Android starts the process when any of the application's code needs to be executed, and shuts down the process when it's no longer needed and system resources are required by other applications. · Each process has its own virtual machine (VM), so application code

4、runs in isolation独立的 from the code of all other applications. · By default, each application is assigned a unique Linux user ID. Permissions are set so that the application's files are visible only to that user and only to the application itself — although there are ways to export them to other ap

5、plications as well.(默认情况下每个应用程序分配唯一的一个linux user ID. 应用程序中的文件,只对于user和应用程序本身是完全许可的——但是也有许多方式去export他们给其他的应用程序) It's possible to arrange for two applications to share the same user ID, in which case they will be able to see each other's files. To conserve system resources, applications with the same

6、 ID can also arrange to run in the same Linux process, sharing the same VM(2个应用程序共享同一个User ID 是可以的,这种情况下,双方可以看到对方的文件。拥有相同ID的系统文件,应用程序,运行在同一个Linux进程中,共享同一个VM) Application Components(应用程序组件) A central feature of Android is that one application can make use of elements of other applications (provided

7、 those applications permit it). Android一个核心功能是,一个应用程序能够使用其他应用程序可用的元素(前提是那些应用程序允许).For example, if your application needs to display a scrolling list of images and another application has developed a suitable(匹配的) scroller and made it available to others, you can call upon that scroller to do the wor

8、k, rather than develop your own. Your application doesn't incorporate the code of the other application or link to it.你的应用程序不需要把其他应用程序的代码包含进来或者link to it. Rather, it simply starts up that piece of the other application when the need arises.你的应用程序只需要启动那个你需要的应用程序块即可. For this to work, the system must

9、 be able to start an application process when any part of it is needed, and instantiate the Java objects for that part. Therefore, unlike applications on most other systems, Android applications don't have a single entry point for everything in the application Android应用程序没有标记一个入口点(no main() function

10、 for example). Rather, they have essential components that the system can instantiate and run as needed.当然啦,系统运行时候需要实例化一些必要的组件. There are four types of components: Activities An activity presents a visual user interface for one focused endeavor the user can undertake. For example, an activity

11、might present a list of menu items users can choose from or it might display photographs along with their captions. A text messaging application一个短信应用 might have one activity that shows a list of contacts to send messages to, a second activity to write the message to the chosen contact, and other ac

12、tivities to review old messages or change settings. Though they work together to form a cohesive紧密的 user interface, each activity is independent独立的,不受约束 of the others. Each one is implemented as a subclass of the Activity base class. An application might consist of just one activity or, like the t

13、ext messaging application just mentioned, it may contain several.一个应用也许由一个activity组成,或者像刚刚提及的短信应用一样,由多个activity组成. What the activities are, and how many there are depends, of course, on the application and its design. Typically, one of the activities is marked as the first one that should be present

14、ed to the user when the application is launched. Moving from one activity to another is accomplished by having the current activity start the next one.从一个activity到另一个activity是通过当前activity开启另一个来完成的. Each activity is given a default window to draw in. Typically, the window fills the screen, but it mi

15、ght be smaller than the screen and float on top of other windows. An activity can also make use of additional windows — for example, a pop-up dialog that calls for a user response in the midst(中间) of the activity, or a window that presents users with vital information when they select a particular i

16、tem on-screen.当user选择一个详情选项窗口显示出和他相关的重要信息. The visual content of the window is provided by a hierarchy of views窗口的视觉内容有一些有层次的view提供 — objects derived from the base View class.这些对象由基本的View类派生. Each view controls a particular rectangular space within the window. Parent views contain and organize the

17、layout of their children. 父容器控制和组织子元素的布局.Leaf views (those at the bottom of the hierarchy) draw in the rectangles they control and respond to user actions directed at that space. 最外层的view直接响应用户的操作.Thus, views are where the activity's interaction with the user takes place.因此,这些view是用户activity交互的地方. F

18、or example, a view might display a small image and initiate an action when the user taps that image. 例如,当user点击一个view中的小图片的时候开启一个动作.Android has a number of ready-made views that you can use安卓有一些已经创建好的控件可以给你使用 — including buttons, text fields, scroll bars, menu items, check boxes, and more. A view h

19、ierarchyz(层次) is placed within an activity's window by the Activity.setContentView() method. The content view is the View object at the root of the hierarchy. (See the separate User Interface document for more information on views and the hierarchy.) Services A service doesn't have a visual(可视化

20、的) user interface, but rather runs in the background for an indefinite period of time.无限周期的时间. For example, a service might play background music as the user attends to other matters, 例如,当用户处理其他事务的时候一个service也许在后台播放音乐or it might fetch data over the network or calculate something and provide the resu

21、lt to activities that need it.或者正在运算并且提供这个运算的结果给活动.Each service extends the Service base class. A prime初期 example is a media player playing songs from a play list. The player application would probably或许 have one or more activities that allow the user to choose songs and start playing them. Howeve

22、r, the music playback重放 itself would not be handled by an activity because users will expect期待 the music to keep playing even after即使 they leave the player and begin something different. To keep the music going, the media player activity could start a service to run in the background. The system wou

23、ld then keep the music playback service running even after the activity that started it leaves the screen. It's possible to connect to (bind to) an ongoing service (and start the service if it's not already running).可以连接到一个正在运行的service(或者开启一个没有运行的service).While connected, you can communicate通讯,传达 w

24、ith the service through an interface that the service exposes.当连接上了的时候,你可以通过service提供的接口和它通讯.For the music service, this interface might allow users to pause, rewind, stop, and restart the playback. Like activities and the other components, services run in the main thread of the application process

25、 So that they won't block other components or the user interface,they often spawn another thread for time-consuming tasks(like music playback).像activity和其他组件一样,service运行在应用进程的主线程上.所以它不会阻止其他组件或用户界面, 他们通常产生其他的线程处理长时间运行的任务(例如音乐回放). See Processes and Threads, later. Broadcast receivers A broadcast r

26、eceiver is a component that does nothing but receive and react to broadcast announcements.接收广播通知并作出反映. Many broadcasts originate起源 in system code — for example, announcements that the timezone has changed, that the battery is low, that a picture has been taken, or that the user changed a language pr

27、eference.例如,时区已经改变了,电池电量低,图片已经删除了,或者用户改变了语言设置的通知. Applications can also initiate创建 broadcasts — for example, to let other applications know that some data has been downloaded to the device and is available for them to use.例如,让其他应用知道一些数据已经被下载到设备上并且可以被它们使用了. An application can have any number of bro

28、adcast receivers to respond to any announcements it considers important. 一个应用有很多广播接收者去响应一些通知是非常重要的.All receivers extend the BroadcastReceiver base class. Broadcast receivers do not display a user interface. However, they may start an activity in response to the information they receive, or they may

29、 use the NotificationManager to alert the user. Notifications can get the user's attention in various ways — flashing the backlight, vibrating the device, playing a sound, and so on.They typically place a persistent icon in the status bar, which users can open to get the message.广播接收者没有用户界面,但它会开启一个a

30、ctivity去对接收到的信息作出响应,或者它可以使用NotificationManager去(弹出信息)提示用户.这些Notification 有多种方式可以引起用户的注意——例如高亮背景,震动设备,发出声音,等等.一般会有一个图标在状态栏上(像qq有消息了),用户可以点开这个图标得到信息. Content providers A content provider makes a specific set of the application's data available to other applications. The data can be stored in the fi

31、le system, in an SQLite database, or in any other manner that makes sense. The content provider extends the ContentProvider base class to implement a standard set of methods that enable other applications to retrieve and store data of the type it controls. However, applications do not call these met

32、hods directly.应用程序不能直接使用调用这些方法. Rather they use a ContentResolver object and call its methods instead. A ContentResolver can talk to any content provider; it cooperates with the provider to manage any interprocess communication that's involved.一个ContentResolver可以对话任何content provider;它配合content provi

33、der去管理进程间的信息交互. See the separate Content Providers document for more information on using content providers. Whenever there's a request that should be handled by a particular component, Android makes sure that the application process of the component is running, starting it if necessary, 无论何时当有一个

34、请求(通过contentResolver)指定一个组件(content provider)处理时,android确保这个组件的应用进程运行(或当需要的时候开启它), and that an appropriate(适当的) instance of the component is available, creating the instance if necessary.并且有一个合适的可用组件(content provider)被创建. Activating components: intents Content providers are activated when they're

35、 targeted by a request from a ContentResolver. The other three components — activities, services, and broadcast receivers — are activated by asynchronous(异步) messages called intents. An intent is an Intent object that holds the content of the message. For activities and services, it names the action

36、 being requested and specifies the URI of the data to act on, among other things.对于activity和service而言,activity和service的intent在其他的应用之间,按照被要求的和指定的uri数据行动.For example, it might convey a request for an activity to present an image to the user or let the user edit some text. 例如:intent可以为一个activity传输一个请求显

37、示一张图片给用户或者让应用编辑一些文字.For broadcast receivers, the Intent object names the action being announced. For example, it might announce to interested parties that the camera button has been pressed.对于broadcast receivers而言,行动的intent对象要被声明.例如:它能够向用户(interested parties)宣布,摄像头按钮已经被按下了. There are separate单独 met

38、hods for activating each type of component: · An activity is launched (or given something new to do) by passing an Intent object to Context.startActivity() orActivity.startActivityForResult(). The responding activity can look at the initial intent that caused it to be launched by calling its getInt

39、ent()method. 作出响应的activity能够找到最初加载出它的intent,通过getIntent()方法.Android calls the activity's onNewIntent() method to pass it any subsequent intents.Android调用activity对象的onNewIntent()方法传递它自己(activity对象)给一个随后出现的新的intent(见onNewIntent方法帮助),注:onNewIntent()方法也可以用intent.setFlag方法代替使用,见帮助 · One activity often

40、starts the next one. If it expects期望 a result back from the activity it's starting, it calls startActivityForResult() instead ofstartActivity(). For example, if it starts an activity that lets the user pick a photo, it might expect to be returned the chosen photo. The result is returned in an Intent

41、 object that's passed to the calling activity's onActivityResult()method. · A service is started (or new instructions指令 are given to an ongoing service正在运行的服务) by passing an Intent object to Context.startService(). Android calls the service's onStart() method and passes it the Intent object. Simil

42、arly, an intent can be passed to Context.bindService() to establish an ongoing connection between the calling component and a target service. The service receives the Intent object in an onBind() call. (If the service is not already running, bindService() can optionally start it.) For example, an ac

43、tivity might establish a connection with the music playback service mentioned earlier so that it can provide the user with the means (a user interface) for controlling the playback. The activity would call bindService() to set up that connection, and then call methods defined by the service to affec

44、t the playback. A later section, Remote procedure calls, has more details about binding to a service. · An application can initiate a broadcast by passing an Intent object to methods like Context.sendBroadcast(), Context.sendOrderedBroadcast(), andContext.sendStickyBroadcast() in any of their vari

45、ations. Android delivers the intent to all interested broadcast receivers by calling their onReceive()methods. For more on intent messages, see the separate article, Intents and Intent Filters. Shutting down components A content provider is active only while it's responding to a request from a Co

46、ntentResolver. And a broadcast receiver is active only while it's responding to a broadcast message. So there's no need to explicitly shut down these components. Activities, on the other hand, provide the user interface. They're in a long-running conversation会话 with the user and may remain保持 active

47、 even when idle空闲, as long as the conversation continues. Similarly, services may also remain running for a long time. So Android has methods to shut down activities and services in an orderly way: · An activity can be shut down by calling its finish() method. One activity can shut down another ac

48、tivity (one it started with startActivityForResult()) by calling finishActivity().一个activity可以关闭另一个activity,例如调用startActivityForResult方法之后,调用finishActivity方法关闭弹出的activity · 代码: · 打开联系人列表,获得选中的联系人 · Intent intent = new Intent(Intent.ACTION_PICK,ContactsContract.Contacts.CONTENT_URI); · this

49、startActivityForResult(intent, 1); · this.finishActivity(1); · A service can be stopped by calling its stopSelf() method, or by calling Context.stopService(). Components might also be shut down by the system when they are no longer being used or when Android must reclaim memory for more ac

50、tive components. A later section, Component Lifecycles, discusses this possibility and its ramifications in more detail. Intent filters An Intent object can explicitly name a target component. If it does, Android finds that component (based on the declarations in the manifest file) and activates i

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服