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. AtCoder Grand Contest 013 E - Placing Squares

    题目传送门:https://agc013.contest.atcoder.jp/tasks/agc013_e 题目大意: 给定一个长度为\(n\)的木板,木板上有\(m\)个标记点,距离木板左端点的距 ...

  2. linux中用户组和用户

    linux中用户组和用户 1.介绍 在我们的linux系统,有很多用户组,也可以手动创建用户组,不同的用户组下面有很多的用户. 2.创建用户组及有关的命令 groupadd phpzu:创建一个php ...

  3. 18.3.2从Class上获取信息(属性)

    package d18_3_1; import java.lang.reflect.Field; import java.util.Arrays; /** * 获取Class对应类所包含的属性的四个方 ...

  4. subline应用之常用插件

    汉化插件:ChineseLocalzations IMESupport插件:解决软件输入法跟随问题 SublimeREPL插件:可以用于运行和调试一些需要交互的程序如python SublimeCod ...

  5. python staticmethod&classmethod

    python中的这两种方法都通过修饰器来完成 静态方法: 不需要传递类对象或者类的实例 可以通过类的实例.方法名a().foo()或者类名.方法a.foo()名来访问 当子类继承父类时,且实例化子类时 ...

  6. asp.net MVC中实现调取web api

    public ActionResult Index(string city) { if (string.IsNullOrEmpty(city)) { city = "上海"; } ...

  7. AJPFX总结heap和stack有什么区别?

    栈是后进先出的线性表结构,存取速度比堆快.创建对象的时候new一个对象,引用存在栈上具体的内容存在堆上. 栈与堆都是Java用来在RAM中存放数据的地方.与C++不同,Java自动管理栈和堆,程序员不 ...

  8. 简要记录下localStorage在项目中的应用之一

    localStorage作为HTML5本地存储web storage特性的API之一,主要作用是将数据保存在客户端中.localStorage保存的数据,一般情况下是永久保存的,也就是说只要采用loc ...

  9. js事件、Js中的for循环和事件的关系、this

    一.js事件  1.事件 用户在网页中所触发的行为 鼠标滑动种类很多,键盘.表单特列: 点击:onclick 鼠标进入:onmouseenter 鼠标离开:onmouseleave 鼠标悬浮:onmo ...

  10. #pragma使用分析

    #pragma简介 #pragma用于指示编译器完成一些特定的动作 #pragma所定义的很多指示字是编译器特有的 #pragma在不同的编译器间是不可移植的 预处理器将忽略它不认识的#pragma指 ...