androidAPIlevel
Android SDK 22 开发环境安装
Android SDK 22 开发环境安装androidsdk22开发环境安装本文描述androidsdk安装过程,包括:androidsdk2.2,eclipse3.5.2(galileo),和andoiddevelopmenttools(adt)plugin。
一个前提就是用户已经加装了jdk5.0或jdk6.0。
并且在系统环境变量设置了path涵盖jdk的bin目录。
[安装android2.2]须要晓得的就是这个zip圣塞雷县不是一个完备的软件包。
android软件包使用“组件”的形式,用户可以根据须要挑选出组件。
上述zip文件只涵盖了一个组件管理工具和一个基本的工具组件。
2.运行androidsdkandavdmanager.解压缩上面的zip纸盒,可以运转sdksetup.exe,即为启动了andoidsdkandavdmanager。
这个工具不但对androidsdk组件展开管理,同时也就是android交互式设备管理器。
(关于后者,参看后面示例)。
然后,可以用这个工具下载完整的androidsdk开发包。
需要注意的如果网络使用了代理服务器,则(有可能)需在这个工具里配置代理服务器域名和端口。
[加装eclipse][安装adt]adt版本:adt0.9.7(may2021)adt0.9.6(march2021)adt0.9.5(december2021)adt0.9.4(october2021)使用eclipse的升级管理器来安装adt:1.启动eclipse,然后步入help>installnewsoftware.2.在availablesoftware对话框里,点击add....5.返回availablesoftware界面,你必须看见\tools\。
挑选出checkbox。
页面next,拒绝接受licenseagreement,然后页面finish。
6.TNUMBERNLeclipse.[配置adt]布局eclipse里的adt,并使其指向androidsdk。
软酷网安卓知识补强考试题答案
1.Android系统构架从高层到低层的顺序是()A.应用程序层、系统运行库层、核心层、应用程序框架层B.应用程序层、系统运行库层、应用程序框架层、核心层C.应用程序层、应用程序框架层、系统运行库层、核心层D.核心层、系统运行库层、应用程序层、应用程序框架层2.下列说法错误的是()A.Android不是基于Linux核心的B.Android词的本义指“机器人”C.Android是由Google发布的D.Androi3.下列哪一项说法是正确的()A.Android 3.0系统可以运行在手机终端B.Android 3.0系统不是针对手持式平板电脑而开发的C.android 3.0系统是针对手持式平板电脑而开发的,不能运行在手机终端D.Android 2.2系统不能运行于手机终端d支持Java语言开发应用程序4.在2011年11月推出的Android版本是()A.Android 1.6B.Android 2.2C.Android 3.0D.Android 4.05.Android是基于什么平台的()A.Unix平台B.Linux平台平台D.任意平台.6.下列哪些是Android模拟器不能实现的()A.发短信B.模拟GPS定位C.上网D.拍照7.通过DDMS中的()可以查看系统内部文件A.InnerFileExplorerB.InnerExplorerC.FileExplorerD.FileInnerExplorer8.关于AVD的说法正确的是()A.AVD只能通过eclipse开发环境创建B.AVD只能通过命令行创建C.AVD的全称是:Android Virtual DeviceD.每个AVD上只能配置一个运行项目9.关于Android模拟器的表示正确的是()A.Android模拟器可以在在AVD manager中新建模拟器的时候指定一个SdCardB.Android模拟器可以在在AVD manager中新建模拟器的时候指定两个SdCardC.Android模拟器可以在在AVD manager中新建模拟器的时候指定多个SdCardD.Android模拟器不能模拟出SdCard10.于Android SdCard的说法正确的是()A.通过getCacheDir()得到缓存目录B.通过getFileDir()得到文件目录C.SdCard是一张硬件卡D.往SdCard中写数据的权限是:android.permission.EXTERNAL_STORAGE11.AndroidManifest.xml 必须包括那些节点()A.manifestB.manifest、applicationC.manifest、application、activityD.manifest、application、activity、intent-filter12.每个<data>元素指定一个URI和数据类型(MIME类型)。
android cursorloader 用法
android cursorloader 用法"Android CursorLoader 用法- 解析与实例"Introduction:Android CursorLoader 是Android 系统提供的一个方便的类,用于异步加载数据库中的数据。
它是在Android API level 11 中引入的,并在后续版本中得到了改进。
CursorLoader 的使用可以简化开发者对数据库数据的管理和操作,同时也能提高应用的性能。
本文将一步一步回答有关Android CursorLoader 的用法。
1. 什么是CursorLoader?CursorLoader 是一个在后台线程中异步加载数据的Loader 类。
它被设计用于从内容提供器(ContentProvider)中检索数据,并将获取到的结果返回给UI 线程。
CursorLoader 的使用可以避免在主线程中进行繁重的数据库操作,从而提高应用的响应性和性能。
2. CursorLoader 的主要好处是什么?- 自动处理底层数据库操作,无需开发者手动编写繁琐的数据库查询代码。
- 提供与Activity 或Fragment 生命周期的无缝集成,确保数据的正确加载和更新。
- 通过ContentObserver 监听数据的变化,自动更新UI。
- 与LoaderCallbacks 接口一起使用,使得数据加载和更新过程更加简单和可靠。
3. 如何创建CursorLoader?CursorLoader 的创建需要以下几个步骤:Step 1: 实现LoaderCallbacks 接口首先,我们需要在Activity 或Fragment 中实现LoaderCallbacks 接口,并覆盖其中的几个方法。
这些方法包括onCreateLoader()、onLoadFinished() 和onLoaderReset()。
Step 2: 实现onCreateLoader() 方法在onCreateLoader() 方法中,我们需要指定需要加载的数据来源。
android ontrimmeomory level值
android ontrimmeomory level值在Android 中,onTrimMemory 方法是用于处理内存不足情况的一种机制。
该方法在Android 4.0(API 级别14)及以上版本引入,用于允许应用程序根据系统内存的不同级别来释放资源或采取其他适当的措施,以确保应用程序的性能和用户体验。
1. onTrimMemory 方法概述:onTrimMemory 方法是ComponentCallbacks2 接口的一部分,用于监听系统的内存状况。
在应用程序的生命周期中,系统可能会调用这个方法,传递不同级别的参数,以指示当前系统内存的状态。
2. onTrimMemory 方法参数:onTrimMemory 方法的参数是一个整数,表示不同的内存级别。
以下是一些常见的内存级别值:•TRIM_MEMORY_COMPLETE (80):系统内存极度不足,应用程序应该释放所有非关键的资源。
此时应该考虑清理缓存、关闭不必要的后台进程等。
•TRIM_MEMORY_MODERATE (60):系统内存较低,应用程序应该释放一些资源。
此时可以考虑清理一些缓存,以便回收内存。
•TRIM_MEMORY_BACKGROUND (40):应用程序在后台,系统内存较低,可能会被终止。
此时应释放一些不必要的资源,以便在后台运行时减少内存占用。
•TRIM_MEMORY_UI_HIDDEN (20):应用程序的UI 不可见,可以释放与UI 相关的资源。
3. onTrimMemory 的使用:@Overridepublic void onTrimMemory(int level){super.onTrimMemory(level);switch(level){case ComponentCallbacks2.TRIM_MEMORY_COMPLETE:// 释放所有非关键的资源break;case ComponentCallbacks2.TRIM_MEMORY_MODERATE:// 释放一些资源break;case ComponentCallbacks2.TRIM_MEMORY_BACKGROUND: // 应用程序在后台,释放资源break;case ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN:// UI 不可见,释放与UI 相关的资源break;// 其他内存级别...}}4. 注意事项:•在实现onTrimMemory 方法时,应该根据应用程序的实际需求选择释放哪些资源。
Android:代码多维度管理(产品风味)-flavorDimensionsproduct。。。
Android:代码多维度管理(产品风味)-flavorDimensionsproduct。
⼀、关于配置产品风味 Android studio 升级到3.0之后,gradle增加了多维度管理配置,便于同⼀个项⽬中创建应⽤的不同版本,分别管理依赖项并签署配置。
创建产品风味与创建构建类型类似:只需将它们添加到productFlavors {}代码块并配置您想要的设置。
产品风味⽀持与defaultConfig相同的属性,这是因为defaultConfig实际上属于类。
这意味着,您可以在defaultConfig {}代码块中提供所有风味的基本配置,每种风味均可更改任何这些默认值,例如。
当您创建新模块时,Android Studio 会⾃动为您创建调试和发布这两种构建类型。
尽管调试构建类型不会出现在构建配置⽂件中,Android Studio 会为其配置。
这样,您可以在安全的 Android 设备上调试应⽤并使⽤通⽤调试密钥库配置 APK 签署。
官⽹⽰例:android {...buildTypes {debug {...}release {...}}// Specifies the flavor dimensions you want to use. The order in which you// list each dimension determines its priority, from highest to lowest,// when Gradle merges variant sources and configurations. You must assign// each product flavor you configure to one of the flavor dimensions.flavorDimensions "api", "mode"productFlavors {demo {// Assigns this product flavor to the "mode" flavor dimension.dimension "mode"...}full {dimension "mode"...}// Configurations in the "api" product flavors override those in "mode"// flavors and the defaultConfig {} block. Gradle determines the priority// between flavor dimensions based on the order in which they appear next// to the flavorDimensions property above--the first dimension has a higher// priority than the second, and so on.minApi24 {dimension "api"minSdkVersion '24'// To ensure the target device receives the version of the app with// the highest compatible API level, assign version codes in increasing// value with API level. To learn more about assigning version codes to// support app updates and uploading to Google Play, read Multiple APK SupportversionCode 30000 + android.defaultConfig.versionCodeversionNameSuffix "-minApi24"...}minApi23 {dimension "api"minSdkVersion '23'versionCode 20000 + android.defaultConfig.versionCodeversionNameSuffix "-minApi23"...}minApi21 {dimension "api"minSdkVersion '21'versionCode 10000 + android.defaultConfig.versionCodeversionNameSuffix "-minApi21"...}}}...通过以上配置,就可以编译出多维度apk,以上⽰例可根据 "api" + "mode" 2个维度分别配置多个产品: ① minApi21 的 demo 、②minApi21 的 full 、③minApi23 的 demo 、④minApi23 的 full 、⑤minApi24 的 demo 、⑥minApi24 的 full⼆、⼩试⽜⼑ 从以上官⽹介绍可知产品多维度,即是在同⼀个⼯程上配置编译出各风味的apk版本,⽐如:演⽰⽤的简化版的和完整功能release版、两个平台UI的差异、多个项⽬之间功能增减...等等,通过多维度配置就不⽤⼀个版本维护⼀份⼯程,也不会因判断逻辑太多,导致代码臃肿。
Android 彻底退出(关闭)应用程序
做android开发时,发现一个关于android退出时不能彻底关闭的问题,比如:一个程序里new 出了N多个Thread,这样在退出程序的可能不能完全关闭,最后发现,只用finish()方法,有时候不能彻底退出,个人感觉还是要在适当的地方加上:System.exit(0);-----------------------------------------------------------------------------前言:finish():结束当前Activity,不会立即释放内存。
遵循android内存管理机制。
exit():结束当前组件如Activity,并立即释放当前Activity所占资源。
killProcess():结束当前组件如Activity,并立即释放当前Activity所占资源。
restartPackage():结束整个App,包括service等其它Activity组件。
1. finish()方法该方法可以结束当前Activity,但是如果你的App有很多Activity 的话,使用该方法显得有点捉襟见肘了。
另外,还有一个方法finishActivity (int requestCode) ,关于这个方法,先看看sdk的api说明吧!public voidfinishActivity (int requestCode)Since: APILevel 1Force finishanother activity that you had previously started withstartActi vityForResult(Intent, int).ParametersrequestCode The request code of the activity that you had given tostartActivityForResult(). If there are multiple activities started with this request code, they will all be finished.也许你会这样理解,Activity1 通过方法startActivityForResult (Intent, int) 启动Activity2,然后在Activity2 中通过方法finishActivity (intrequestCode)来结束Activity1,但是很不幸运,不是这样的。
安卓常见问题
1.如果你的项目的R文件不见的话,可以试下改版本号在保存,R文件不见一般都是布局文本出错导致.2. 布局文件不可以有大写字母3. 抛出如下错误WARNING: Application does not specify an API level requirement!,是由于没有指定users sdk的缘故,修改AndroidManifest.xml文件.加入:<uses-sdkandroid:minSdkVersion=”8″></uses-sdk> ##4. 机器内存的瓶颈,当apk大于我们的机器内存时,模拟器无情的抛出复制代码代码如下:Installation error: INSTALLFAILEDINSUFFICIENT_STORAGE Please check logcat output for more details. Launch canceled!让我们无法调试,现在我们来根治这个问题,解决方法有两种第一种(仅限apk小于机器内存,并且已安装上当前apk,只是无法再次debug)启动模拟器,然后进入菜单复制代码代码如下:settings->applications->mangeapplications-> select the application->select “unistall”.这样就能彻底删除了,然后再重新安装这个apk就没问题了第二种(通用)复制代码代码如下:-partition-size 128Eclipse中在项目Target的Options中添加。
##5.启动android模拟器时候如果提示:Failed to install on device ‘emulator-5554′: timeout 这是可能因为卡的原因导致启动超时,解决办法:eclipse -> window -> Preferences -> Android -> DDMS -> ADB connection time out(ms).把这个时间设置的长一些,默认是5秒即5000ms,我改成10秒就ok了。
Android 各版本SDK的区别
Android 各个版本SDK的区别---转载Android 1.5 API变更概要:UI framework· Framework for easier background/UI thread interaction·新SlidingDrawer 组件·新HorizontalScrollview 组件AppWidget framework·一些关于创建桌面AppWidget 的API.·提供根据自定义的内容创建LiveFolders的APIMedia framework·原声录音和回放APIs·交互式的MIDI 回放引擎·开发者使用的视频录像API (3GP format).·视频相片分享Intents·媒体搜索IntentInput Method framework·输入法服务framework·文本预测引擎·提供具有下载能力的IME给使用者Application-defined hardware requirements应用可定义硬件需求,应用程序可以定义说明此程序需要什么硬件需求.比如是否需要物理键盘或者轨迹球.Speech recognition framework·支持语音识别库.Miscellaneous API additions· LocationManager -应用可以接收到位置改变的信息.· WebView - 触摸start/end/move/cancel DOM 事件的支持·重建Sensor Manager APIs· GLSurfaceView - 创建OpenGL 应用更加方便的framework .·软件升级安装成功的Broadcast Intent - 更加平和优秀的软件升级体验Android 1.6 API变更概要:UI framework·新的类android.view.animation 控制动画行为:o AnticipateInterpolatoro AnticipateOvershootInterpolatoro BounceInterpolatoro OvershootInterpolator·新的XML 属性android onClick ,从一个layout文件描述一个view的View.OnClickListener.·对不同分辨率的屏幕的新的支持. 对于Bitmap和Canvas会执行有针对性的缩放行为.该框架会根据屏幕分辨率和其他内容自动缩放bitmap等.要在你的应用中使用Android 1.6包含的API的话你必须要设置"4"属性在manifest的元素中Search framework·应用程序现在可以公开的有关内容,作为建议放入快速搜索框,新的设备范围内的搜索功能,是可从主屏幕搜索。
AndroidAPI详解大全
Android —— TextView一、TextView的API 1.1 结构 ng.Object ↳ android.view.View ↳android.widget.TextView 直接子类: Button, CheckedTextView, Chronometer, DigitalClock, EditText 间接子类: AutoCompleteTextView, CheckBox, CompoundButton, ExtractEditText,MultiAutoCompleteTextView, RadioButton, ToggleButton 1.2 API属性名称描述android:autoLink 设置是否当文本为URL链接/email/电话号码/map时,文本显示为可点击的链接。
可选值(none/web/email/phone/map/all)android:autoText 如果设置,将自动执行输入值的拼写纠正。
此处无效果,在显示输入法并输入的时候起作用。
android:bufferType 指定getText()方式取得的文本类别。
选项editable 类似于StringBuilder可追加字符,也就是说getText后可调用append方法设置文本内容。
spannable 则可在给定的字符区域使用样式,参见这里1、这里2。
android:capitalize 设置英文字母大写类型。
此处无效果,需要弹出输入法才能看得到,参见EditText此属性说明。
android:cursorVisible设定光标为显示/隐藏,默认显示。
android:digits设置允许输入哪些字符。
如“1234567890.+-*/%\n()”android:drawableBottom 在text的下方输出一个drawable,如图片。
如果指定一个颜色的话会把text的背景设为该颜色,并且同时和background使用时覆盖后者。
AndroidSDKPDKNDK详解
AndroidSDKPDKNDK详解昨天⼀个同事问我 PDK,NDK,SDK都是做什么的,什么意思。
之前听到过这⼏个词,感觉⾃⼰能够理解,但是发现要⽐较清晰的给她解释才发现⾃⼰的理解可能还不是很到位,带着疑问查了查资料,结合⾃⼰的理解写下来。
其实这个三个词应该是在软件开发领域通⽤的,它们的全称分别为SDK(Software Development Kit),PDK(Platform DevelopmentKit),NDK(Native Development Kit),我们可以从它们的⽤途以及针对的⼈群来理解⼀下。
1.SDK 软件开发套件⼀般平台都会发布⾃⼰的SDK,SDK包含该平台为应⽤程序开发⼈员提供的开发⼯具,主要是所有公开API的集合,应⽤程序开发⼈员可以借助SDK中的API快速的进⾏应⽤的开发。
Android SDK针对所有应⽤开发⼈员开放,下载ADT查看sdk⽬录如下:sdk├──add-ons├──build-tools├──extras├── platforms├──platform-tools└──toolsSDK⽂件⽬录解释:1) add-ons 这⾥保存⼀些附加库,例如GoogleMaps2) build-tools 这⾥放的是Android的⼀些重要的编译⼯具,⽐如aapt、aidl、逆向调试⼯具dexdump和编译脚本dx等3) extras 存放的是⼏次⼤的升级添加的新功能相关的static library,如android-v4,android-v7,android-v134) platforms 存放的是平台真正的SDK,其中会根据APILevel来区分SDK的版本,命名规则android-APILevel,如android 4.4 SDK的⽂件夹名称为android-20,其⽂件⽬录如下:├──android.jar├── build.prop├──data├── framework.aidl├── sdk.properties├──skins├── source.properties├── templates└── uiautomator.jar该⽬录下主要⽂件android.jar为该版本framework的主要⽂件,包括class,图⽚等;data⽬录下为系统的资源⽂件,包括字符串资源,fonts 字体库⽂件,activity broadcast的action记录,intent的category,widget的列表等内容;skins⽬录为Android模拟器的⽪肤资源;templates⽬录下为创建Android⼯程默认模板,包括AndroidManifest.xml,⽂件,launch图标等;5) platform-tools 此⽬录主要放置的是平台⼯具,如adb, fastboot, sqlite3等6) tootls 这个⽬录中有⽐较重要的调试⼯具,如ddms(包括⼀些截图),Android模拟器的主程序emulator,traceview性能优化⼯具, UI控件扫描⼯具uiautomatorviewer,UI层级显⽰⼯具hierarchyviewer,代码混淆⼯具proguard,ant编译脚本,代码缺陷扫描⼯具lint等,这个⽬录下也有个templates⽬录,简单看了下不太明⽩是⼲什么⽤的,有兴趣的可以了解⼀下。
Android上NFC应用API介绍以及部分NFC知识整合
NFC(近场通信)NFC是一套短距离的无线通信,通常距离是4厘米或更短。
NFC工作频率是13.56M Hz,传输速率是106kbit/s 到848kbit/s. NFC总是在一个发起者和一个被动目标之间发生。
发起者发出近场无线电波,这个近场可以给被动目标供电。
这些被动的目标包括不需要电源的标签,卡,也可以是有电源的设备。
与其他无线通信技术比较,例如蓝牙和WiFi, NFC提供更低带宽和距离,并且低成本,不需要供电,不需要实现匹配,整个通信过程仅仅是短短的靠近一秒就能完成。
一个带有NFC支持的android设备通常是一个发起者。
也可以作为NFC的读写设备。
他将检测NFC tags并且打开一个Activity来处理. Android 2.3.3还有支持有限的P2P。
Tags分很多种,其中简单的只提供读写段,有的只能读。
复杂的tags可以支持一些运算,加密来控制对tags 里数据段的读写。
甚至一些tags上有简单的操作系统,允许一些复杂的交互和可以执行一些代码。
API概览Android.nfc package包含顶层类用来与本地NFC适配器交互. 这些类可以表示被检测到的tags和用NDEF数据格式。
声明Android Manifest.xml的元素在你能访问一个设备的NFC硬件和正确的处理NFC的Intent之前,需要在AndroidManifest.xml中先声明下面的项:1.NFC使用<uses-permission>元素来访问NFC硬件:<uses-permission android:name="android.permission.NFC"/>2.最小SDK版本需要设置正确,API level 9只包含有限的tag支持,包括:.通过ACTION_TAG_DISCOVERED来发布Tag信息.只有通过EXTRA_NDEF_MESSAGES扩展来访问NDEF消息.其他的tag属性和I/O操作都不支持所以你可能想要用API level 10来实现对tag的广泛的读写支持。
Android基础知识之API等级介绍
Android基础知识之API等级介绍:可以让开发者通过⼀个表⽰API级别的整数来描述程序在android平台上的兼容性,系统会将与系统本⾝提供的API级别与应⽤指定的API级别⽐较。
尽管他有这个名字,但是该元素只是⽤来指定API级别,并不是⽤来指定SDK或者android平台的版本号。
API级别也是⼀个整数,但是你不能根据android版本号来追溯API级别(例如,它并不等同于主版本号或是主版本与次版本号的和)。
同样,请阅读⽂档.::Google Play会过滤应⽤对⽤户的可见性,⽤户只能看见和下载那些与⽤户设备兼容的⼀些应⽤。
过滤应⽤的⼀种⽅式就是通过Android版本的兼容性。
为此,Google Play会检查每个应⽤的Manifest⽂件标记的属性来构建版本兼容性范围,然后会根据它与⽤户Android系统的API级别的⽐对来决定隐藏或者显⽰该应⽤。
可以参考.属性::android:minSdkVersion::⼀个整数来指定程序可以运⾏的最⼩版本。
如果⽤户系统的API级别⼩于该属性指定的值,系统将会阻⽌⽤户来安装此应⽤。
你应该⼀直声明这个属性。
* 注意* :如果没有显⽰的声明该属性,系统指定⼀个默认值1,表明你的程序兼容Android系统的所有版本。
如果应⽤并不是兼容所有的版本的android系统(举例来说,应⽤⽤到了API3 才引⽤的API),⽽且你没有声明minSdkVersion属性,当应⽤安装到API的级别⼩于3的系统上且试图访问不可⽤的API时,系统将会异常终⽌。
有鉴于此,请确定,应⽤已显式声明 minSdkVersion属性。
:android:targetSdkVersion::⼀个整数⽤来指定应⽤⽬标的API级别。
如果没有设置,默认值等于minSdkVersion所给的值。
::该值⽤来告诉系统应⽤已经在⽬标版本上进⾏测试以及系统可以不启⽤任何兼容性⾏为来维持你的应⽤的向前兼容性。
AndroidSDK目录具体结构及Android源码的具体结构
AndroidSDK⽬录具体结构及Android源码的具体结构Android SDK⽬录具体结构1. add-ons:这⾥⾯保存着附加库,⽐如Google Maps,当然你如果安装了OphoneSDK,这⾥也会有⼀些类库在⾥⾯。
2. docs:这⾥⾯是Android SDK API参考⽂档,所有的API都可以在这⾥查到。
3. market_licensing:作为AndroidMarket版权保护组件,⼀般发布付费应⽤到电⼦市场可以⽤它来反盗版。
4. platforms:是每个平台的SDK真正的⽂件,⾥⾯会根据API Level划分的SDK版本,这⾥就以Android 2.2来说,进⼊后有⼀个android-8的⽂件夹,android-8进⼊后是Android 2.2 SDK的主要⽂件,其中ant为ant编译脚本,data保存着⼀些系统资源,images是模拟器映像⽂件,skins则是Android模拟器的⽪肤,templates是⼯程创建的默认模板,android.jar则是该版本的主要framework⽂件,tools⽬录⾥⾯包含了重要的编译⼯具,⽐如aapt、aidl、逆向调试⼯具dexdump和编译脚本dx。
5. platform-tools:保存着⼀些通⽤⼯具,⽐如adb、和aapt、aidl、dx等⽂件,这⾥和platforms⽬录中tools⽂件夹有些重复,主要是从android 2.3开始这些⼯具被划分为通⽤了。
6. samples:是Android SDK⾃带的默认⽰例⼯程,⾥⾯的apidemos强烈推荐初学者运⾏学习,对于SQLite数据库操作可以查看NotePad这个例⼦,对于游戏开发Snake、LunarLander都是不错的例⼦,对于Android主题开发Home则是android m5时代的主题设计原理。
7. tools:作为SDK根⽬录下的tools⽂件夹,这⾥包含了重要的⼯具,⽐如ddms⽤于启动Android调试⼯具,⽐如logcat、屏=幕截图和⽂件管理器,⽽draw9patch则是绘制android平台的可缩放png图⽚的⼯具,sqlite3可以在PC上操作SQLite数据库,⽽monkeyrunner则是⼀个不错的压⼒测试应⽤,模拟⽤户随机按键,mksdcard则是模拟器SD映像的创建⼯具,emulator是android模拟器主程序,不过从android1.5开始,需要输⼊合适的参数才能启动模拟器,traceview作为android平台上重要的调试⼯具。
Android 使用隐藏API
Android-使用internal(com.android.internal)和hidden (@hide)APIs –Part 1来自Fgamers1,153 次阅读评论(0)本系列文章:Android有两种类型的API是不能经由SDK访问的。
第一种是位于com.android.internal包中的API。
我将称之为internal API。
第二种API类型是一系列被标记为@hide属性的类和方法。
从严格意义上来讲,这不是一个单一的API,而是一组小的被隐藏的API,但我仍将其假设为一种API,并称之为hidden API。
Hidden API 例子你可以查看一下android的源码,并能找到一些变量、函数和类等,都被@hide属性标记了。
下面的例子就是在WifiManager(API 10源码)中隐藏的变量。
另一个例子是在WifiManager(API 10源码)中隐藏了setWifiApEnabled函数。
因此,只要你看到@hide属性,那你看到的就是hidden API。
Internal和hidden API的区别Hidden API之所以被隐藏,是想阻止开发者使用SDK中那些未完成或不稳定的部分(接口或架构)。
举个例子,Bluetooth API在API 5(Android 2.0)上才开放;在API 3 和4上都是用@hide属性隐藏了。
当这些API被验证和清理后,Google的开发者会移除@hide属性,并让其在API 5官方化。
很多地方在API 4 和5之间发生了变化。
如果你的程序依赖某些隐藏的API,当其部署到新的平台上时,就有可能陷入困境。
对于internal API来说,从来都没有计划将其开放出来。
它就是Android的“内部厨房”,对开发者来说,应该将其视作黑盒。
凡事都会有变化的。
如果你依赖某些 internal API,也有可能在新的Android release上,这些internal API发生变化,从而令你失望。
Android 5.0概览
SHOW MORE IN THIS DOCUMENT Update your target API level User InterfaceNotificationsGraphicsMedia StorageWireless and Connectivity Project VoltaAndroid in the Workplaceand in EducationSystemPrinting FrameworkTesting & Accessibility IMEManifest DeclarationsAPI DIFFERENCESAPI level 20 to 21 »L Developer Preview to 21 »SEE ALSOAndroid 5.0 Behavior ChangesAndroid Lollipop Highlights Android 5.0 APIsAPI Level: 21Android 5.0 (LOLLIPOP(/reference/android/os/Build.VERSION_CODES.html#LOLLIPOP)) offers new features for users and app developers. This document provides an introduction to the most notable new APIs.If you have a published app, make sure to check out the Android 5.0 Behavior Changes (/about/versions/android-5.0-changes.html) that you should account for in your app. These behavior changes may affect your app on Android 5.0devices, even if you are not using new APIs or targeting new functionality.For a high-level look at the new platform features, instead see the Android Lollipop highlights (/about/versions/lollipop.html).Start developing To start building apps for Android 5.0, you must first get the Android SDK (/sdk/index.html). Then use the SDK Manager (/tools/help/sdk-manager.html) to download the Android 5.0 SDK Platform and System Images.To test your apps on a real device, flash a Nexus 5 or Nexus 7 with the ANDROID PREVIEW SYSTEM IMAGE (/preview/index.html#Start).Update your target API levelTo better optimize your app for devices running Android 5.0, set your targetSdkVersion (/guide/topics/manifest/uses-sdk-element.html#target) to "21",install your app on an Android 5.0 system image, test it, then publish the updated app with this change.You can use Android 5.0 APIs while also supporting older versions by addingconditions to your code that check for the system API level before executingAPIs not supported by your minSdkVersion (/guide/topics/manifest/uses-sdk-element.html#min). To learn more about maintaining backward compatibility, read Supporting Different Platform Versions (/training/basics/supporting-devices/platforms.html).For more information about how API levels work, read What is API Level? (/guide/topics/manifest/uses-sdk-element.html#ApiLevels)Important behavior changesIf you have previously published an app for Android, be aware that your app might be affected by changes in Android 5.0.Please see Android 5.0 Changes (/about/versions/android-5.0-changes.html) for complete information.User InterfaceMaterial design supportAndroid 5.0 adds support for Android's new material design style. You can create apps with material design that are visually dynamic and have UI element transitions that feel natural to users. This support includes:The material themeView shadowsThe RecyclerView widgetDrawable animation and styling effectsMaterial design animation and activity transition effectsAnimators for view properties based on the state of the viewCustomizable UI widgets and app bars with color palettes that you controlAnimated and non-animated drawables based on XML vector graphicsTo learn more about adding material design functionality to your app, see Material Design (/training/material/index.html).Concurrent documents and activities in the recents screenIn previous releases, the recents screen (/guide/components/recents.html) could only display only one task for each app that the user interacted with most recently. Now your app can open more tasks as needed for additional concurrent activities for documents. This feature facilitates multitasking by letting users quickly switch between individual activities and documents from the recents screen, with a consistent switching experience across all apps. Examples of such concurrent tasks might include open tabs in a web browser app, documents in a productivity app, concurrent matches in a game, or chats in a messaging app. Your app can manage its tasks through the ActivityManager.AppTask(/reference/android/app/ActivityManager.AppTask.html) class.To insert a logical break so that the system treats your activity as a new task, use FLAG_ACTIVITY_NEW_DOCUMENT(/reference/android/content/Intent.html#FLAG_ACTIVITY_NEW_DOCUMENT) when launching the activity with startActivity()(/reference/android/app/Activity.html#startActivity(android.content.Intent)). You can also get this behavior by setting the <activity> (/guide/topics/manifest/activity-element.html) element's documentLaunchMode attribute to "intoExisting" or "always" in your manifest.To avoid cluttering the recents screen, you can set the maximum number of tasks from your app that can appear in that screen. To do this, set the <application> (/guide/topics/manifest/application-element.html) attribute android:maxRecents(/reference/android/R.attr.html#maxRecents). The current maximum that can be specified is 50 tasks per user (25 for low RAM devices).Tasks in the recents screen can be set to persist across reboots. To control the persistence behavior, use the android:persistableMode (/reference/android/R.attr.html#persistableMode) attribute. You can also change the visual properties of an activity in the recents screen, such as the activity’s color, label, and icon, by calling the setTaskDescription()(/reference/android/app/Activity.html#setTaskDescription(android.app.ActivityManager.TaskDescription)) method.WebView updatesAndroid 5.0 updates the WebView (/reference/android/webkit/WebView.html) implementation to Chromium M37, bringing security and stability enhancements, as well as bug fixes. The default user-agent string for a WebView(/reference/android/webkit/WebView.html) running on Android 5.0 has been updated to incorporate 37.0.0.0 as the version number.This release introduces the PermissionRequest (/reference/android/webkit/PermissionRequest.html) class, which allows your app to grant the WebView (/reference/android/webkit/WebView.html) permission to access protected resources like the camera and microphone, through web APIs such as getUserMedia() (https:///en-US/docs/NavigatorUserMedia.getUserMedia). Your app must have the appropriate Android permissions for these resources in order to grant the permissions to the WebView (/reference/android/webkit/WebView.html).With the new onShowFileChooser() (/reference/android/webkit/WebChromeClient.html#onShowFileChooser(android.webkit.WebView, android.webkit.ValueCallback<.Uri[]>, android.webkit.WebChromeClient.FileChooserParams)) method, you can now use an input form field in the WebView (/reference/android/webkit/WebView.html), and launch a file chooser to select images and files from the Android device.Additionally, this release brings support for the WebAudio (http://webaudio.github.io/web-audio-api/), WebGL(https:///webgl/), and WebRTC (/) open standards. To learn more about the new features included in this release, see WebView for Android (https:///multidevice/webview/overview). Screen capturing and sharingAndroid 5.0 lets you add screen capturing and screen sharing capabilities to your app with the newandroid.media.projection (/reference/android/media/projection/package-summary.html) APIs. This functionality is useful, for example, if you want to enable screen sharing in a video conferencing app.The new createVirtualDisplay()(/reference/android/media/projection/MediaProjection.html#createVirtualDisplay(ng.String, int, int, int, int, android.view.Surface, android.hardware.display.VirtualDisplay.Callback, android.os.Handler)) method allows your app to capture the contents of the main screen (the default display) into a Surface (/reference/android/view/Surface.html) object, which your app can then send across the network. The API only allows capturing non-secure screen content, and not system audio. To begin screen capturing, your app must first request the user’s permission by launching a screen capture dialog using an Intent (/reference/android/content/Intent.html) obtained through the createScreenCaptureIntent() (/reference/android/media/projection/MediaProjectionManager.html#createScreenCaptureIntent()) method.For an example of how to use the new APIs, see the MediaProjectionDemo class in the sample project.NotificationsLock screen notificationsLock screens in Android 5.0 have the ability to present notifications. Users can choose via Settings whether to allow sensitive notification content to be shown over a secure lock screen.Your app can control the level of detail visible when its notifications are displayed over the secure lock screen. To control the visibility level, call setVisibility() (/reference/android/app/Notification.Builder.html#setVisibility(int)) and specify one of these values:VISIBILITY_PRIVATE: Shows basic information, such as the notification’s icon, but hides the notification’s full content. VISIBILITY_PUBLIC: Shows the notification’s full content.VISIBILITY_SECRET: Shows nothing, excluding even the notification’s icon.When the visibility level is VISIBILITY_PRIVATE (/reference/android/app/Notification.html#VISIBILITY_PRIVATE), you can also provide a redacted version of the notification content that hides personal details. For example, an SMS app might display a notification that shows "You have 3 new text messages" but hides the message content and senders. To provide this alternative notification, first create the replacement notification using Notification.Builder(/reference/android/app/Notification.Builder.html). When you create the private notification object, attach the replacement notification to it through the setPublicVersion()(/reference/android/app/Notification.Builder.html#setPublicVersion(android.app.Notification)) method.Notifications metadataAndroid 5.0 uses metadata associated with your app notifications to sort the notifications more intelligently. To set the metadata, call the following methods in Notification.Builder (/reference/android/app/Notification.Builder.html) when you construct the notification:setCategory(): Tells the system how to handle your app notifications when the device is in priority mode (for example, if a notification represents an incoming call, instant message, or alarm).setPriority(): Marks the notification as more or less important than normal notifications. Notifications with the priority field set to PRIORITY_MAX or PRIORITY_HIGH appear in a small floating window if the notification also has sound or vibration.addPerson(): Enables you to add one or more people who are relevant to a notification. Your app can use this to signal to the system that it should group together notifications from the specified people, or rank notifications from these people as being more important.GraphicsSupport for OpenGL ES 3.1Android 5.0 adds Java interfaces and native support for OpenGL ES 3.1. Key new functionality provided in OpenGL ES 3.1 includes:Compute shadersSeparate shader objectsIndirect draw commandsMultisample and stencil texturesShading language improvementsExtensions for advanced blend modes and debuggingBackward compatibility with OpenGL ES 2.0 and 3.0The Java interface for OpenGL ES 3.1 on Android is provided with GLES31 (/reference/android/opengl/GLES31.html). When using OpenGL ES 3.1, be sure that you declare it in your manifest file with the <uses-feature> (/guide/topics/manifest/uses-feature-element.html) tag and the android:glEsVersion attribute. For example:<manifest><uses-feature android:glEsVersion="0x00030001"/>...</manifest>For more information about using OpenGL ES, including how to check the device’s supported OpenGL ES version at runtime, see the OpenGL ES API guide (/guide/topics/graphics/opengl.html).Android Extension PackIn addition to OpenGL ES 3.1, this release provides an extension pack with Java interfaces and native support for advanced graphics functionality. These extensions are treated as a single package by Android. (If theANDROID_extension_pack_es31a extension is present, your app can assume all extensions in the package are present and enable the shading language features with a single #extension statement.)The extension pack supports:Guaranteed fragment shader support for shader storage buffers, images, and atomics (Fragment shader support is optional in OpenGL ES 3.1.)Tessellation and geometry shadersASTC (LDR) texture compression formatPer-sample interpolation and shadingDifferent blend modes for each color attachment in a frame bufferThe Java interface for the extension pack is provided with GLES31Ext (/reference/android/opengl/GLES31Ext.html). In your app manifest, you can declare that your app must be installed only on devices that support the extension pack. For example:<manifest><uses-feature android:name=“android.hardware.opengles.aep”android:required="true"/>...</manifest>MediaCamera API for advanced camera capabilitiesAndroid 5.0 introduces the new android.hardware.camera2 (/reference/android/hardware/camera2/package-summary.html) API to facilitate fine-grain photo capture and image processing. You can now programmatically access the camera devices available to the system with getCameraIdList() (/reference/android/hardware/camera2/CameraManager.html#getCameraIdList()) and connect to a specific device with openCamera()(/reference/android/hardware/camera2/CameraManager.html#openCamera(ng.String,android.hardware.camera2.CameraDevice.StateCallback, android.os.Handler)). To start capturing images, create a CameraCaptureSession (/reference/android/hardware/camera2/CameraCaptureSession.html) and specify the Surface(/reference/android/view/Surface.html) objects to send captured images. The CameraCaptureSession(/reference/android/hardware/camera2/CameraCaptureSession.html) can be configured to take single shots or multiple images in a burst.To be notified when new images are captured, implement the CameraCaptureSession.CaptureCallback(/reference/android/hardware/camera2/CameraCaptureSession.CaptureCallback.html) listener and set it in your capture request. Now when the system completes the image capture request, your CameraCaptureSession.CaptureCallback(/reference/android/hardware/camera2/CameraCaptureSession.CaptureCallback.html) listener receives a call to onCaptureCompleted()(/reference/android/hardware/camera2/CameraCaptureSession.CaptureCallback.html#onCaptureCompleted(android.hardware.camera2.Cam eraCaptureSession, android.hardware.camera2.CaptureRequest, android.hardware.camera2.TotalCaptureResult)), providing you with the image capture metadata in a CaptureResult (/reference/android/hardware/camera2/CaptureResult.html).The CameraCharacteristics (/reference/android/hardware/camera2/CameraCharacteristics.html) class lets your app detect what camera features are available on a device. The object's INFO_SUPPORTED_HARDWARE_LEVEL(/reference/android/hardware/camera2/CameraCharacteristics.html#INFO_SUPPORTED_HARDWARE_LEVEL) property represents the camera's level of functionality.All devices support at least the INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY hardware level, which has capabilities roughly equivalent to that of the deprecated Camera API.Devices that support the INFO_SUPPORTED_HARDWARE_LEVEL_FULL hardware level are capable of manual control of capture and post-processing, and capturing high-resolution images at high frame rates.To see how to use the updated Camera (/reference/android/hardware/camera2/package-summary.html) API, refer to the Camera2Basic and Camera2Video implementation samples in this release.Audio playbackThis release includes the following changes to AudioTrack (/reference/android/media/AudioTrack.html):Your app can now supply audio data in floating-point format (ENCODING_PCM_FLOAT). This permits greater dynamic range, more consistent precision, and greater headroom. Floating-point arithmetic is especially useful during intermediate calculations. Playback endpoints use integer format for audio data, and with lower bit depth. (In Android 5.0, portions of the internal pipeline are not yet floating point.)Your app can now supply audio data as a ByteBuffer, in the same format as provided by MediaCodec.The WRITE_NON_BLOCKING option can simplify buffering and multithreading for some apps.Media playback controlUse the new notification and media APIs to ensure that the system UI knows about your media playback and can extract and show album art. Controlling media playback across a UI and a service is now easier with the new MediaSession(/reference/android/media/session/MediaSession.html) and MediaController(/reference/android/media/session/MediaController.html) classes.The new MediaSession (/reference/android/media/session/MediaSession.html) class replaces the deprecated RemoteControlClient (/reference/android/media/RemoteControlClient.html) class and provides a single set of callback methods for handling transport controls and media buttons. If your app provides media playback and runs on the Android TV (/tv/index.html) or Wear (/wear/index.html) platform, use the MediaSession(/reference/android/media/session/MediaSession.html) class to handle your transport controls using the same callback methods.You can now build your own media controller app with the new MediaController(/reference/android/media/session/MediaController.html) class. This class provides a thread-safe way to monitor and control media playback from your app's UI process. When creating a controller, specify a MediaSession.Token(/reference/android/media/session/MediaSession.Token.html) object so that your app can interact with the given MediaSession (/reference/android/media/session/MediaSession.html). By using the MediaController.TransportControls(/reference/android/media/session/MediaController.TransportControls.html) methods, you can send commands such as play() (/reference/android/media/session/MediaController.TransportControls.html#play()), stop()(/reference/android/media/session/MediaController.TransportControls.html#stop()), skipToNext()(/reference/android/media/session/MediaController.TransportControls.html#skipToNext()), and setRating()(/reference/android/media/session/MediaController.TransportControls.html#setRating(android.media.Rating)) to control media playback on that session. With the controller, you can also register a MediaController.Callback(/reference/android/media/session/MediaController.Callback.html) object to listen for metadata and state changes on the session.In addition, you can create rich notifications that allow playback control tied to a media session with the new Notification.MediaStyle (/reference/android/app/Notification.MediaStyle.html) class.Media browsingAndroid 5.0 introduces the ability for apps to browse the media content library of another app, through the new android.media.browse (/reference/android/media/browse/package-summary.html) API. To expose the media content in your app, extend the MediaBrowserService (/reference/android/service/media/MediaBrowserService.html) class. Your implementation of MediaBrowserService (/reference/android/service/media/MediaBrowserService.html) should provide access to a MediaSession.Token (/reference/android/media/session/MediaSession.Token.html) so that apps can play media content provided through your service.To interact with a media browser service, use the MediaBrowser (/reference/android/media/browse/MediaBrowser.html) class. Specify the component name for a MediaSession (/reference/android/media/session/MediaSession.html) when you create an MediaBrowser (/reference/android/media/browse/MediaBrowser.html) instance. Using that browser instance, your app can then connect to the associated service and obtain a MediaSession.Token(/reference/android/media/session/MediaSession.Token.html) object to play content exposed through that service. StorageDirectory selectionAndroid 5.0 extends the Storage Access Framework (/guide/topics/providers/document-provider.html) to let users select an entire directory subtree, giving apps read/write access to all contained documents without requiring user confirmation for each item.To select a directory subtree, build and send an OPEN_DOCUMENT_TREE(/reference/android/content/Intent.html#ACTION_OPEN_DOCUMENT_TREE) intent. The system displays all DocumentsProvider(/reference/android/provider/DocumentsProvider.html) instances that support subtree selection, letting the user browse andselect a directory. The returned URI represents access to the selected subtree. You can then use buildChildDocumentsUriUsingTree()(/reference/android/provider/DocumentsContract.html#buildChildDocumentsUriUsingTree(.Uri, ng.String)) and buildDocumentUriUsingTree() (/reference/android/provider/DocumentsContract.html#buildDocumentUriUsingTree(.Uri, ng.String)) along with query() (/reference/android/content/ContentResolver.html#query(.Uri,ng.String[], ng.String, ng.String[], ng.String)) to explore the subtree.The new createDocument()(/reference/android/provider/DocumentsContract.html#createDocument(android.content.ContentResolver, .Uri,ng.String, ng.String)) method lets you create new documents or directories anywhere under the subtree. To manage existing documents, use renameDocument()(/reference/android/provider/DocumentsContract.html#renameDocument(android.content.ContentResolver, .Uri,ng.String)) and deleteDocument()(/reference/android/provider/DocumentsProvider.html#deleteDocument(ng.String)). Check COLUMN_FLAGS(/reference/android/provider/DocumentsContract.Document.html#COLUMN_FLAGS) to verify provider support for these calls before issuing them.If you're implementing a DocumentsProvider (/reference/android/provider/DocumentsProvider.html) and want to support subtree selection, implement isChildDocument()(/reference/android/provider/DocumentsProvider.html#isChildDocument(ng.String, ng.String)) and includeFLAG_SUPPORTS_IS_CHILD (/reference/android/provider/DocumentsContract.Root.html#FLAG_SUPPORTS_IS_CHILD) in yourCOLUMN_FLAGS (/reference/android/provider/DocumentsContract.Root.html#COLUMN_FLAGS).Android 5.0 also introduces new package-specific directories on shared storage where your app can place media files for inclusion in MediaStore (/reference/android/provider/MediaStore.html). The new getExternalMediaDirs()(/reference/android/content/Context.html#getExternalMediaDirs()) returns paths to these directories on all shared storage devices. Similarly to getExternalFilesDir() (/reference/android/content/Context.html#getExternalFilesDir(ng.String)), no additional permissions are needed by your app to access the returned paths. The platform periodically scans for new media in these directories, but you can also use MediaScannerConnection(/reference/android/media/MediaScannerConnection.html) to explicitly scan for new content.Wireless & ConnectivityMultiple network connectionsAndroid 5.0 provides new multi-networking APIs that let your app dynamically scan for available networks with specific capabilities, and establish a connection to them. This functionality is useful when your app requires a specialized network, such as an SUPL, MMS, or carrier-billing network, or if you want to send data using a particular type of transport protocol.To select and connect to a network dynamically from your app, follow these steps:1. Create a ConnectivityManager.2. Use the NetworkRequest.Builder class to create an NetworkRequest object and specify the network features andtransport type your app is interested in.3. To scan for suitable networks, call requestNetwork() or registerNetworkCallback(), and pass in theNetworkRequest object and an implementation of workCallback. Use therequestNetwork() method if you want to actively switch to a suitable network once it’s detected; to receive only notifications for scanned networks without actively switching, use the registerNetworkCallback() methodinstead.When the system detects a suitable network, it connects to the network and invokes the onAvailable()(/reference/android/net/workCallback.html#onAvailable(work)) callback. You can use the Network (/reference/android/net/Network.html) object from the callback to get additional information about the network, or to direct traffic to use the selected network.Bluetooth Low EnergyAndroid 4.3 introduced platform support for Bluetooth Low Energy (/guide/topics/connectivity/bluetooth-le.html) (Bluetooth LE) in the central role. In Android 5.0, an Android device can now act as a Bluetooth LE peripheral device. Apps can use this capability to make their presence known to nearby devices. For instance, you can build apps that allow a device to function as a pedometer or health monitor and communicate its data with another Bluetooth LE device.The new android.bluetooth.le (/reference/android/bluetooth/le/package-summary.html) APIs enable your apps to broadcast advertisements, scan for responses, and form connections with nearby Bluetooth LE devices. To use the new advertising and scanning features, add the BLUETOOTH_ADMIN (/reference/android/Manifest.permission.html#BLUETOOTH_ADMIN) permissionin your manifest. When users update or download your app from the Play Store, they are asked to grant the following permission to your app: "Bluetooth connection information: Allows the app to control Bluetooth, including broadcasting to or getting information about nearby Bluetooth devices."To begin Bluetooth LE advertising so that other devices can discover your app, call startAdvertising()(/reference/android/bluetooth/le/BluetoothLeAdvertiser.html#startAdvertising(android.bluetooth.le.AdvertiseSettings, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseCallback)) and pass in an implementation of the AdvertiseCallback (/reference/android/bluetooth/le/AdvertiseCallback.html) class. The callback object receives a report of the success or failure of the advertising operation.Android 5.0 introduces the ScanFilter (/reference/android/bluetooth/le/ScanFilter.html) class so that your app can scan for only the specific types of devices it is interested in. To begin scanning for Bluetooth LE devices, call startScan()(/reference/android/bluetooth/le/BluetoothLeScanner.html#startScan(android.bluetooth.le.ScanCallback)) and pass in a list of filters. In the method call, you must also provide an implementation of ScanCallback(/reference/android/bluetooth/le/ScanCallback.html) to report when a Bluetooth LE advertisement is found.NFC enhancementsAndroid 5.0 adds these enhancements to enable wider and more flexible use of NFC:Android Beam is now available in the share menu.Your app can invoke the Android Beam on the user’s device to share data by calling invokeBeam(). This avoids the need for the user to manually tap the device against another NFC-capable device to complete the data transfer.You can use the new createTextRecord() method to create an NDEF record containing UTF-8 text data.If you are developing a payment app, you now have the ability to register an NFC application ID (AID) dynamically by calling registerAidsForService(). You can also use setPreferredService() to set the preferred card emulation service that should be used when a specific activity is in the foreground.Project VoltaIn addition to new features, Android 5.0 emphasizes improvements in battery life. Use the new APIs and tool to understand and optimize your app’s power consumption.Scheduling jobsAndroid 5.0 provides a new JobScheduler (/reference/android/app/job/JobScheduler.html) API that lets you optimize battery life by defining jobs for the system to run asynchronously at a later time or under specified conditions (such as when the device is charging). Job scheduling is useful in such situations as:The app has non-user-facing work that you can defer.The app has work you'd prefer to do when the unit is plugged in.The app has a task that requires network access or a Wi-Fi connection.The app has a number of tasks that you want to run as a batch on a regular schedule.A unit of work is encapsulated by a JobInfo (/reference/android/app/job/JobInfo.html) object. This object specifies the scheduling criteria.Use the JobInfo.Builder (/reference/android/app/job/JobInfo.Builder.html) class to configure how the scheduled task should run. You can schedule the task to run under specific conditions, such as:Start when the device is chargingStart when the device is connected to an unmetered networkStart when the device is idleFinish before a certain deadline or with a minimum delayFor example, you can add code like this to run your task on an unmetered network:JobInfo uploadTask =new JobInfo.Builder(mJobId,mServiceComponent /* JobService component */).setRequiredNetworkCapabilities(workType.UNMETERED).build();JobScheduler jobScheduler =(JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);jobScheduler.schedule(uploadTask);If the device has stable power (that is, it has been plugged in for more than 2 minutes and the battery is at a healthy level。
android implement和api实现原理
android implement和api实现原理
Android中的“implementation”和“api”是Gradle 配置中的两种依赖方式,它们在实现原理上存在一定差异。
“implementation”是一种依赖配置,当我们在项目中使用“implementation”关键字引入外部库时,这些库的实现细节将只在当前模块中可见,并且不会传递给依赖当前模块的其他模块。
这样可以避免库的冲突和隐藏实现细节,提高代码的模块化和隔离性。
而“api”与“compile”类似,它无法隐藏自己使用的依赖。
具体来说,当mylibrary1使用api依赖mylibrary3时,mylibrary3的实现细节将对所有依赖mylibrary1的模块可见。
总的来说,“implementation”可以隐藏实现细节,提高代码的模块化和隔离性,而“api”则无法隐藏依赖。
Android 的os.Build_ID 对应的SDK版本号 以及 SDK版本号与API Level对应关系
Android 的os.Build_ID 对应的SDK版本号以及SDK版本号与API Level对应关系Marshmallow棉花糖 6.0 API level 23 Lollipop棒棒糖 5.1 API level 22 Lollipop 5.0 API level 21KitKat 4.4 - 4.4.4 API level 19Jelly Bean 4.3.x API level 18Jelly Bean 4.2.x API level 17Jelly Bean 4.1.x API level 16Ice Cream Sandwich 4.0.3 - 4.0.4 API level 15, NDK 8 Ice Cream Sandwich 4.0.1 - 4.0.2 API level 14, NDK 7 Honeycomb 3.2.x API level 13 Honeycomb 3.1 API level 12, NDK 6 Honeycomb 3.0 API level 11 Gingerbread 2.3.3 - 2.3.7 API level 10 Gingerbread 2.3 - 2.3.2 API level 9, NDK 5 Froyo 2.2.x API level 8, NDK 4 Eclair 2.1 API level 7, NDK 3 Eclair 2.0.1 API level 6Eclair 2.0 API level 5Donut 1.6 API level 4, NDK 2 Cupcake 1.5 API level 3, NDK 1 (no code name) 1.1 API level 2(no code name) 1.0 API level 1android源码分支以及支持设备型号对应表Build Branch Version Supported devicesMMB29M android-6.0.1_r3 Marshmallow Nexus 6P, Nexus PlayerMMB29K android-6.0.1_r1 Marshmallow Nexus 5, Nexus 5X, Nexus 6, Nexus 7 (flo/deb), Nexus 9(volantis/volantisg)MMB29N android-6.0.0_r41 Marshmallow Nexus 6PMDB08M android-6.0.0_r26 Marshmallow Nexus 5X, Nexus 6P MDB08L android-6.0.0_r25 Marshmallow Nexus 5X, Nexus 6P MDB08K android-6.0.0_r24 Marshmallow Nexus 6PMDB08I android-6.0.0_r23 Marshmallow Nexus 5XMDA89E android-6.0.0_r12 Marshmallow Nexus 5XMDA89D android-6.0.0_r11 Marshmallow Nexus 6PMRA59B android-6.0.0_r7 Marshmallow Nexus 7 (deb) MRA58X android-6.0.0_r6 Marshmallow Nexus 6MRA58V android-6.0.0_r5 Marshmallow Nexus 7 (flo/deb) MRA58U android-6.0.0_r4 Marshmallow Nexus 7 (flo)MRA58N android-6.0.0_r2 Marshmallow Nexus 5, Nexus 6, Nexus 7(flo/deb), Nexus 9(volantis/volantisg), Nexus PlayerMRA58K android-6.0.0_r1 Marshmallow Nexus 5, Nexus 6, Nexus 7(flo/deb), Nexus 9(volantis/volantisg), Nexus PlayerLYZ28N android-5.1.1_r28 Lollipop Nexus 6 (For T-Mobile ONLY)LMY48Z android-5.1.1_r30 Lollipop Nexus 6, Nexus 7 (deb), Nexus 9 (volantisg), Nexus 10LMY48Y android-5.1.1_r26 Lollipop Nexus 6LMY48X android-5.1.1_r25 Lollipop Nexus 6, Nexus 7 (deb), Nexus 9 (volantisg), Nexus 10LMY48W android-5.1.1_r24 Lollipop Nexus 6LVY48H android-5.1.1_r23 Lollipop Nexus 6 (For Project Fi ONLY) LYZ28M android-5.1.1_r22 Lollipop Nexus 6 (For T-Mobile ONLY) LMY48U android-5.1.1_r20 Lollipop Nexus 7 (deb)LMY48T android-5.1.1_r19 Lollipop Nexus 4, Nexus 6, Nexus 9 (volantis/volantisg), Nexus 10LVY48F android-5.1.1_r18 Lollipop Nexus 6 (For Project Fi ONLY) LYZ28K android-5.1.1_r17 Lollipop Nexus 6 (For T-Mobile ONLY) LMY48P android-5.1.1_r16 Lollipop Nexus 7 (deb)LMY48N android-5.1.1_r15 Lollipop Nexus PlayerLMY48M android-5.1.1_r14 Lollipop Nexus 4, Nexus 5, Nexus 6, Nexus 7 (flo), Nexus 9 (volantis/volantisg), Nexus 10LVY48E android-5.1.1_r13 Lollipop Nexus 6 (For Project Fi ONLY) LYZ28J android-5.1.1_r12 Lollipop Nexus 6 (For T-Mobile ONLY) LMY48J android-5.1.1_r10 Lollipop Nexus PlayerLMY48I android-5.1.1_r9 Lollipop Nexus 4, Nexus 5, Nexus 6, Nexus 7 (flo), Nexus 9 (volantis/volantisg), Nexus 10LVY48C android-5.1.1_r8 Lollipop Nexus 6 (For Project Fi ONLY)LMY48G android-5.1.1_r6 Lollipop Nexus 7 (flo)LYZ28E android-5.1.1_r5 Lollipop Nexus 6 (For T-Mobile ONLY)LMY47Z android-5.1.1_r4 Lollipop Nexus 6 (All carriers except T-Mobile US)LMY48B android-5.1.1_r3 Lollipop Nexus 5LMY47X android-5.1.1_r2 Lollipop Nexus 9 (volantis)LMY47V android-5.1.1_r1 Lollipop Nexus 7 (flo/grouper), Nexus 10, Nexus PlayerLMY47O android-5.1.0_r5 Lollipop Nexus 4, Nexus 7 (flo/deb) LMY47M android-5.1.0_r4 Lollipop Nexus 6 (For T-Mobile ONLY)LMY47I android-5.1.0_r3 Lollipop Nexus 5, Nexus 6LMY47E android-5.1.0_r2 Lollipop Nexus 6LMY47D android-5.1.0_r1 Lollipop Nexus 5, Nexus 6, Nexus 7 (grouper/tilapia), Nexus 10, Nexus PlayerLRX22L android-5.0.2_r3 Lollipop Nexus 9 (volantis/volantisg)LRX22G android-5.0.2_r1 Lollipop Nexus 7(flo/deb/grouper/tilapia), Nexus 10LRX22C android-5.0.1_r1 Lollipop Nexus 4, Nexus 5, Nexus 6 (shamu), Nexus 7 (flo), Nexus 9(volantis/volantisg), Nexus 10LRX21V android-5.0.0_r7.0.1 Lollipop Nexus Player (fugu)LRX21T android-5.0.0_r6.0.1 Lollipop Nexus 4LRX21R android-5.0.0_r5.1.0.1 Lollipop Nexus 9 (volantis)LRX21Q android-5.0.0_r5.0.1 Lollipop Nexus 9 (volantis)LRX21P android-5.0.0_r4.0.1 Lollipop Nexus 7 (flo/grouper), Nexus 10LRX21O android-5.0.0_r3.0.1 Lollipop Nexus 5 (hammerhead), Nexus 6 (shamu)LRX21M android-5.0.0_r2.0.1 Lollipop Nexus Player (fugu) LRX21L android-5.0.0_r1.0.1 Lollipop Nexus 9 (volantis)KTU84Q android-4.4.4_r2 KitKat Nexus 5 (hammerhead) (For2Degrees/NZ, Telstra/AUS and India ONLY)KTU84P android-4.4.4_r1 KitKat Nexus 5, Nexus 7(flo/deb/grouper/tilapia), Nexus 4, Nexus 10KTU84M android-4.4.3_r1.1 KitKat Nexus 5 (hammerhead)KTU84L android-4.4.3_r1 KitKat Nexus 7(flo/deb/grouper/tilapia), Nexus 4, Nexus 10KVT49L android-4.4.2_r2 KitKat Nexus 7 (deb Verizon)KOT49H android-4.4.2_r1 KitKat Nexus 5, Nexus 7(flo/deb/grouper/tilapia), Nexus 4, Nexus 10KOT49E android-4.4.1_r1 KitKat Nexus 5, Nexus 7(flo/deb/grouper/tilapia), Nexus 4, Nexus 10KRT16S android-4.4_r1.2 KitKatNexus 7(flo/deb/grouper/tilapia), Nexus 4, Nexus 10KRT16M android-4.4_r1 KitKat Nexus 5 (hammerhead)JLS36I android-4.3.1_r1 Jelly Bean N exus 7 (deb) JLS36C android-4.3_r3 Jelly Bean N exus 7 (deb) JSS15R android-4.3_r2.3 Jelly Bean N exus 7 (flo) JSS15Q android-4.3_r2.2 Jelly Bean N exus 7 (flo) JSS15J android-4.3_r2.1 Jelly Bean N exus 7 (flo/deb) JSR78D android-4.3_r2Jelly Bean N exus 7 (deb)JWR66Y android-4.3_r1.1Jelly BeanGalaxy Nexus, Nexus 7 (grouper/tilapia), Nexus 4, Nexus 10JWR66V android-4.3_r1Jelly BeanGalaxy Nexus, Nexus 7(grouper/tilapia), Nexus 4, Nexus 10JWR66N android-4.3_r0.9.1Jelly Bean Galaxy Nexus, Nexus 7(grouper/tilapia/flo), Nexus 4, Nexus10JWR66L android-4.3_r0.9 Jelly Bean N exus 7JDQ39E android-4.2.2_r1.2 Jelly Bean N exus 4JDQ39B android-4.2.2_r1.1 Jelly Bean N exus 7JDQ39 android-4.2.2_r1Jelly BeanGalaxy Nexus, Nexus 7, Nexus 4, Nexus 10JOP40G android-4.2.1_r1.2 Jelly Bean N exus 4JOP40F android-4.2.1_r1.1 Jelly Bean N exus 10JOP40D android-4.2.1_r1Jelly BeanGalaxy Nexus, Nexus 7, Nexus 4, Nexus 10JOP40C android-4.2_r1Jelly BeanGalaxy Nexus, Nexus 7, Nexus 4,Nexus 10JZO54M android-4.1.2_r2.1 Jelly BeanJZO54L android-4.1.2_r2Jelly BeanJZO54K android-4.1.2_r1Jelly Bean N exus S, Galaxy Nexus, Nexus 7JRO03S android-4.1.1_r6.1 Jelly Bean N exus 7 JRO03R android-4.1.1_r6 Jelly Bean N exus S 4G JRO03O android-4.1.1_r5 Jelly Bean G alaxy Nexus JRO03L android-4.1.1_r4 Jelly Bean N exus S JRO03H android-4.1.1_r3 Jelly BeanJRO03E android-4.1.1_r2Jelly Bean N exus SJRO03D android-4.1.1_r1.1 Jelly Bean N exus 7JRO03C android-4.1.1_r1 Jelly Bean G alaxy NexusIMM76L android-4.0.4_r2.1 Ice Cream SandwichIMM76K android-4.0.4_r2 Ice CreamSandwichGalaxy NexusIMM76I android-4.0.4_r1.2 Ice CreamSandwichGalaxy NexusIMM76D android-4.0.4_r1.1 Ice CreamSandwichNexus S, Nexus S 4G, Galaxy NexusIMM76 android-4.0.4_r1 Ice Cream SandwichIML77 android-4.0.3_r1.1 Ice Cream SandwichIML74K android-4.0.3_r1 Ice CreamSandwichNexus SICL53F android-4.0.2_r1 Ice CreamSandwichGalaxy NexusITL41F android-4.0.1_r1.2 Ice CreamSandwichGalaxy NexusITL41D android-4.0.1_r1.1 Ice CreamSandwichGalaxy NexusITL41D android-4.0.1_r1 Ice CreamSandwichGalaxy NexusGWK74 android-2.3.7_r1 Gingerbread Nexus S 4GGRK39F android-2.3.6_r1 Gingerbread Nexus One, Nexus S GRK39C android-2.3.6_r0.9 Gingerbread Nexus SGRJ90 android-2.3.5_r1 Gingerbread Nexus S 4GGRJ22 android-2.3.4_r1 Gingerbread Nexus One, Nexus S, Nexus S 4G GRJ06D android-2.3.4_r0.9 Gingerbread Nexus S 4GGRI54 android-2.3.3_r1.1 Gingerbread Nexus SGRI40 android-2.3.3_r1 Gingerbread Nexus One, Nexus SGRH78C android-2.3.2_r1 Gingerbread Nexus SGRH78 android-2.3.1_r1 Gingerbread Nexus SGRH55 android-2.3_r1 Gingerbread earliest Gingerbread version, Nexus SFRK76C android-2.2.3_r2 FroyoFRK76 android-2.2.3_r1 FroyoFRG83G android-2.2.2_r1 Froyo Nexus One FRG83D android-2.2.1_r2 Froyo Nexus One FRG83 android-2.2.1_r1 Froyo Nexus One FRG22D android-2.2_r1.3 FroyoFRG01B android-2.2_r1.2 FroyoFRF91 android-2.2_r1.1 Froyo Nexus One FRF85B android-2.2_r1 Froyo Nexus One EPF21B android-2.1_r2.1p2 EclairESE81 android-2.1_r2.1s EclairEPE54B android-2.1_r2.1p Eclair Nexus OneERE27 android-2.1_r2 Eclair Nexus One ERD79 android-2.1_r1 Eclair Nexus One ESD56 android-2.0.1_r1 EclairESD20 android-2.0_r1 EclairDMD64 android-1.6_r1.5 DonutDRD20 android-1.6_r1.4DRD08 android-1.6_r1.3DRC92 android-1.6_r1.2。
搭建Android源码编译环境
Android 2.3.1 的源代码并在 Ubuntu 10.04(32 位)上编译通过。
这篇文章简 要记录了下载、编译的过程。
关于搭建 Android 开发环境的文章已经有很多,本文只简要介绍一下,做为备 忘。
[ 编译前的准备 ] 这一步安装获取源代码以及编译所需要的软件,使用如下命令:$ sudo aptitude install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev 另外,参考别人编译 Android 2.3 的经验,安装了下列软件包:$ sudo apt-get install lib64z1-dev libc6-dev-amd64 g++-multilib lib64stdc++6 虽然 Android 官方网站上讲不支持 Java 6,不过我使用 Java 6 也可以编译通 过,所以在这里 Easwy 安装的是 Java 6。
首先去掉/etc/apt/sources.list 中 这两行的注释,使能 Java 6 源:deb /ubuntu lucid partner deb-src /ubuntu lucid partner 然后安装 Java 6 JDK:$ sudo aptitude install sun-java6-jdk1接下来下载 repo 工具,这是 Google 提供的一个 Python 脚本,方便管理多个 Git 版本库:$ cd ~ $ mkdir bin $ curl /repo >~/bin/repo $ chmod a+x ~/bin/repo 记得把 repo 加到你的路径中, 方便以后使用。
编辑~/.bashrc, 加入下面一行:PATH=$PATH:~/bin export PATH 然后用命令. ~/.bashrc,以后就可以直接使用 repo 命令了。
AndroidSDK与API版本对应关系
2012年6月28日推出果冻豆
2013年9月4日,KitKat(奇巧)
2014年10月16日推出棒棒糖 2015年5月28日 推出棉花糖 2016年8月22日 Nougat(牛轧糖) 2017年3月21日推出奥利奥 2018年8月7日馅饼 2019年9月4日 2020年9月9日
API level
API level 1 API level 2 API level 3, NDK 1 API level 4, NDK 2 API level 5 API level 6 API level 7, NDK 3 API level 8, NDK 4 API level 9, NDK 5 API level 10 API level 11 API level 12, NDK 6 API level 13 API level 14, NDK 7 API level 15, NDK 8 API level 16 API level 17 API level 18 API level 19 API level 20 API level 21 API level 22 API level 23 API level 24 API level 25 API level 26 API level 27 API level 28 API level 29 API level 30
Version
1.0 1.1 1.5 1.6 2.0 2.0.1 2.1 2.2.x 2.3 - 2.3.2 2.3.3 - 2.3.7 3.0 3.1 3.2.x 4.0.1 - 4.0.2 4.0.3 - 4.0.4 4.1.x 4.2.x 4.3.x 4.4 - 4.4.4 4.4W 5.0 5.1 6.0 7.0 7.1.1 8.0 8.1 9.0 10.0 11.0
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Android API LevelsAs you develop your application on Android, it's useful to understand the platform's general approach to API change management. It's also important to understand the API Level identifier and the role it plays in ensuring your application's compatibility with devices on which it may be installed.The sections below provide information about API Level and how it affects your applications.For information about how to use the "Filter by API Level" control available in the API reference documentation, see Filtering the documentation at the end of this document.What is API Level?API Level is an integer value that uniquely identifies the framework API revision offered by a version of the Android platform.The Android platform provides a framework API that applications can use to interact with the underlying Android system. The framework API consists of:A core set of packages and classesA set of XML elements and attributes for declaring a manifest fileA set of XML elements and attributes for declaring and accessing resourcesA set of IntentsA set of permissions that applications can request, as well as permission enforcements included in the systemEach successive version of the Android platform can include updates to the Android application framework API that it delivers.Updates to the framework API are designed so that the new API remains compatible with earlier versions of the API. That is, most changes in the API are additive and introduce new or replacement functionality. As parts of the API are upgraded, the older replaced parts are deprecated but are not removed, so that existing applications can still use them. In a very small number of cases, parts of the API may be modified or removed, although typically such changes are only needed to ensure API robustness and application or system security. All other API parts from earlier revisions are carried forward without modification.The framework API that an Android platform delivers is specified using an integer identifier called "API Level". Each Android platform version supports exactly one API Level, although support is implicit for all earlier API Levels (down to API Level 1). The initial release of the Android platform provided API Level 1 and subsequent releases have incremented the API Level.The following table specifies the API Level supported by each version of the Android platform.Platform V ersion API LevelAndroid 2.2 8Android 2.1 7Android 2.0.1 6Android 2.0 5Android 1.6 4Android 1.5 3Android 1.1 2Android 1.0 1Uses of API Level in AndroidThe API Level identifier serves a key role in ensuring the best possible experience for users and application developers:It lets the Android platform describe the maximum framework API revision that it supportsIt lets applications describe the framework API revision that they requireIt lets the system negotiate the installation of applications on the user's device, such that version-incompatible applications are not installed.Each Android platform version stores its API Level identifier internally, in the Android system itself.Applications can use a manifest element provided by the framework API —<uses-sdk> —to describe the minimum and maximum API Levels under which they are able to run, as well as the preferred API Level that they are designed to support. The element offers three key attributes: android:minSdkV ersion — Specifies the minimum API Level on which the application is able to run. The default value is "1".android:targetSdkV ersion — Specifies the API Level on which the application is designed to run. In some cases, this allows the application to use manifest elements or behaviors defined in the target API Level, rather than being restricted to using only those defined for the minimum API Level.android:maxSdkV ersion — Spec ifies the maximum API Level on which the application is able to run. Important: Please read the <uses-sdk> documentation before using this attribute.For example, to specify the minimum system API Level that an application requires in order to run, the application would include in its manifest a <uses-sdk> element with a android:minSdkV ersion attribute. The value of android:minSdkV ersion would be the integer corresponding to the API Level of the earliest version of the Android platform under which the application can run.When the user attempts to install an application, or when revalidating an appplication after a system update, the Android system first checks the <uses-sdk> attributes in the application's manifest and compares the values against its own internal API Level. The system allows the installation to begin only if these conditions are met:If a android:minSdkV ersion attribute is declared, its value must be less than or equal to the system's API Level integer. If not declared, the system assumes that the application requires API Level 1.If a android:maxSdkV ersion attribute is declared, its value must be equal to or greater than the system's API Level integer. If not declared, the system assumes that the application has no maximum API Level. Please read the <uses-sdk> documentation for more information about how the system handles this attribute.When declared in an application's manifest, a <uses-sdk> element might look like this:<manifest>...<uses-sdk android:minSdkV ersion="5" />...</manifest>The principal reason that an application would declare an API Level in android:minSdkV ersion is to tell the Android system that it is using APIs that were introduced in the API Level specified. If the application were to be somehow installed on a platform with a lower API Level, then it would crash at run-time when it tried to access APIs that don't exist. The system prevents such an outcome by not allowing the application to be installed if the lowest API Level it requires is higher than that of the platform version on the target device.For example, the android.appwidget package was introduced with API Level 3. If an application uses that API, it must declare a android:minSdkV ersion attribute with a value of "3". The application will then be installable on platforms such as Android 1.5 (API Level 3) and Android 1.6 (API Level 4), but not on the Android 1.1 (API Level 2) and Android 1.0 platforms (API Level 1).For more information about how to specify an application's API Level requirements, see the <uses-sdk> section of the manifest file documentation.Development ConsiderationsThe sections below provide information related to API level that you should consider when developing your application.Application forward compatibilityAndroid applications are generally forward-compatible with new versions of the Android platform.Because almost all changes to the framework API are additive, an Android application developed using any given version of the API (as specified by its API Level) is forward-compatible with later versions of the Android platform and higher API levels. The application should be able to run on all later versions of the Android platform, except in isolated cases where the application uses a part of the API that is later removed for some reason.Forward compatibility is important because many Android-powered devices receive over-the-air (OTA) system updates. The user may install your application and use it successfully, then later receive an OTA update to a new version of the Android platform. Once the update is installed, your application will run in a new run-time version of the environment, but one that has the API and system capabilities that your application depends on.In some cases, changes below the API, such those in the underlying system itself, may affect your application when it is run in the new environment. For that reason it's important for you, as the application developer, to understand how the application will look and behave in each system environment. To help you test your application on various versions of the Android platform, the Android SDK includes multiple platforms that you can download. Each platform includes a compatible system image that you can run in an A VD, to test your application.Application backward compatibilityAndroid applications are not necessarily backward compatible with versions of the Android platform older than the version against which they were compiled.Each new version of the Android platform can include new framework APIs, such as those that give applications access to new platform capabilities or replace existing API parts. The new APIs are accessible to applications when running on the new platform and, as mentioned above, also when running on later versions of the platform, as specified by API Level. Conversely, because earlier versions of the platform do not include the new APIs, applications that use the new APIs are unable to run on those platforms.Although it's unlikely that an Android-powered device would be downgraded to a previous version of the platform, it's important to realize that there are likely to be many devices in the field that run earlier versions of the platform. Even among devices that receive OTA updates, some might lag and might not receive an update for a significant amount of time.Selecting a platform version and API LevelWhen you are developing your application, you will need to choose the platform version against which you will compile the application. In general, you should compile your application against the lowest possible version of the platform that your application can support.Y ou can determine the lowest possible platform version by compiling the application against successively lower build targets. After you determine the lowest version, you should create an A VD using the corresponding platform version (and API Level) and fully test your application. Make sure to declare a android:minSdkV ersion attribute in the application's manifest and set its value to the API Level of the platform version.Declaring a minimum API LevelIf you build an application that uses APIs or system features introduced in the latest platform version, you should set the android:minSdkV ersion attribute to the API Level of the latest platform version. This ensures that users will only be able to install your application if their devices are running a compatible version of the Android platform. In turn, this ensures that your application can function properly on their devices.If your application uses APIs introduced in the latest platform version but does not declare a android:minSdkV ersion attribute, then it will run properly on devices running the latest version of the platform, but not on devices running earlier versions of the platform. In the latter case, the application will crash at runtime when it tries to use APIs that don't exist on the earlier versions.T esting against higher API LevelsAfter compiling your application, you should make sure to test it on the platform specified in the application's android:minSdkV ersion attribute. To do so, create an A VD that uses the platform version required by your application. Additionally, to ensure forward-compatibility, you should run and test the application on all platforms that use a higher API Level than that used by your application.The Android SDK includes multiple platform versions that you can use, including the latest version, and provides an updater tool that you can use to download other platform versions as necessary.To access the updater, use the android command-line tool, located in the <sdk>/tools directory. Y ou can launch the Updater by using the android command without specifying any options. Y ou can also simply double-click the android.bat (Windows) or android (OS X/Linux) file. In ADT, you can also access the updater by selecting Window > Android SDK and A VD Manager.To run your application against different platform versions in the emulator, create an A VD for each platform version that you want to test. For more information about A VDs, see Android Virtual Devices. If you are using a physical device for testing, ensure that you know the API Level of the Android platform it runs. See the table at the top of this document for a list of platform versions and their API Levels.Using a Provisional API LevelIn some cases, an "Early Look" Android SDK platform may be available. To let you begin developing on the platform although the APIs may not be final, the platform's API Level integer will not be specified. Y ou must instead use the platform's provisional API Level in your application manifest, in order to build applications against the platform. A provisional API Level is not an integer, but a string matching the codename of the unreleased platform version. The provisional API Level will be specified in the release notes for the Early Look SDK release notes and is case-sensitive.The use of a provisional API Level is designed to protect developers and device users from inadvertently publishing or installing applications based on the Early Look framework API, which may not run properly on actual devices running the final system image.The provisional API Level will only be valid while using the Early Look SDK and can only be used to run applications in the emulator. An application using the provisional API Level can never be installed on an Android device. At the final release of the platform, you must replace any instances of the provisional API Level in your application manifest with the final platform's actual API Level integer.Filtering the Reference Documentation by API LevelReference documentation pages on the Android Developers site offer a "Filter by API Level" control in the top-right area of each page. Y ou can use the control to show documentation only for parts of the API that are actually accessible to your application, based on the API Level that it specifies in the android:minSdkV ersion attribute of its manifest file.To use filtering, select the checkbox to enable filtering, just below the page search box. Then set the "Filter by API Level" control to the same API Level as specified by your application. Notice that APIs introduced in a later API Level are then grayed out and their content is masked, since they would not be accessible to your application.Filtering by API Level in the documentation does not provide a view of what is new or introduced in each API Level — it simply provides a way to view the entire API associated with a given API Level, while excluding API elements introduced in later API Levels.If you decide that you don't want to filter the API documentation, just disable the feature using the checkbox. By default, API Level filtering is disabled, so that you can view the full framework API, regardless of API Level.Also note that the reference documentation for individual API elements specifies the API Level at which each element was introduced. The API Level for packages and classes is specified as "Since <api level>" at the top-right corner of the content area on each documentation page. The API Level for class members is specified in their detailed description headers, at the right margin.。