Android 2.3姜饼的API改变大全

简介:     Android 2.3姜饼由Google正式发布,这款开发代号为Gingerbread的Android 2.3包含哪些新特性和改进呢?        1. 新增android.net.sip包,名为SipManager类,可以轻松开发基于Sip的Voip应用。
    Android 2.3姜饼由Google正式发布,这款开发代号为Gingerbread的Android 2.3包含哪些新特性和改进呢?

       1. 新增android.net.sip包,名为SipManager类,可以轻松开发基于Sip的Voip应用。同时使用时必须至少包含这两个权限 <uses-permission android:name="android.permission.INTERNET"> and <uses-permission android:name="android.permission.USE_SIP">,如果需要在Market上过滤仅显示支持VoIP API的机型,可以在发布时androidmanifest.xml中加入 <uses-feature android:name="android.software.sip" android:required="true"> 和 <uses-feature android:name="android.software.sip.voip"> 这两个标志。

      2. Near Field Communications (NFC) 近距离通讯的支持,NFC可以在不接触的情况下实现数据交换通讯,可以很好的代替RFID SIM卡实现手机支付等扩展功能,当然Android123提示这需要硬件的支持
    ,新增包在 android.nfc包含NfcAdapter,NdefMessage,NdefRecord等类,类似蓝牙的处理方式,使用该API需要声明权限<uses-permission android:name="android.permission.NFC"> ,同时在Market上过滤支持NFC的设备需要加入<uses-feature android:name="android.hardware.nfc" android:required="true">这句。

      3. 新增陀螺仪和其他的传感器支持

      Android 2.3加入了一些新的感应器,比如gyroscope陀螺仪, rotation vector旋转向量, linear acceleration线性加速器 gravity和barometer气压计的支持。如果过滤这些功能,发布时加入类似<uses-feature android:name="android.hardware.sensor.gyroscope" android:required="true">到androidmanifest.xml中。

      4. 多摄像头支持

    新增 Camera.CameraInfo 可以管理摄像头前置或后置
    新增 getNumberOfCameras(), getCameraInfo() 和 getNumberOfCameras() 获取摄像头数量。  
    新增 get() 方法,可以获取摄像头配置信息 CamcorderProfile

    新增 getJpegEncodingQualityParameter() 获取jpeg编码质量参数可以在 CameraPreview.java 文件从ApiDemos示例程序中查看。

     5. 新增拍照API

      比如获取焦距getFocusDistances()获取预览FPS getPreviewFpsRange(), 获取焦距范围 getSupportedPreviewFpsRange() 和设置教育 setPreviewFpsRange()

     6. 混响音效

     本次Android 2.3框架中加入了对混响音效的支持,比如低音,耳机和虚拟化等效果.

    新增 android.media.audiofx 包
    新增 AudioEffect 类提供音效控制
    新增音频会话ID,设置 AudioTrack 和 MediaPlayer.
    新 AudioTrack 新增 attachAuxEffect()、getAudioSessionId()和 setAuxEffectSendLevel()。
    新 attachAuxEffect() ,getAudioSessionId(), setAudioSessionId(int), 和 setAuxEffectSendLevel() .
    相关音效在 AudioFxDemo.java 的 ApiDemos 示例。

    6. 照片EXIF信息改进

    新增 经纬度标签在JPG格式的EXIF中,同时可以使用 getAltitude() 方法获取经纬度的EXIF信息
    新增setOrientationHint() 可以让程序获取视频录制的方向.

    7. 下载管理

     在Android 2.3中新增的下载管理支持长时间运行的Http下载服务支持。可以保证在手机重启后仍然重试下载等操作,整个过程在后台执行。

     通过 DownloadManager 类使用getSystemService(DOWNLOAD_SERVICE) 来实例化,通过 ACTION_NOTIFICATION_CLICKED 这个Intent来处理。

    8. 限制模式

      可以帮助开发者监控他的应用的性能,处理线程阻塞,避免ANR的发生。

    StrictMode.ThreadPolicy 和 StrictMode.VmPolicy 获取VM相关信息.
    使用限制模式优化的Android应用程序可以查看android.os.StrictMode包的具体介绍。


Android 2.3的API Level为9,有关所有的API改变,Android123帮助大家总结如下:

  新增包

android.media.audiofx    混响音效
android.net.sip     VOIP支持
android.nfc      NFC支付支持
android.os.storage  存储管理类

详细的请查看 Android 2.3新特性及改进列表,已正式发布 一文

移除类

VMDebug  
VMRuntime  
VMStack  
Zygote

