(转)关于androidManifest.xml的概叙以及intent-filter的详细分析

转自:http://www.cnblogs.com/wytings/p/4083463.html

 

AndroidManifest.xml配置文件对于Android应用开发来说是比较细但又很重要的基础知识,本文旨在总结该配置文件中常用到的几个属性,以便日后查阅,至于那些比较细的属性,主要是平时开发比较少用便不列举,如果自己有需要直接在eclipse中直接“alt+/”就好了……

下面是一个比较通用的AndroidManifest.xml文件样例(所建的工程目录是Test),

复制代码
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.test"
    android:versionCode="1"
    android:versionName="1.0" >

    <!-- SDK版本的要求 -->
    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="21" />
    
    <!-- 获取系统相关的权限配置 如果不知道系统有多少属性,不用那么麻烦去搜,直接在name便签的双引号里alt+/就好,多直接~ -->
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    
    <!-- 应用配置细节 
      icon是图标;
      label是程序名称显示在titlebar中的
      theme是整个程序的主题,这里是自己文件定义的主题,如果想用android的就是@android:style/Theme再加alt+/就可以随便选了
   -->
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <!-- Activity配置 -->
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <data android:host="MainActivity"/>
            </intent-filter>
        </activity>
        
        <!-- Service配置 -->
        <service >
            <intent-filter >
                <action />
                <category />
                <data />
            </intent-filter>
        </service>
        
        <!-- Receive配置 -->
        <receiver >
            <intent-filter />
            <meta-data />
        </receiver>
        
        <!-- Provider配置 -->
        <provider >
            <grant-uri-permission />
            <meta-data />
            <path-permission />
        </provider>
        
        <!-- 程序需要的外部库 -->
        <uses-library />
        
    </application>

</manifest>
复制代码

 

     纵观上面的各个系统组件配置,基本都有一个Intent-filter属性,来对系统中各种乱七八糟的intent进行过滤处理。因为android系统中会时时刻刻发送着各种消息各种intent,有些是系统发的有些是各个程序发的,怎么从那么多的消息中获取自己想要的?那就过滤,Intent-filter就是起这个作用。下面我们来详细问题一下这个Intent-filter的相关属性,虽然各个组件的Intent-filter有差别,但是了解大概后,基本都差不多,举一反三,触类旁通嘛。

     Intent消息还包含有名称、动作、数据、类别几个重要属性,同时这几个点因过滤的标签的不同而有一些差别。

  <action>标签用于描述具体消息的名称;

  <category>标签用于表示能处理消息组件的类别;

  <data>标签则用于描述消息需要处理的数据格式,支持使用正则表达式来限定数据来源;

例如以下是一个activity的intent-filter:

<intent-filter>  
    <action android:name="wytings msg" />  
    <category android:name="android.intent.category.DEFAULT" />  
    <data mimeType="*/*" />  
</intent-filter>  

只要系统中有程序发出的intent的action为wytings msg这个activity就可以收到。

category设置的是默认配置,一般category主要就是android.intent.category.DEFAULT和android.intent.category.LAUNCHER两个(前者是默认配置,看action怎么设置,就怎么启动,后者是代表的第一个启动的基本都得和<action android:name="android.intent.action.MAIN" />一起用),其他的看自己需求,要是还是不知道还是alt+/就好了。

 

data中设置了处理类型,意思就是消息我收到了,如果不是我处理的类型,我依然不干活。比如我们把上面的action设置为android.intent.action.SEND(意思是当我们点发送的时候,系统就会调用这个activity,还有个前提是发送的文件得是它支持的,这里是什么都文件类型都支持)

Android-Sensor源码分析总结(1) 4,应用开发总结。 阅读详情

相关推荐

Protobuf性能优化5大必学技巧

Protobuf通信优化的5大核心技巧:1)精简字段,只保留必要数据;2)高频字段优先使用1-15编号节省空间;3)用整数替代浮点数控制精度;4)临时字段单独管理不入主协议;5)善用proto3空值策略和repeated去重。优化要点包括字段编号分配、数据类型选择和消息粒度控制,通过精简字段和高效存储可显著提升性能。建议遵循"高频小号、低频高号"的编号原则,并分离业务字段与临时字段。

本博客聚焦游戏开发技巧、创业实战心得及大学热门课程干货。这里既有技术深度,也有思维广度,无论你是开发者、创业者还是高校学子,都能在这里找到适合自己的成长之路! 1551

【intent-filter】AndroidManifest中<intent-filter>标签的 部分作用

AndroidManifest.xml中intent-filter标签的作用

qq_21882885的博客 1620

FISCO-BCOS配置及使用控制台

如果因为网络问题长时间无法下载,请尝试:curl -#LO https://gitee.com/FISCO-BCOS/console/raw/master-2.0/tools/download_console.sh && bash download_console.sh。为了可以更加方便快捷,所以HelloWorld合约已经被内置了,位于控制台下面的contracts/solidity/HelloWorld.sol。用于获取和设置name的值,合约代码如下。部署成功会返回合约地址。

qq_51562644的博客 831

关于androidManifest.xml的概叙以及intent-filter的详细分析

AndroidManifest.xml配置文件对于Android应用开发来说是比较细但又很重要的基础知识,本文旨在总结该配置文件中常用到的几个属性,以便日后查阅,至于那些比较细的属性,主要是平时开发比较少用便不列举,如果自己有需要直接在eclipse中直接“alt+/”就好了…… 下面是一个比较通用的AndroidManifest.xml文件样例(所建的工程目录是Test), <?x...

weixin_30567225的博客 178

【ESP32-IDF笔记】20-配置以太网网络(W5500)

基于ESP32IDF和官方的ethernet驱动,配置W5500以太网驱动芯片,实现ESP32的有线网络

别看了,就这些信息 3471

AWS RDS 介绍 三)创建 RDS 实例

AWS RDS 介绍 共分为 7 个部分, 其中 第 3部分重点介绍,如何创建一个RDS 实例。 三) AWS RDS 试用MySQL http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_GettingStarted.CreatingConnecting.MySQL.

XuYongshi02的专栏 7646

android四大组件-----Service的认识(IntentService的使用)

service的概念 1、service组件是可执行的程序,也是有自己的生命周期,是四大组件常用组件之一。创建、配置service和Activity的过程相似 service的作用 1、Service非常适用于去执行那些不需要和用户交互而且还要长期运行在后台的任务 service的特点 1、Service默认线程为UI线程,不要在Service中执行耗时的操作,除非你在Service中创...

Hunter2916的博客 945

C语言获取硬件信息(CPU序列号,硬盘序列号,网卡IP、MAC地址、是否插入网线)

本文主要介绍Linux和Windows下使用C语言获取各种硬件信息,包括CPU序列号、硬盘序列号、网卡信息(包括网卡名字、IP地址、MAC地址、网卡是否插入网线等)。

叶落花枯的博客 9378

AndroidManifest.xml 中的intent-filter

隐式启动Activity的intent到底发给哪个activity,需要进行三个匹配,一个是action,一个是category,一个是data,可以是全部或部分匹配 同样适用于Service和BroadcastReceiver,下面是以Activity为例 MainActivity.java --主Activity TestActivity.java --需要隐式启动的Ac

luohai859的专栏 1万+

命令行执行YOLO训练命令报错:1.PermissionError: [WinError 5] 拒绝访问 2.OMP: Error#15: Initializing libiomp5md.dll...

(已解决!)报错:1.PermissionError: [WinError 5] 拒绝访问 2.OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.

Gpengyuyan的博客 1124

使用Typora时LaTeX内联公式简单汇总

0、前言 在使用Typora写笔记时,有时候需要添加上LaTeX排版的公式。以下是整理出的一份简单笔记,方便记忆不清楚时查阅。笔记暂时不够完善,之后再补充。 注:有些公式语法KateX不能解析,但在Typora中可以使用(不用在意) 1、一些基本内联公式 位置关系 展示 LaTeX 说明 x2x^{2}x2 x^{2} 右上标 x2x_{2}x2​ x_{2} 右下标 2x{}^{2}x2x {}^{2}x 左上标 2x{}_{2}x2​x {}_{2}x 左下标

白白旧维的博客 4438

Android开发必备: Intent-Filter详解

