Android中的Intent是什么? 有人能举个例子吗? intent的类型是什么,我们为什么要使用它们? 为什么intent在Android中如此重要?


当前回答

意图是对要执行的操作的抽象描述。它可以与startActivity一起使用来启动一个Activity,与broadcastIntent一起使用来将它发送到任何感兴趣的BroadcastReceiver组件,与startService(Intent)或bindService(Intent, ServiceConnection, int)一起使用来与后台服务通信。

欲了解更多详情,请参阅以下链接:

1). http://developer.android.com/reference/android/content/Intent.html

2) http://developer.android.com/guide/topics/intents/intents-filters.html

3). http://www.vogella.de/articles/AndroidIntent/article.html

还有更多的文章可用。

其他回答

一个Android应用程序可以包含零个或多个活动。当应用程序有多个活动时,通常需要从一个活动导航到另一个活动。在Android中,你通过所谓的意图在活动之间导航。你可以通过使用putExtra()将一些数据传递给你想要通过intent启动的活动。

意图是对要执行的操作的抽象描述。它可以与startActivity一起使用来启动一个Activity,与broadcastIntent一起使用来将它发送到任何感兴趣的BroadcastReceiver组件,与startService(Intent)或bindService(Intent, ServiceConnection, int)一起使用来与后台服务通信。

欲了解更多详情,请参阅以下链接:

1). http://developer.android.com/reference/android/content/Intent.html

2) http://developer.android.com/guide/topics/intents/intents-filters.html

3). http://www.vogella.de/articles/AndroidIntent/article.html

还有更多的文章可用。

什么是意图?

它是传递给组件的一种消息或信息。它被用来启动一个活动,显示一个网页,发送短信,发送电子邮件等。

在android中有两种类型的intent:

隐式意图 明确的意图

隐式意图用于调用系统组件

例子

Intent i = newIntent(android.content.Intent.ACTION_VIEW,Uri.parse(“http://www.amazon.com”));

startActivity(i);

显式意图用于调用活动类。

例子

Intent Intent = newIntent (this, SecondActivity.class);

startActivity(intent);

你可以阅读更多

http://www.vogella.com/tutorials/AndroidIntent/article.html#intents_overview http://developer.android.com/reference/android/content/Intent.html

Intent是一个类,用来绑定执行某些操作的信息。

示例:当用户在活动中执行此类操作时,将数据从一个活动传递给另一个活动

目前的活动。

来自2013年Android构建者峰会上关于Android IPC/Binder框架的深入研究

在一些短小而有效的语句中可以理解其意图

Android supports a simple form of IPC(inter process communication) via intents Intent messaging is a framework for asynchronous communication among Android components (activity, service, content providers, broadcast receiver ) Those components may run in the same or across different apps (i.e. processes) Enables both point-to-point as well as publish subscribe messaging domains The intent itself represents a message containing the description of the operation to be performed as well as data to be passed to the recipient(s).

在这篇文章中,android架构师Dianne Hackborn给出了一个简单的答案,即它实际上是一个数据容器。

从android架构的角度来看:

Intent是一个用于进程间通信的数据容器。从android架构的角度来看,它是建立在Binder之上的。