更多改进
Extra Large Screens

  目前Android 2.3将支持更大的屏幕尺寸定义,开发者可以通过 <supports screens ... android:xlargeScreens="true"> 元素在你的 manifest files 中定义,新增的 xlarge 标记将支持更多的屏幕尺寸, 有关具体的使用方法,Android开发网将在今后的文章中讲到。.
Graphics

    * 添加保留了OpenGL ES 2.0 中的 glDrawElements() 和 glVertexAttribPointer() 方法在 android.opengl.GLES20 类中.
    * 新增YV12 pixel 格式和 4:2:0 YCrCb 格式的支持。

Content Providers

    * New AlarmClock provider class for setting an alarm or handling an alarm. The provider contains a ACTION_SET_ALARM Intent action and extras that can be used to start an Activity to set a new alarm in an alarm clock application. Applications that wish to receive the SET_ALARM Intent should create an activity that requires the the SET_ALARM permission. Applications that wish to create a new alarm should use Context.startActivity(), so that the user has the option of choosing which alarm clock application to use.
    * MediaStore supports a new Intent action, PLAY_FROM_SEARCH, that lets an application search for music media and automatically play content from the result when possible. For example, an application could fire this Intent as the result of a voice recognition command to listen to music.
    * MediaStore also adds a new MEDIA_IGNORE_FILENAME flag that tells the media scanner to ignore media in the containing directory and its subdirectories. Developers can use this to avoid having graphics appear in the Gallery and likewise prevent application sounds and music from showing up in the Music app.
    * The Settings provider adds the new Activity actions APPLICATION_DETAILS_SETTINGS and MANAGE_ALL_APPLICATIONS_SETTINGS, which let an application show the details screen for a specific application or show the Manage Applications screen.
    * The ContactsContract provider adds the ContactsContract.CommonDataKinds.SipAddress data kind, for storing a contact's SIP (Internet telephony) address.

Location

    *  LocationManager 类可以跟踪程序请求wake locks 或 wifi locks 的结果通过 to WorkSource 类,让系统管理指定的程序.

      The LocationManager keeps track of all clients requesting periodic updates, and tells its providers about them as a WorkSource parameter, when setting their minimum update times. The network location provider uses WorkSource to track the wake and wifi locks initiated by an application and adds it to the application's battery usage reported in Manage Applications.
    * The LocationManager adds several new methods that let an Activity register to receive periodic or one-time location updates based on specified criteria (see below).
    * A new Criteria class lets an application specify a set of criteria for selecting a location provider. For example, providers may be ordered according to accuracy, power usage, ability to report altitude, speed, and bearing, and monetary cost.

Storage

    * Android 2.3 新增 StorageManager 类支持 OBB (Opaque Binary Blob) 文件在 Android 2.3上开发恐惧创建和管理OBB文件将在2011年早期无法使用。
    * 加入一些判断虚拟SD分区,类似三星i9000可能存在虚拟的SD路径,所以 isExternalStorageRemovable() 可以知道是否是一个物理的SD卡.

Package Manager

    * PackageInfo 新增 firstInstallTime 和 lastUpdateTime 可以查看一个软件的安装和上次更新时间,这比直接获取APK路径查看文件时间更可靠,对于付费的私有路径未root的机型无权限获取的。
    * 新增 getProviderInfo() 方法获取content provider类相关信息.

Telephony

    * TelephonyManager 增加了对CDMA EVDO Rev B网络类型的定义NETWORK_TYPE_EVDO_B.
    * 新的 getPsc() 返回私有混合码从UMTS网络.

Android 2.3 可以让应用本地访问声明周期和窗口

  NativeActivity是一个新的Activity类整个声明周期的方法可以通过本地C/C++代码直接访问,使用Android NDK r5或更高版本即可支持。

    * 新增 InputQueue 类提供本地管理事件队列的回调接口
    * 新增 SurfaceHolder.Callback2 接口可以让C/C++代码管理 SurfaceHolder.
    * 新增 takeInputQueue 和 takeSurface() 让本地代码管理一个窗口事件.

有关最新版的NDK下载和NDK参考文档可以在 Android开发包下载 中找到。

有关Dalvik运行时库

    * dalvik.system  移除了很多类,在上一版本这些类已经标记为将放弃使用包含以下
    * Dalvik 核心库:
          o 新增 collections: ArrayDeque, NavigableMap, ConcurrentSkipListMap, LinkedBlockingDeque 数据类型
          o 新增 Arrays 辅助方法: binarySearch(), copyOf(), copyOfRange(), and others.
          o 新增CookieManager针对HttpURLConnection.
          o 更完整的网络API支持比如 InterfaceAddress, NetworkInterface 和 IDN
          o 文件读写控制
          o String.isEmpty()
          o Normalizer 和 Normalizer.Form
          o 改进了 javax.net.ssl server sockets.