Android中<intent-filter>是AndroidManifest.xml中用于声明组件可响应Intent规则的配置标签。其核心作用是让系统知道组件能处理什么请求,通过<action>、<category>、<data>三个子标签定义匹配规则。一个Intent要匹配过滤器,必须同时满足这三个标签的规则。常见应用场景包括:定义应用入口Activity、处理网页链接、接收系统广播等。在Android12+中,支持隐式Intent的组件必须显式设置and

上市公司前技术负责人,20 年软硬件深耕 + 百人研发团队管理经验,名校理工科背景加持。从技术攻坚到团队掌舵,沉淀海量项目实战与管理心得,专注分享软硬件干货、疑难问题解决方案,既是靠谱知识传播者,也盼链接优质项目共成长。 1400

VAY 是 SAP 自动科目确定(OBYC-GBB)中的科目修改码,专用于带科目分配对象的销售订单发货场景,核心是触发 “Dr 成本要素科目(如销售费用 / 特定成本对象) Cr 库存商品” 的分录,

摘要:VAY是SAP中用于带科目分配对象(如成本中心、WBS)的销售订单发货的科目修改码,与标准VAX场景不同,它生成"借成本要素科目/贷库存商品"的分录。配置路径为OBYC-GBB-VAY,需确保借方科目为成本要素。典型业务场景包括免费样品、项目专用发货等。常见问题包括VAY未触发或科目记账错误,需检查销售订单科目分配、移动类型设置及OBYC配置。特殊场景建议单独配置科目以便费用分析。

金牌架构师 1253

android中Manifest.xml中的intent-filter作用

注意: 隐式启动Activity的intent到底发给哪个activity,需要进行三个匹配,一个是action,一个是category,一个是data,可以是全部或部分匹配 同样适用于Service和BroadcastReceiver,下面是以Activity为例 MainActivity.java --主Activity TestActivity.java --需要隐式

chajinglong的专栏 3084

AI学习指南RAG篇(19)-API调用与集成

通过上述API调用示例,您可以方便地将RAGFlow与其他系统集成,实现数据集管理、文档处理、会话管理等功能。希望本文的介绍能帮助您更好地理解和使用RAGFlow的API。

俞兆鹏的博客 2545

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

android mainfest配置,以及intent—filter中讲解

android mainfest配置,以及intent—filter中讲解

gehongfeide的博客 1511

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

行为变更 | 了解 Android 12 中的 intent-filter

Android 12 一个重要的变更是提高应用和系统的安全性,这个变更影响了所有目标版本为 Android 12 的应用。在 AndroidManifest.xml 文件中注册的 Acti...

Android开发者 1968

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

AndroidManifest.xml文件详解(intent-filter)

语法(SYNTAX): &lt;intent-filterandroid:icon="drawable resource" android:label="string resource" android:priority="integer"&gt; . . .&lt;/intent-filter&gt; 被包含于(CONTAINED IN): &lt...

编程资料大全 461

Android基础知识之Manifest中的Intent-filter元素

原文:http://android.eoe.cn/topic/android_sdk :指定活动、服务、或者广播接收者能支持的intent的类型。一个意图过滤器声明了其父组件的能力——一个活动或者服务能做什么,以及一个接收者能接收哪种类型的广播。它打开能接收指定类型的意图的组件,同时过滤掉不符合条件的组件。 :大部分过滤器通过、或者等子元素描述其内容。 :要查看关于过滤器更详细的描述,请参考...

weixin_33924220的博客 243

AndroidManifest.xml中的intent-filter过滤器

当Intent在组件间传递时,组件如果想告知Android系统自己能够响应和处理哪些Intent,那么就需要用到IntentFilter对象。 IntentFilter对象负责过滤掉组件无法响应和处理的Intent,只将自己关心的Intent接收进来进行处理。 IntentFilter实行“白名单”管理,即只列出组件乐意接受的Intent,但IntentFilter只会过滤隐式Intent,显式...

weixin_33910434的博客 900

AndroidManifest.xml文件详解(data)

语法(SYNTAX): &lt;dataandroid:host="string" android:mimeType="string" android:path="string" android:pathPattern="string" android:pathPrefix="string" android:port="string" android:

编程资料大全 499
上一篇: (转)AndroidManifest.xml文件详解(service)
下一篇: [Android]You need to use a Theme.AppCompat theme on AlertDialog creation
jameskaron
博客等级 码龄20年 31粉丝 663原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值