1.intent(意图)可以用来创建启动3种类型的基本情况:①To start an activity:启动一个活动②To start an service③To start an broadcast

2.intent types:-----first:Explicit intent:指的是当你知道你的类的名字,你可以使用显式意图,for instance:start an activity or start a service to download a file in                       background;

        -----second:Implicit intent : 可以不指定一个明确的名字,采用一个明确的action 来指定要执行的操作,当其他的apps获取到这个action后执行所代表的动作,

                      他会在清单文件中看看那个能接受这个action。

  PS:当启动一个service时,必须用显式意图!

3.如果一个隐式意图未被其他的程序处理,在startActivity()方法调用时,程序将崩溃

4.PendingIntent可用作三种情况:①通知信息的Intent②Home Screen的Intent,(app widget:应用程序小部件)③定义将来某个时间执行的代码。e.gAlarmManager

5.PendingIntent.getActivity() for an Intent that starts an Activity.

6.Alarm Clock(闹钟),创建一个闹钟,使用ACTION_SET_ALARM

      EXTRA_RINGTONEcontent: URI specifying a ringtone to use with the alarm,or VALUE_RINGTONE_SILENT for no ringtone.

        To use the default ringtone, do not specify this extra.

            EXTRA_VIBRATEA boolean specifying whether to vibrate for this alarm.

      EXTRA_SKIP_UIA boolean specifying whether the responding app should skip its UI when setting the alarm. If true, the app should bypass any                confirmation UI and simply set the specified alarm.

显式

public void createAlarm(String message, int hour, int minutes) {
Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM)
.putExtra(AlarmClock.EXTRA_MESSAGE, message)
.putExtra(AlarmClock.EXTRA_HOUR, hour)
.putExtra(AlarmClock.EXTRA_MINUTES, minutes);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />

隐式

<activity ...>
<intent-filter>
<action android:name="android.intent.action.SET_ALARM" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

7.Create a timer(定时器)创建一个倒计时定时器ACTION_SET_TIMER(PS:最低支持版本Android4.4)

public void startTimer(String message, int seconds) {
Intent intent = new Intent(AlarmClock.ACTION_SET_TIMER)
.putExtra(AlarmClock.EXTRA_MESSAGE, message)
.putExtra(AlarmClock.EXTRA_LENGTH, seconds)
.putExtra(AlarmClock.EXTRA_SKIP_UI, true); //true 表示不跳转到定时器界面
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}

其他如上...

8.Show all alarms(显示所有闹钟)ACTION_SHOW_ALARMS

<activity ...>
<intent-filter>
<action android:name="android.intent.action.SHOW_ALARMS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

只有一个隐式声明意图

9.Add a calender event(在用户的日历中增加新事件)action:ACTION_INSERT

public void addEvent(String title, String location, Calendar begin, Calendar end) {
Intent intent = new Intent(Intent.ACTION_INSERT)
.setData(Events.CONTENT_URI)
.putExtra(Events.TITLE, title)
.putExtra(Events.EVENT_LOCATION, location)
.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, begin)
.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, end);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
<activity ...>
<intent-filter>
<action android:name="android.intent.action.INSERT" />
<data android:mimeType="vnd.android.cursor.dir/event" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