新增manifest元素和属性

    * 新增 xlargeScreens 属性针对 <supports-screens> 元素,可以支持更大设备比如说Android平板的定义。
    * 新的屏幕方向属性 android:screenOrientation 在<activity> 中
          o "reverseLandscape" — The Activity would like to have the screen in landscape orientation, turned in the opposite direction from normal landscape.
          o "reversePortait" — The Activity would like to have the screen in portrait orientation, turned in the opposite direction from normal portrait.
          o "sensorLandscape" — The Activity would like to have the screen in landscape orientation, but can use the sensor to change which direction the screen is facing.
          o "sensorPortrait" — The Activity would like to have the screen in portrait orientation, but can use the sensor to change which direction the screen is facing.
          o "fullSensor" — Orientation is determined by a physical orientation sensor: the display will rotate based on how the user moves the device. This allows any of the 4 possible rotations, regardless of what the device will normally do (for example some devices won't normally use 180 degree rotation).

新增 Permissions

    * com.android.permission.SET_ALARM —设置一个提醒权限.
    * android.permission.USE_SIP — 使用SIP接收一个VOIP.
    * android.permission.NFC — 允许程序使用NFC支持

有关硬件的改进如下

android.hardware.audio.low_latency — 允许使用 low-latency 音频管道在设备和可以提供敏感的延迟在声音输出输出上。
android.hardware.camera.front — 前置摄像头控制类.
android.hardware.nfc —  NFC近距无线设备管理.
android.hardware.sensor.barometer — 气压计感应器支持类The application uses the device's barometer.
android.hardware.sensor.gyroscope —  陀螺仪感应器支持类 The application uses the device's gyroscope sensor.
android.software.sip — SIP VoIP类.
android.software.sip.voip — 使用基于 SIP的 VoIP 服务.
android.hardware.touchscreen.multitouch.jazzhand — 增强的多点触控类,可以实现跟踪5个或更多的点.

以上是Android 2.3姜饼的API改变大全
目录
相关文章
|
8月前
|
定位技术 API 开发工具
Android 按照步骤接入百度地图API,定位显示不了解决办法
Android 按照步骤接入百度地图API,定位显示不了解决办法
225 0
|
7月前
|
API Android开发
mPaaS(移动跨平台框架)目前已经支持了Android API级别21
mPaaS(移动跨平台框架)目前已经支持了Android API级别21
106 2
|
8月前
|
API 数据库 Android开发
Android SQLite数据库中基础的增删改查操作以及API的详解
Android SQLite数据库中基础的增删改查操作以及API的详解
65 0
|
10月前
|
API Android开发
Android Activity Result API
Android Activity Result API
98 0
|
11月前
|
Java API Android开发
Sui为根应用提供Java APIs,滴API。主要提供直接使用Android APIs的能力(几乎以Java作为root的身份
Sui为根应用提供Java APIs,滴API。主要提供直接使用Android APIs的能力(几乎以Java作为root的身份,在root下启动app自己的AIDL风格的Java服务。这将使root应用程序开发变得更加容易。
142 0
|
12月前
|
缓存 Java API
Android音频API
MediaRecorder与MediaPlayer并不能算完整意义的音频API,它们只是系统音频API的封装,除了采集/播放,他们集成了编码/解码、复用/解复用等能力。它们在最底层还是调用了AudioRecorder、AudioTrack。下面主要介绍它们的几个主要的配置项。
355 0
|
Ubuntu Java Shell
Android使用FFmpeg的API库
Android使用FFmpeg的API库
293 1
|
定位技术 API Android开发
Android Studio进行APP设计调用百度地图API接口隐藏百度地图的logo方法
Android Studio进行APP设计调用百度地图API接口隐藏百度地图的logo方法
315 0
Android Studio进行APP设计调用百度地图API接口隐藏百度地图的logo方法
|
存储 缓存 Java
Android 百度语音合成 (含离线、在线、API合成方式,详细步骤+源码)
Android 百度语音合成 (含离线、在线、API合成方式,详细步骤+源码)
498 0
Android 百度语音合成 (含离线、在线、API合成方式,详细步骤+源码)
|
XML API Android开发
Android 垃圾分类APP(一)申请API、搭建项目、访问接口获取数据
Android 垃圾分类APP(一)申请API、搭建项目、访问接口获取数据
370 0
Android 垃圾分类APP(一)申请API、搭建项目、访问接口获取数据