@SuppressLint("NewApi")和@TargetApi()的区别

阿里云Windows服务器部署网站全流程:从IIS配置到安全上线 Web服务器是承载网站应用、处理HTTP请求的核心软件。其工作原理是监听特定网络端口,接收客户端请求,并返回相应的网页、文件或动态生成的内容。在Windows Server环境中,IIS(Internet Information Services)作为微软官方Web服务器,凭借其与操作系统深度集成、图形化管理界面和对ASP.NET等微软技术栈的良好支持,成为许多开发者和运维人员的首选。其技术价值在于提供了稳定、可扩展的托管平台,支持从简单的静态网站到复杂的企业级Web应用。在云服务器普及的今天,将IIS部署 阅读详情

在Android代码中,我们有时会使用比我们在AndroidManifest中设置的android:minSdkVersion版本更高的方法,此时编译器会提示警告,解决方法是在方法上加上@SuppressLint("NewApi")或者@TargetApi()。

那他们之间有什么区别呢,很简单,

@SuppressLint("NewApi")屏蔽一切新api中才能使用的方法报的android lint错误

@TargetApi() 只屏蔽某一新api中才能使用的方法报的android lint错误

举个例子,某个方法中使用了api9新加入的方法,而项目设置的android:minSdkVersion=8,此时在方法上加@SuppressLint("NewApi")和@TargetApi(Build.VERSION_CODES.GINGERBREAD)都可以,以上是通用的情况。

而当你在此方法中又引用了一个api11才加入的方法时,@TargetApi(Build.VERSION_CODES.GINGERBREAD)注解的方法又报错了,而@SuppressLint("NewApi")不会报错,这就是区别。


当然,不管你使用了哪个注解,作用仅仅是屏蔽android lint错误,所以在方法中还要判断版本做不同的操作,比如:

[java] view plain copy
  1. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {  
  2.             //  
  3.         } else {// Pre GINGERBREAD  
  4.             //  
  5.         }  
GEE开发之ERA5(气温、降水、压力、风速等)数据获取和分析 前言:ERA5主要提供DAILY和MONTHLY两大类别数据,其中主要包括气温、降水、压力、风速等。 阅读详情

相关推荐

混合示教长短时记忆网络的车辆轨迹预测研究

论文"混合示教长短时记忆网络的车辆轨迹预测研究"中数据处理及MTF-LSTM模型实现代码,模型在Pytorch框架下实现。

ColinFhz的博客 1448

@SuppressLint("NewApi")

本文转载https://blog.youkuaiyun.com/archer_zoro/article/details/54314913 在开发中我们经常可以看到这种标记 @SuppressLint("NewApi") 基本上是代码中用到了高于该app最低支持版本的api  但往往,出现的情况是这样的:  1. 用到了高版本的api  2. 编译器提示出错,出来一个小红线  3. 根据提示,其中一个...

jinpeng9001的博客 1182

【VS2017】“LNK1104 cannot open file ‘python39_d.lib‘ “

记录一下编译调用了python代码的C语言源程序时遇到的问题 版本:以python3.9.1为例 先确保你安装了python的debug版本,如果没有,用对应版本安装包可以修改已经安装的python,如图。 选择 “Modify” 选择next 确保最后一项勾选,然后install。 光安装了还不够,需要配置一下C语言编译器。 以VS2017为例: 将python37_d.lib(在安装目录下的libs文件夹里有python39_d.lib)所在文件夹的路径添加到库目录里面,右键你的解决方案,选.

m0_46296905的博客 6477

@SuppressLint("NewApi")

@SuppressLint("NewApi")作用是屏蔽android lint错误 在Android代码中,我们有时会使用比我们在AndroidManifest中设置的android:minSdkVersion版本更高的方法,此时编译器会提示警告. 解决方法是在方法上加上@SuppressLint("NewApi") 作用仅仅是屏蔽android lint错误,所以在方法中还要判断版本做不同的操

我是正直的技术小白 5108

Dataset - DeepFashion 服装数据集

Dataset - DeepFashion 服装数据集 [Dataset - DeepFashion] [Project - DeepFashion] 1. 服装类别和属性预测集 [Category - Attribute 下载] [百度网盘] 289,222 张服装图片 clothes images; 50 个服装类别 clothing categories 1,000 ...

长风破浪会有时,直挂云帆济沧海 2万+

避开PFC设计大坑:从环路分析到参数整定的5个常见误区与解决方案

本文深入解析PFC电路设计中从环路分析到参数整定的5个常见误区,包括电感参数设计、小信号模型适用边界、电压环与电流环耦合效应等。通过实际案例和PSIM仿真数据,提供工程落地的解决方案,帮助工程师避开设计陷阱,提升电路性能与可靠性。

weixin_30666401的博客 325

@SuppressLint(“HandlerLeak”)

碰到方法的前面和类的前面有时会出现@SuppressLint或者@SuppressWarnings这样的黄色警告,看起来很不舒服,于是上网搜集了一些相关资料。发现这些警告的出现其实是由于我们编写代码时的一些不规范的写法导致,解决这些问题其实是能提高我们程序的安全性、可用性和性能的。接下来就让我为大家一一说明。 1、@SuppressLint(“DrawAllocation”) 原因:我们都知道Vi...

androidsj的专栏 2万+

【ODX介绍】-5-用于Flash刷写的ODX-F文件概述

用于Flash刷写的ODX-F文件概述

「汽车电子助手」的博客 2531

java suppresslint_@SuppressLint("NewApi")

在Android代码中,我们有时会使用比我们在AndroidManifest中设置的android:minSdkVersion版本更高的方法,此时编译器会提示警告,解决方法是在方法上加上@SuppressLint("NewApi")或者@TargetApi()。那他们之间有什么区别呢,很简单,@SuppressLint("NewApi")屏蔽一切新api中才能使用的方法报的android lint...

weixin_30767895的博客 411

Anomalib库安装以及使用

Anomalib是一个专注于异常检测的深度学习库。它的目标是收集最新的异常检测算法,并提供用于在公共和私有数据集上进行基准测试的工具。该库提供了一系列已实现的异常检测算法,这些算法在最近的文献中有所描述。此外,Anomalib还提供了一套工具,方便开发人员开发和实现自定义模型。该库特别注重基于图像的异常检测,旨在识别数据集中的异常图像或图像中的异常像素区域。通过使用Anomalib,用户可以快速构建和评估各种异常检测算法,以满足其特定需求。

mingo_敏 5201

100天精通Python(基础篇)——第1天:Python从起源到应用的全面解析(附上Python、PyCharm、VSCode下载安装详细教程)

100天精通Python(基础篇)——第1天:Python从起源到应用的全面解析(附上Python、PyCharm、VSCode下载安装详细教程)

努力让自己发光,对的人才能迎着光而来 101万+

@SuppressLint("NewApi")和@TargetApi()的区别章标题

转自:http://blog.youkuaiyun.com/wbshuang09/article/details/44920549 在Android代码中,我们有时会使用比我们在AndroidManifest中设置的android:minSdkVersion版本更高的方法,此时编译器会提示警告,解决方法是在方法上加上@SuppressLint(“NewApi”)或者@TargetApi()。那他们之间有什么区

wz5779354的博客 252

小论文/大论文必备 | RT-DETR目标检测、数据集增强 | 引入多种数据集增强方法,支持图像和标签同步扩充增强,助力小论文和大论文实验涨点策略,平均提升模型mAP约1-2个百分点

RT-DETR目标检测数据增强策略研究 ,本文针对RT-DETR目标检测模型提出9种数据增强方法,包括几何变换(水平/垂直翻转、中心裁剪)、光照调整(亮度、对比度)和噪声添加(高斯/椒盐噪声)等。所有增强操作均保持图像与标签同步变换,确保训练数据的准确性。实验表明,该策略可提升模型mAP 1-2个百分点,对小目标检测效果尤为显著。文中提供了完整的Python实现代码,支持批量处理图像和标签文件,并详细说明了各增强方法的功能特点。该方法通过提升数据多样性,有效增强了模型在复杂场景下的鲁棒性和泛化能力。

Ai缝合怪、助力小伙伴高效发论文 462

android 基础 @SuppressLint("NewApi")和@TargetApi()的作用与区别

在Android代码中,我们有时会使用比我们在AndroidManifest中设置的android:minSdkVersion版本更高的方法,此时编译器会提示警告,解决方法是在方法上加上@SuppressLint("NewApi")或者@TargetApi()。 那他们之间有什么区别呢,很简单, @SuppressLint("NewApi")屏蔽一切新api中才能使用的方法报的android ...

NCTU_to_prove_safety的博客 490

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

Android @SuppressLint("NewApi")和@TargetApi()的区别

原址:http://blog.youkuaiyun.com/wbshuang09/article/details/44920549 在Android代码中,我们有时会使用比我们在AndroidManifest中设置的android:minSdkVersion版本更高的方法,此时编译器会提示警告,解决方法是在方法上加上@SuppressLint("NewApi")或者@TargetApi()。 那他

燃烧那滴泪的专栏 1226

深度学习工具包 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之API详解
下一篇: Android CountDownTimer(倒计时器)和Chronometr(定时器)
zwyAndroid
博客等级 码龄11年 5粉丝 42原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值