Intent学习(1)
来源:互联网 发布:淘宝直通车没流量 编辑:程序博客网 时间:2024/05/22 14:06
<span style="color: rgb(90, 90, 90); font-family: "microsoft yahei"; font-size: 25.2px; font-weight: 600; line-height: 27.72px; white-space: pre-wrap; background-color: rgb(255, 255, 255);">一、Intent的定义</span>
1.Intent是一种在不同组件之间传递的请求消息,是应用程序发出的请求和意图。他不仅可以**指明当前组件想要执行的意图**,动作,还可以**在不同组件之间传递数据**。
2.Intent是一种运行时绑定(runtime binding)机制,它能在程序运行的过程中连接两个不同的组件。通过Intent,你的程序可以向Android表达某种请求或者意愿,Android会根据意愿的内容选择适当的组件来响应。
3. Intent不仅可用于应用程序之间,也可用于应用程序内部的activity, service和broadcast receiver之间的交互
4. Intenet大致可以分为两种,显示Intent和隐式Intent
二、Intent的简单使用
1.Activity
Intent intent = new Intent( FirstActivity.this , SecondActivity. class );
<pre name="code" class="html"><span style="white-space:pre"></span><span style="font-size:24px;">startActivity(intent);</span>
2. Service
启动服务
<span style="font-size:24px;"><span style="white-space:pre"></span> Intent intent = new Intent(Activity.this, MyService.class); startService(intent);</span>
停止服务
<span style="font-size:24px;"><span style="white-space:pre"></span>Intent intent = new Intent(Activity.this, MyService.class); stopService(intent);</span>
3. 广播
<span style="font-size:24px;">Intent intent = new Intent("com.example.broadcasttest.MY_BROADCAST");</span>
<span style="font-size:24px;">//自定义广播,AndroidManifest文件中符合此调节的广播接收器,接收此条广播</span>
<span style="font-size:24px;">sendBroadcast(intent);</span>
0 0
- Intent学习(1)
- Intent学习(2)
- Android学习(1)——Intent Flag介绍 intent.addFlags()
- Android开发学习——显式intent和隐式intent(1)
- Intent学习笔记(一)
- android学习三(Intent)
- Intent学习
- Intent学习
- Intent学习
- Intent学习
- Intent学习
- Intent 用法(1)
- Intent(1)
- intent与intent filter学习
- android学习笔记1——Intent
- android学习笔记(六) intent
- Android学习总结(一)---Intent
- Android学习笔记(7):Hello Intent
- 如何优化appium-IOS的自动化测试运行的速度
- 如何用maven创建nexus私服并将包打包发布到私服
- java中String 的==和equals;String直接赋值和使用new String()
- Java常考面试题
- 坚持#第24天~回黄陂了
- Intent学习(1)
- How To Use Codelite
- READING NOTE: Rethinking the Inception Architecture for Computer Vision
- python(五)常用模块学习
- Android studio中控制台输出乱码
- 面向对象知识点回顾
- Leetcode 136. Single Number
- 18. 4Sum
- Section 1.3 Greedy Algorithm