Android-Intent and Intent Filters的更多相关文章

  1. Android开发-API指南-Intent和Intent过滤器

    Intents and Intent Filters 英文原文:http://developer.android.com/guide/components/intents-filters.html 采 ...

  2. android intent和intent action大全

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

  3. Android安全之Intent Scheme Url攻击

    0X01 前言 Intent scheme url是一种用于在web页面中启动终端app activity的特殊URL,在针对intent scheme URL攻击大爆发之前,很多android的浏览 ...

  4. Intent和Intent Filters

    什么是Intent     Intent是android开发中的重要对象,它作为一个信息承载对象存在.     我们可以在使用其他一些组件的时候从Intent获取行为响应的准则(即应该做什么东西,如何 ...

  5. Android复习笔记--Intent

    Intent是Android中各组件跳转的重要方式,一般可悲用于启动活动.启动服务.以及发送广播等场景. #显示Intent 主要主要用于启动已知的组件 //发送方  Intent intent = ...

  6. Android 中的 Intent 简介

    Intent是Android程序中各组件之间进行交互的一种重要方式,它不仅可以指明当前组件想要执行的动作,还可以在不同组件之间传递数据. ------------------------------- ...

  7. Android开发之Intent略解

    Intent是一种运行时绑定(run-time binding)机制,它能在程序运行过程中连接两个不同的组件.通过Intent,你的程序可以向Android表达某种请求或者意愿,Android会根据意 ...

  8. Android学习之 Intent详解

    一. Intent 作用 Intent 是一个将要执行的动作的抽象的描述,一般来说是作为参数来使用,由Intent来协助完成android各个组件之间的通讯.比如说调用startActivity()来 ...

  9. Android中的Intent Filter匹配规则介绍

    本文主要介绍了隐式Intent匹配目标组件的规则,若有叙述不清晰或是不准确的地方希望大家指出,谢谢大家: ) 1. Intent简介 Intent用于在一个组件(Component,如Activity ...

  10. Android中的Intent详解

    前言: 每个应用程序都有若干个Activity组成,每一个Activity都是一个应用程序与用户进行交互的窗口,呈现不同的交互界面.因为每一个Acticity的任务不一样,所以经常互在各个Activi ...

随机推荐

  1. 基于node 搭建http2服务

    1.准备工作:安装node2.安装http2: npm install http2 -g安装完成后,在安装目录中appData/Roaming>npm>node_modules>ht ...

  2. Mysql选择合适的存储引擎

    Myisam:默认的mysql插件式存储引擎.如果应用是以读操作和插入操作为主,只有很少的更新和删除操作,并且对事务的完整性.并发性要求不是很高,那么选择这个存储引擎是非常合适的.Myisam是在we ...

  3. ML——决策树模型

    决策树模型 优点:高效简单.易于理解,可以处理不相关特征. 缺点:容易过拟合,训练集在特征上是完备的 决策树过程:特征选择.划分数据集.构建决策树.决策树剪枝 决策树选择最优的划分特征,将数据集按照最 ...

  4. poj3204Ikki's Story I - Road Reconstruction(最大流求割边)

    链接 最大流=最小割  这题是求割边集 dinic求出残余网络 两边dfs分别以源点d找到可达点 再以汇点进行d找到可达汇点的点 如果u,v为割边 那么s->u可达 v->t可达 并且为饱 ...

  5. mac osx上为qt应用生成debug symbol

    mac平台上,希望Qt编译的release程序也能包含debug symbol,这样出问题以后便于查找问题 开始按照http://doc.qt.io/qt-4.8/mac-differences.ht ...

  6. DAX:New and returning customers

    The New and Returning Customers pattern dynamically calculates the number of customers with certain ...

  7. Java异常归纳

      1.使用Tomcat运行“播报哥架构”出现的两大异常 1.1 监听器异常 详细情况:部署好Maven项目,启动TOMCAT提示如下错误 java.lang.ClassNotFoundExcepti ...

  8. react开启一个项目 webpack版本出错

    npx create-react-app my-app cd my-app npm start 在命令行里执行以上语句就可(前两天刚刚发现,最新版的react对webpack的版本要了新要求,大概是他 ...

  9. billu_b0x靶场刷题

    https://www.vulnhub.com/ 里面有很多安全环境,只要下载相关镜像,在虚拟机上面搭建运行就可以练习对应靶场了. 第一步.信息收集 nmap扫描内网开放80端口的存活主机  nmap ...

  10. 必知干货:Web前端应用十种常用技术你全都知道吗?

    Web前端应用十种常用技术,随着JS与XHTML的应用普及,越来越多的web界面应用技术出现在网站上,比如我们常见的日历控件,搜索下拉框等,这些web界面应用技术大大的丰富了网站的表现形式,本文将为您 ...