1.intent 6 items

action, data(uri &type),Component name,Extras,flags

2.data---uri & type

不管使用什么参数,action,type或者其他,关键问题就是。

所有的new activity启动,最终都需要Component name.

所以,intent可以分析得到Component name,就可以使用。

    private void sendBroadcast(long eventId, long begin, long end, String title){
Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon();
builder.appendEncodedPath("events/" + eventId);
Uri uri = builder.build();
Intent i = new Intent(EVENT_DETAIL_ACTION);
i.putExtra(EXTRA_EVENT_BEGIN_TIME, begin);
i.putExtra(EXTRA_EVENT_END_TIME, end);
i.putExtra(TITLE, title);
// i.setDataAndType(uri, EXTRA_TYPE);
i.setData(uri);
if (i.resolveActivity(getPackageManager()) != null) {
startActivity(i);
}
}

关于传递data的问题。一般情况下,uri和type只需要一个。

关键是,我们每个activtiy最好是指定处理的类型,当我们需要做隐示intent传递的时候。

        <activity android:name=".agenda.AgendaDetailActivity" >
<intent-filter>
<action android:name="com.xui.calendar.agenda_detail"></action>
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/event"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/event"/>
</intent-filter>
</activity>

但是我们可能只想传奇Uri给activtiy使用,这个时候,使用content类型的uri可以保证具有唯一性。

因为每个uri对应数据库,而数据库是有类型的。content_item_type.

进而ams可以通过数据库的类型进行匹配。

所以可以只传递uri的情况。

如果想同时传递uri & type。setdataandtype。

android intent 5.1的更多相关文章

  1. android Intent介绍

    Android中提供了Intent机制来协助应用间的交互与通讯,Intent负责对应用中一次操作的动作.动作涉及数据.附加数据进行描述,Android则根据此Intent的描述,负责找到对应的组件,将 ...

  2. android:Intent匹配action,category和data原则

    1.当你在androidmanifest里面定义了一个或多个action时 你使用隐式意图其他activity或者service时,规定你隐式里面的action必须匹配XML中定义的action,可以 ...

  3. Android Intent

    Intent在Android中的重要性不言而喻.本文主要总结下Intent使用过程中需要注意的一些问题. 1.隐式Intent AndroidManifest.xml声明时<intent-fil ...

  4. android intent和intent action大全

    1.Intent的用法:(1)用Action跳转1,使用Action跳转,如果有一个程序的AndroidManifest.xml中的某一个 Activity的IntentFilter段中 定义了包含了 ...

  5. Android总结篇系列:Android Intent

    Intent在Android中的重要性不言而喻.本文主要总结下Intent使用过程中需要注意的一些问题. 1.隐式Intent AndroidManifest.xml声明时<intent-fil ...

  6. 什么时候加上android.intent.category.DEFAULT

    什么时候加上android.intent.category.DEFAULT 1.要弄清楚这个问题,首先需要弄明白什么是implicit(隐藏) intent什么是explicit(明确) intent ...

  7. (转)android.intent.action.MAIN与android.intent.category.LAUNCHER

    android.intent.action.MAIN决定应用程序最先启动的Activity android.intent.category.LAUNCHER决定应用程序是否显示在程序列表里 在网上看到 ...

  8. android之android.intent.category.DEFAULT的用途和使用

    1.要弄清楚这个问题,首先需要弄明白什么是implicit(隐藏) intent什么是explicit(明确) intent. Explicit Intent明确的指定了要启动的Acitivity , ...

  9. 理解android.intent.action.MAIN 与 android.intent.category.LAUNCHER

    刚才看了一下sundy的视频<LLY110426_Android应用程序启动>,里面讲到luncher这个activity通过获取应用程序信息来加载应用程序,显示给用户,其中就是通过一个应 ...

  10. Android Intent的几种用法全面总结

    Android Intent的几种用法全面总结 Intent, 用法 Intent应该算是Android中特有的东西.你可以在Intent中指定程序要执行的动作(比如:view,edit,dial), ...

随机推荐

  1. 使用Html5+C#+微信 开发移动端游戏详细教程 :(一)序(关于作者创业失败的感想)

    说起梦想,我清楚的记得2012年7月初毕业,拿到毕业证书的那天果断买好了次日南下去深圳的绿皮火车票,500多块,26个小时车程.第二天就拖上行李到了深圳. 一开始的想法仅仅是过去想见见世面,学习点新技 ...

  2. 基于openssl的单向和双向认证

    1.前言 最近工作涉及到https,需要修改nginx的openssl模块,引入keyless方案.关于keyless可以参考CloudFlare的官方博客: https://blog.cloudfl ...

  3. Android 学习笔记之Volley开源框架解析(五)

    学习内容: 1.PoolingByteArrayOutputStream 2.ByteArrayPool 3.HttpStack 4.HurlStack 5.HttpHeaderParser   前面 ...

  4. Windows魔法堂:解决“由于启动计算机时出现页面文件配置问题.......”

    一.前言 昨晚终于在VirtualBox中安装好Win7了,但在系统启动后弹出窗报“由于启动计算机时出现页面文件配置问题.......”,于是度娘一下.以下记录以供日后查阅. 二.原因 网上说的是在使 ...

  5. Angular系列----AngularJS入门教程02:静态模板(转载)

    为了说明angularJS如何增强了标准HTML,我们先将创建一个静态HTML页面模板,然后把这个静态HTML页面模板转换成能动态显示的AngularJS模板. 在本步骤中,我们往HTML页面中添加两 ...

  6. SQL Server 诊断查询-(5)

    Query #57 Buffer Usage -- Breaks down buffers used by current database by object (table, index) in t ...

  7. [Bootstrap]7天深入Bootstrap(1)入门准备

    由于申请了一个域名,一个云主机,开始弄个人网站. 发现Bootstrap非常方便,和重要,故开始学习与分享关于Bootstrap的技术. 推个广告 个人网站:http://www.neverc.cn ...

  8. CSS布局 -- 左侧定宽,右侧自适应

    左侧定宽,右侧自适应 有很多种方法可以实现 缩小窗口试试看? 方案一: 左边左浮动,右边加个margin-left 查看 demo <!DOCTYPE html PUBLIC "-// ...

  9. learning sql (second edition) script

    create database bank; use bank; /* begin table creation */ create table department (dept_id smallint ...

  10. 泛函编程(6)-数据结构-List基础

    List是一种最普通的泛函数据结构,比较直观,有良好的示范基础.List就像一个管子,里面可以装载一长条任何类型的东西.如需要对管子里的东西进行处理,则必须在管子内按直线顺序一个一个的来,这符合泛函编 ...