Intent是Android中各组件跳转的重要方式,一般可悲用于启动活动、启动服务、以及发送广播等场景。

#显示Intent

主要主要用于启动已知的组件

//发送方 

Intent intent = new Intent(FirstActivity.this, SecondActivity.class);

intent.putExtra("extra_data", data);

startActivity(intent);

//接收方

Intent intent = getIntent();

String data = intent.getStringExtra("extra_data");

#示Intent

(1)action

(2)category

(3)data:scheme、host、path、type

Intent intent = new Intent("com.example.activitytest.ACTION_START");

intent.addCategory("com.example.activitytest.MY_CATEGORY");

//如果不添加Category,那么默认使用DEFAULT

startActivity(intent);

//AndroidManifest.xml

//用来响应Intent

<activity android:name=".SecondActivity" >

<intent-filter>

<action android:name="com.example.activitytest.ACTION_START" />

<category android:name="android.intent.category.DEFAULT" />

</intent-filter>

</activity>

##使用Intent启动浏览器

Intent intent = new Intent(Intent.ACTION_VIEW);

intent.setData(Uri.parse("http://www.baidu.com"));

startActivity(intent);

Android复习笔记--Intent的更多相关文章

  1. Android学习笔记-Intent(一)

    Intent对象在Android官方API这样描述:It is a passive data structure holding an abstract description of an opera ...

  2. Android复习笔记--Activity

    #Activity注册 Android四大组件(Activity,Service,Broadcast Receiver, Content Provider)都需要在AndroidManifest中注册 ...

  3. Android学习笔记--Intent

    Intent是android四大组件之间交互的一种重要方式.Intent可以指明当前要执行的动作,也可以指明要传递的数据.Intent可以用来启动活动,启动服务,发送广播. Intent分为两种:1. ...

  4. Android复习笔记--架构与版本

    #Android架构: 1. Linux 内核层 Android 系统是基于Linux 2.6 内核的,这一层为Android 设备的各种硬件提供了底 层的驱动,如显示驱动.音频驱动.照相机驱动.蓝牙 ...

  5. Android学习笔记Intent二

    上篇随笔大概写了了Intent学习的大纲,这篇通过代码理解下Intent的ComponentName属性的使用 ComponentName,中文意思是组件名称,通过Intent的setsetCompo ...

  6. 【转】Pro Android学习笔记(十二):了解Intent(下)

    解析Intent,寻找匹配Activity 如果给出component名字(包名.类名)是explicit intent,否则是implicit intent.对于explicit intent,关键 ...

  7. 【转】Pro Android学习笔记(十):了解Intent(上)

    目录(?)[-] Intent基本含义 系统的Intent Android引入了Intent的概念来唤起components,component包括:1.Activity(UI元件) 2.Servic ...

  8. 【转】Android Activity和Intent机制学习笔记----不错

    原文网址:http://www.cnblogs.com/feisky/archive/2010/01/16/1649081.html Activity Android中,Activity是所有程序的根 ...

  9. Android Activity和Intent机制学习笔记

    转自 http://www.cnblogs.com/feisky: Activity Android中,Activity是所有程序的根本,所有程序的流程都运行在Activity之中,Activity具 ...

随机推荐

  1. DedeCms文档关键词替换,优先替换长尾关键词

    本文教大家:dedecms文档关键词维护之关键词出现多次,只给出现的第一个加链接的 举例:当文章中出现了一百次台历时,按官方的原理,他会给一百个台历都加上链接的.dedecms这如何是好? 解决方法( ...

  2. Windows Azure HDInsight 使用技巧

    Windows Azure HDInsight是一个面向大数据的PaaS服务,是PaaS版本的Hadoop.HDInsight是微软与Hortonworks合作的产物.可以理解为Hortonworks ...

  3. UESTC 395 Dynamic Query System --Treap

    题意:让你维护一个集合,有8种操作: 1.  I x  插入一个数 2.  R x 删除x 3.  S 输出总的数个数(集合大小) 4.  L x  查询小于x的数的个数 5.  W k  查询集合中 ...

  4. WAMP中phpMyAdmin登陆不了问题的解决方法

    WAMP中phpMyAdmin登陆不了问题的解决方法

  5. NODE.JS开发指南学习笔记2

    1.核心模块 核心模块是Node.js的心脏,由一些精简高效的库组成,为其提供了基本的API.2.全局对象 global.所有的的全局变量都是其属性.其根本的作用是作为全局变量的宿主.3.全局变量 1 ...

  6. ExcelHelper

    NPOI下载:http://pan.baidu.com/s/1JNAGm 最新封装类: 2016-03-14 1.添加对OleConn的读 private static string connstri ...

  7. HTML 学习笔记 CSS样式(链接)

    我们能够以不同的方法为链接设置样式. 设置链接的样式 能够设置链接样式的 CSS 属性有很多种(例如 color, font-family, background 等等).链接的特殊性在于能够根据它们 ...

  8. Use Cursor

    declare : CURSOR cursor_name IS select_statement ; open : OPEN cursor_name if the query returns no r ...

  9. Github 简明教程

    http://www.runoob.com/w3cnote/git-guide.html http://rogerdudler.github.io/git-guide/index.zh.html

  10. Win10删除 6个多余文件夹

    下面附上注册表地址,HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace ...