61阅读

category是什么意思-“android.intent.category.DEFAULT”的目的是什么?

发布时间:2017-12-07 所属栏目:default.aspx是什么

一 : “android.intent.category.DEFAULT”的目的是什么?

原文地址:“android.intent.category.DEFAULT”的目的是什么?作者:莫云伦1、要弄清楚这个问题,首先需要弄明白什么是implicit(隐藏)intent什么是explicit(明确) intent。

Explicit Intent明确的指定了要启动的Acitivity ,比如以下Java代码:
Intent intent= new Intent(this, B.class)

Implicit Intent没有明确的指定要启动哪个Activity ,而是通过设置一些IntentFilter来让系统去筛选合适的Acitivity去启动。

2、intent到底发给哪个activity,需要进行三个匹配,一个是action,一个是category,一个是data。

理论上来说,如果intent不指定category,那么无论intentfilter的内容是什么都应该是匹配的。但是,如果是implicitintent,android默认给加上一个CATEGORY_DEFAULT,这样的话如果intentfilter中没有android.intent.category.DEFAULT这个category的话,匹配测试就会失败。所以,如果你的activity支持接收implicit intent的话就一定要在intentfilter中加入android.intent.category.DEFAULT。

例外情况是:android.intent.category.MAIN和android.intent.category.LAUNCHER的filter中没有必要加入android.intent.category.DEFAULT,当然加入也没有问题。

我们定义的activity如果接受implicit intent的话,intentfiler就一定要加上android.intent.category.DEFAULT这个category。


来自另一篇文章的解释:

在写 AndroidManifest.xml 的时候,一直没有搞明白,什么时候要给Activityandroid.intent.category.DEFAULT 过滤器,现在才明白。

--------------------------------------------------------------------------------
Android treats all implicit intents passed to startActivity() as ifthey contained at least one category:"android.intent.category.DEFAULT" (the CATEGORY_DEFAULT constant).Therefore, activities that are willing to receive implicit intentsmust include "android.intent.category.DEFAULT" in their intentfilters
--------------------------------------------------------------------------------

意思是说,每一个通过 startActivity() 方法发出的隐式 Intent 都至少有一个 category,就是"android.intent.category.DEFAULT",所以只要是想接收一个隐式 Intent 的 Activity都应该包括 "android.intent.category.DEFAULT" category,不然将导致 Intent匹配失败。

从上面的论述还可以获得以下信息:
1、一个 Intent 可以有多个 category,但至少会有一个,也是默认的一个 category。
2、只有 Intent 的所有 category 都匹配上,Activity 才会接收这个 Intent。


最新历史版本 :Android中的category大全

返回文档

Api Level 3(SDK 1.5)和Api Level 4(SDK1.6):

Xml代码
  1. android.intent.category.ALTERNATIVE
  2. android.intent.category.BROWSABLE
  3. android.intent.category.DEFAULT
  4. android.intent.category.DEVELOPMENT_PREFERENCE
  5. android.intent.category.EMBED
  6. android.intent.category.HOME
  7. android.intent.category.INFO
  8. android.intent.category.LAUNCHER
  9. android.intent.category.MONKEY
  10. android.intent.category.OPENABLE
  11. android.intent.category.PREFERENCE
  12. android.intent.category.SELECTED_ALTERNATIVE
  13. android.intent.category.TAB

Api Level 5(SDK 2.0)增加的:

Xml代码
  1. android.intent.category.CAR_DOCK
  2. android.intent.category.DESK_DOCK

Api Level 6和7没有变化。

Api Level 8(SDK 2.2)增加的:

Xml代码
  1. android.intent.category.CAR_MODE

二 : Category Theory 是做什么的?

[category是什么意思]Category Theory 是做什么的?
听说数学老师的一个朋友在 CMU 做 category theory,结果拿的是美国国防部的 funding,突然对 category theory 产生了好奇。请问 category theory 到底是什么?做 category 的和做 set theory 的是不是同一帮人?
下面就看看www.61k.com小编为您搜集整理的参考答案吧。

网友匿名用户[category是什么意思]Category Theory 是做什么的?给出的答复:
Category theory 跟 set theory 是 "两种" 东西, 一般来说不是一帮人. Category theory 是一种正确的东西...它是做什么的呢? 因为它 "正确", 所以可以做很多, 比如说:

