Android培训翻译_与其它应用程序交互
本文是Android官方文档的翻译,采用中英文对照风格,原文参见 http://developer.android.com/intl/zh-CN/training/basics/intents/index.html
Dependencies and prerequisites
- Basic understanding of the Activity lifecycle (see Managing the Activity Lifecycle)
对Activity生命周期的基本认识(见 管理Activity生命周期)
You should also read
- Sharing Content
共享内容 - Integrating Application with Intents (blog post)
用Intent整合应用程序(博客文章) - Intents and Intent Filters
Intent和Intent过滤器
An Android app typically has several activities. Each activity displays a user interface that allows the user to perform a specific task (such as view a map or take a photo). To take the user from one activity to another, your app must use an Intent
to define your app's "intent" to do something. When you pass anIntent
to the system with a method such as startActivity()
, the system uses the Intent
to identify and start the appropriate app component. Using intents even allows your app to start an activity that is contained in a separate app.
一个Android应用程序通常有几个activity。每个activity显示一个用户接口,允许用户执行指定的任务(例如查看地图或拍照)。为了指引用户从一个activity到另一个activity,你的应用程序必须使用一个Intent来定义你的应用程序的“意图”是要做什么。当你使用一个方法,例如startActivity(),传递一个Intent到系统,系统使用Intent来标识并启动相应的应用程序组件。使用Intent甚至允许你的应用程序启动另一个独立程序中的activity。
An Intent
can be explicit in order to start a specific component (a specific Activity
instance) or implicit in order to start any component that can handle the intended action (such as "capture a photo").
Intent可以明确的启动一个指定的组件(一个指定的Activity实例),或者隐式的启动任何可以处理有目的行为的组件(例如"拍照")。
This class shows you how to use an Intent
to perform some basic interactions with other apps, such as start another app, receive a result from that app, and make your app able to respond to intents from other apps.
本课向你展示如何使用Intent与其它应用程序进行一些基本的交互,例如启动其它的应用程序,接收来自该应用程序的结果,使您的程序可以相应来自其它程序的Intent。
Lessons 课程
- Sending the User to Another App
将用户发送到其它程序 - Shows how you can create implicit intents to launch other apps that can perform an action.
演示如何创建隐式的Intent,启动其它的应用程序以执行一个动作。 - Getting a Result from an Activity
从Activity获取一个结果 - Shows how to start another activity and receive a result from the activity.
演示如何启动另一个活动,并接收该活动的结果。 - Allowing Other Apps to Start Your Activity
允许别的应用程序启动你的Activity - Shows how to make activities in your app open for use by other apps by defining intent filters that declare the implicit intents your app accepts.
展示如何使你的应用中的activity可以被其它应用打开并使用。 这通过定义Intent过滤器,声明你应用程序所可以接受的隐式意图来实现。