Android中的Intent是什么? 有人能举个例子吗? intent的类型是什么,我们为什么要使用它们? 为什么intent在Android中如此重要?
当前回答
什么是意图?
它是传递给组件的一种消息或信息。它被用来启动一个活动,显示一个网页,发送短信,发送电子邮件等。
在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
其他回答
意图基本上是一种将数据从一个活动传递到另一个活动的方式
来自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之上的。
意图用于从一个活动启动另一个活动。它主要用于几个目的,例如从一个活动向另一个活动发送数据,以及用于触发目的。
它们基本上有两种类型
隐式意图。 明确的意图。
作为一个初学者,我知道这些,我认为这将给一些关于机器人意图的基本概念
什么是意图?
它是传递给组件的一种消息或信息。它被用来启动一个活动,显示一个网页,发送短信,发送电子邮件等。
在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
意图是对要执行的操作的抽象描述。它可以与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
还有更多的文章可用。
推荐文章
- 警告:API ' variable . getjavacompile()'已过时,已被' variable . getjavacompileprovider()'取代
- 安装APK时出现错误
- 碎片中的onCreateOptionsMenu
- TextView粗体通过XML文件?
- 如何使线性布局的孩子之间的空间?
- DSL元素android.dataBinding。enabled'已过时,已被'android.buildFeatures.dataBinding'取代
- ConstraintLayout:以编程方式更改约束
- PANIC: AVD系统路径损坏。检查ANDROID_SDK_ROOT值
- 如何生成字符串类型的buildConfigField
- Recyclerview不调用onCreateViewHolder
- Android API 21工具栏填充
- Android L中不支持操作栏导航模式
- 如何在TextView中添加一个子弹符号?
- PreferenceManager getDefaultSharedPreferences在Android Q中已弃用
- 在Android Studio中创建aar文件