告诉你 "不同的" 很多数学为什么其实是 "相同的", 这就是各种各样的对偶性, 等价函子, 比如说下面这三样事物是 "相同的", 但要在范畴论里才比较好看清楚: 1. 一维复流形; 2. 光滑投影复代数曲线; 3. 复数域上的一维函数域.
告诉你事情的 "正确的" 发展是什么, 比如说, Weil 考虑他的著名的有限域上代数簇猜想时洞察到一种 "合适的" 上同调理论能 "自然的" 解决这个问题. 而只是使用代数簇上最 "自然的" Zariski 拓扑则过于 "粗糙" 而做不到, 这迫使人们去思考, 到底什么是拓扑? 什么是开集? 哦, 这些 "对象" 其实是不重要的, 一个开集应该被视为一个开嵌入, 态射才是重要的, 于是 "拓扑" 这么底层的概念也被有效推广, 得到了 Grothendieck 拓扑以及 site (一个范畴带上一个 Grothendieck 拓扑) 的概念, 在这之上便建立了 étale 上同调, l-adic 上同调, 并最后解决了 Weil 猜想. 这一工作涉及众多大数学家, 出了至少两枚 Fields medal, 牵扯许多 Fields medalists, 目前也仍在热烈发展.
告诉你一个东西其实是什么东西, 比如说, 经典的同调代数是处理环上的模范畴的. 而很多时候人们需要在一种被称为 Abelian category 的范畴上去使用同调代数, 为什么用来定义 Abelian category 的公理会这么有效? 人们发现, 其实某种程度上我们实际都是在处理环上的模范畴, 因为每个 Abelian category 都是某个模范畴的满子范畴, 这是 Mitchell embedding theorem.


网友匿名用户[category是什么意思]Category Theory 是做什么的?给出的答复:
范畴论是对抽象的数学概念进行进一步抽象
Category theory范畴论
离应用较远,和国防没有直接关系,但值得投钱。


网友匿名用户[category是什么意思]Category Theory 是做什么的?给出的答复:
现在很多人在做\infty-范畴

我觉得范畴论还是很有趣的
比如2-范畴,来源之一是基本群胚。
推广到n-范畴会出现一些障碍
而定义无穷范畴就更复杂了。

其实我也不懂………

拿范畴论思想做事还是很系统的
可以搜索科学家用范畴论,一门开放课程


网友兔八哥[category是什么意思]Category Theory 是做什么的?给出的答复:
据说计算机里有用。


网友匿名用户[category是什么意思]Category Theory 是做什么的?给出的答复:
从Quora上看见一个回答:Category theory is an abstract framework for (among other things) describing other fields of mathematics.

Rather than give a definition, let's start with an example. The category Set has "objects," which are sets, and "morphisms" or "arrows," which are functions between the sets. It has a few other interesting properties, notably:
If there's a function from some set to some set , and there's also a function , then there's a function .
Composition is associative: for functions , , and , we have that .
For every set , there's a special function , which is the identity for function composition; that is, and .

Now, if you change "set" to "object," "function" to "morphism," you have the definition of a category. The key thing is that while sets have a bunch of other properties, such as Cartesian products and function spaces (sets of functions), not every category has all that structure. However, many categories share some common bits of structure, and this lets us say things about all the categories that share that structure.

The other important thing is that we describe this structure without looking "inside" the objects — all we're allowed to see is the structure of the morphisms.

It might help to consider a few other categories
Grp, the category of groups. The objects are groups, and the morphisms are group homomorphisms. Note that group homomorphisms are closed under composition, and that every group has an identity homomorphism.
Rel, whose objects are sets and whose morphisms are relations. (Again, note identity and associativity.)
Top, whose objects are topological spaces and whose morphisms are continuous functions. (Again, note . . .)
Met, whose objects are metric spaces and whose morphisms are metric maps. (Again, . . .)
Every partially ordered set is a category: The objects are the elements of the set, and there is a unique morphism for every pair of elements and such that . Note that the poset axioms give us identity morphisms and associativity.

What makes category theory potentially interesting is that many general definition in terms of categories often correspond to the specific definitions within several categories. For example, a morphism is an isomorphism if it has an inverse morphism such that and . We just defined isomorphisms quite abstractly, in terms of relationships between morphisms, but that definition corresponds to bijections in Set, group isomorphisms in Grp, homeomorphisms in Top, and isometries in Met. Many other definitions from specific fields of mathematics can be generalized to category theory, and theorems in category theory are then theorems in every category having suitable axioms.

There's a lot more to category theory — I don't know that I've even captured the basic flavor. However, you might get the idea that to a category theorist, your branch of mathematics is merely one point in hers.


网友匿名用户[category是什么意思]Category Theory 是做什么的?给出的答复:
set theory is 0-category theory.


网友黄博文[category是什么意思]Category Theory 是做什么的?给出的答复:
范畴论。实变和泛函等抽象理论的进一步抽象。计算机方面也有应用,被称为计算机的前沿科学。
如果你知道haskell的话,会有涉及。

本文标题:category是什么意思-“android.intent.category.DEFAULT”的目的是什么?
本文地址: http://www.61k.com/1068808.html

61阅读| 精彩专题| 最新文章| 热门文章| 苏ICP备13036349号-1