没有合适的资源?快使用搜索试试~ 我知道了~
首页Android开发入门全攻略:打造首个应用
Android开发入门全攻略:打造首个应用
需积分: 1 0 下载量 52 浏览量
更新于2024-07-22
收藏 1.25MB PDF 举报
"《Android开发指南第一部》是一本针对Android初学者的优秀参考书籍。它全面介绍了Android平台,强调了其作为一个强大的应用程序开发环境,支持开发者使用Java语言构建创新的移动应用和游戏。该书的结构清晰,左侧导航栏列出了详尽的文档,覆盖了从基础概念到实际操作的各个阶段。 首先,入门部分引导读者理解Android的基本架构。Android应用程序由一系列独特的组件构成,如Activity(负责呈现用户界面)和Service(在后台独立运行的服务)。这些组件允许开发者为不同类型的设备提供适配性,确保应用程序能在各种规格和配置的设备上正常运行。 App Fundamentals是学习过程中的起点,它帮助新手建立起对应用程序整体运作原理的理解,包括应用程序的生命周期、用户交互以及数据管理等核心概念。紧接着,Building Your First App这一章节则直接指导开发者进行实战编程,通过创建首个应用程序来掌握实际编码技巧。 此外,Android的应用程序并非僵化不变,而是根据需求提供定制化的资源。这体现了Android的灵活性,开发者可以根据设备特性动态调整UI元素、加载图片资源或调整布局,以优化用户体验。适应性框架使得开发者能够针对不同的屏幕尺寸、分辨率和操作系统版本创建兼容性良好的应用。 《Android开发指南第一部》为Android新手提供了一个坚实的学习平台,无论是基础知识的学习还是实践经验的积累,都能在这本书中找到所需的指导。通过逐步深入,读者将逐步掌握Android开发的核心技术,从而踏上构建高质量移动应用的职业之路。"
资源详情
资源推荐
there's probably another app that does that and your app can use it, instead of
developing an activity to capture a photo yourself. You don't need to incorporate or even
link to the code from the camera app. Instead, you can simply start the activity in the
camera app that captures a photo. When complete, the photo is even returned to your
app so you can use it. To the user, it seems as if the camera is actually a part of your
app.
Android 系统设计的一个特殊的层面是任何应用都能够启动其他应用的组件。例如,如果
你想用户使用设备的相机去捕获一张图片,有可能您通过其他应用的去这么做,而不是自
己开发一个 Activity 去这么做。你不需要把相机应用的代码放到你的应用中去,而是改为
简单的启动相机应用的 Activity 去获得一张图片。当捕捉完成的时候,这张图片将返回到
你的应用中,所以你能够使用它。对于用户来讲,相机就好像是你的应用程序的一部分。
When the system starts a component, it starts the process for that app (if it's not already
running) and instantiates the classes needed for the component. For example, if your app
starts the activity in the camera app that captures a photo, that activity runs in the
process that belongs to the camera app, not in your app's process. Therefore, unlike
apps on most other systems, Android apps don't have a single entry point (there's no
main() function, for example).
当系统启动一个组建的时候,它开始一个这个应用的进程(如果他没有正在运行),并且实
例化这个组件所需要的类。例如说,如果你的应用启动一个 Camera 应用的 Activity 去不
活一张图片,该 Activity 属于相机应用的进程中,而不是在你的用用的进程中。因此,不
像其他大多数系统的应用程序,Android 应用程序没有一个单独的入口点(例如,没有
main()函数)
Because the system runs each app in a separate process with file permissions that
restrict access to other apps, your app cannot directly activate a component from another
app. The Android system, however, can. So, to activate a component in another app, you
must deliver a message to the system that specifies your intent to start a particular
component. The system then activates the component for you.
由于每个应用程序运行在独立于其它应用程序文件权限的系统中,你的呢应用程序不能直
接从另一个程序激活一个组件。但是 Android 系统可以,所以,要激活另一个应用程序的
组件,则必须将消息传递到你的 Intent 所指定的特定组件中,然后系统为你激活那个组
件。
1.1.1、Activating Components(激活组件)
Three of the four component types—activities, services, and broadcast receivers—are
activated by an asynchronous message called an intent. Intents bind individual
components to each other at runtime (you can think of them as the messengers that
request an action from other components), whether the component belongs to your app
or another.
四个组建类型中的三个——Activity、Service、BroadcastReceiver——通过调用一个
Intent 的异步消息来激活。Intents 在运行是绑定多个组件(你可以把它们看作是请求来自其
他组件的动作信使),无论这个组件是否属于你的应用。
An intent is created with an Intent object, which defines a message to activate either a
specific component or a specific type of component—an intent can be either explicit or
implicit, respectively.
一个 Intent 是一个 Intent 对象,它定义了一个消息来激活一个特定的组件或特定
类型
的
组件,意图可以是显式的或隐式的。
For activities and services, an intent defines the action to perform (for example, to "view"
or "send" something) and may specify the URI of the data to act on (among other things
that the component being started might need to know). For example, an intent might
convey a request for an activity to show an image or to open a web page. In some cases,
you can start an activity to receive a result, in which case, the activity also returns the
result in an Intent (for example, you can issue an intent to let the user pick a personal
contact and have it returned to you—the return intent includes a URI pointing to the
chosen contact).
对于 Activity 和 Service,意图定义了要执行的 action(例如,“查看”或“发送”的东西),并
且可以指定执行操作的数据的 URI(其中包括了正在启动的组件可能需要知道的)。例如,
一个意图可能传达给一个 Activity 显示一个图片或者打开一个网页的请求。在某些情况
下,你就可以启动一个 Activity 来获得的结果,在这种情况下,该 Activity 也返回结果中的
Intent(例如,你可以发出一个意图,让用户选择一个选择联系人,并将它返回给你——
返回意图包括一个指向选中的联系人的 URI)。
For broadcast receivers, the intent simply defines the announcement being broadcast (for
example, a broadcast to indicate the device battery is low includes only a known action
string that indicates "battery is low").
对于广播接收机,intent 只是定义正在发出的广播(例如,一个广播表示该设备电池电量
低时只包括已知的字符串,表示“电池电量低”)。
The other component type, content provider, is not activated by intents. Rather, it is
activated when targeted by a request from a ContentResolver. The content resolver
handles all direct transactions with the content provider so that the component that's
performing transactions with the provider doesn't need to and instead calls methods on
the ContentResolver object. This leaves a layer of abstraction between the content
provider and the component requesting information (for security).
其他的组件类型,Content Provider 不是通过 Intent 激活的。相反,它是通过一个
ContentResolver 发起的请求来激活的。Content Resolver 处理与 content Provider 的
所有直接的事务,并不需要 Content Provider 来执行事务,而是调用 ContentResolver
对象的方法。这是一个在 Content Provider 和请求信息的组件之间的一个抽象(为了安全
性)。
剩余37页未读,继续阅读
jane_dxj
- 粉丝: 3
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 构建Cadence PSpice仿真模型库教程
- VMware 10.0安装指南:步骤详解与网络、文件共享解决方案
- 中国互联网20周年必读:影响行业的100本经典书籍
- SQL Server 2000 Analysis Services的经典MDX查询示例
- VC6.0 MFC操作Excel教程:亲测Win7下的应用与保存技巧
- 使用Python NetworkX处理网络图
- 科技驱动:计算机控制技术的革新与应用
- MF-1型机器人硬件与robobasic编程详解
- ADC性能指标解析:超越位数、SNR和谐波
- 通用示波器改造为逻辑分析仪:0-1字符显示与电路设计
- C++实现TCP控制台客户端
- SOA架构下ESB在卷烟厂的信息整合与决策支持
- 三维人脸识别:技术进展与应用解析
- 单张人脸图像的眼镜边框自动去除方法
- C语言绘制图形:余弦曲线与正弦函数示例
- Matlab 文件操作入门:fopen、fclose、fprintf、fscanf 等函数使用详解
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功