Android 0.9 API改变中文总结

最新的Android 0.9 SDK和m5-rc15相比API有什么改变呢? 下面我们一起来看看,有关详细的Package以及API的添加、删除、修改如下:

  一、移除了下面的Package

android.awt   
android.telephony.gsm.stk   
android.test.mock   
com.google.android.gtalkservice   
java.lang.instrument   
javax.sound.midi   
javax.sound.midi.spi   
javax.sound.sampled   
javax.sound.sampled.spi 
org.apache.http.client.methods.multipart
org.apache.http.impl  (移动到内部实现)
org.apache.http.impl.auth  (移动到内部实现)
org.apache.http.impl.client  (移动到内部实现)
org.apache.http.impl.conn  (移动到内部实现)
org.apache.http.impl.conn.tsccm  (移动到内部实现)
org.apache.http.impl.cookie  (移动到内部实现)
org.apache.http.impl.entity  (移动到内部实现)
org.apache.http.impl.io  (移动到内部实现)
org.apache.http.util.concurrent 
org.bluez

我们看到主要是一些J2ME时代的音乐播放类,还有Apache相关的部分方法移到内部来实现了,不过蓝牙支持在0.9版Android SDK中存在些问题

 二、增加的Package

android.content.res  
android.net.wifi  
android.preference   
android.test   
android.test.suitebuilder.annotation   
dalvik.annotation   
dalvik.bytecode   
dalvik.system   
java.awt.font   
javax.microedition.khronos.egl   
javax.xml   
org.apache.http.client.entity   
org.apache.http.conn.routing   
org.apache.http.conn.scheme

  新增了一些实用的功能比如Wifi无线网络、http相关的操作、加入了AWT字体包。

三、修改的Package有下面

android   
android.app   
android.content   
android.content.pm   
android.database   
android.database.sqlite   
android.graphics   
android.graphics.drawable   
android.graphics.drawable.shapes   
android.hardware   
android.location   
android.media   
android.net   
android.opengl   
android.os   
android.provider   
android.telephony   
android.telephony.gsm   
android.text   
android.text.method   
android.text.style   
android.text.util   
android.util   
android.view   
android.view.animation   
android.webkit   
android.widget   
com.google.android.maps   
java.io   
java.lang.ref   
java.lang.reflect   
java.net   
java.util   
java.util.concurrent   
java.util.jar   
java.util.logging   
java.util.regex   
javax.net.ssl   
javax.xml.parsers   
org.apache.http   
org.apache.http.auth   
org.apache.http.auth.params   
org.apache.http.client   
org.apache.http.client.methods   
org.apache.http.client.params   
org.apache.http.client.protocol   
org.apache.http.client.utils   
org.apache.http.conn   
org.apache.http.conn.params   
org.apache.http.conn.ssl   
org.apache.http.conn.util   
org.apache.http.cookie   
org.apache.http.cookie.params   
org.apache.http.entity   
org.apache.http.message   
org.apache.http.params   
org.apache.http.protocol   
org.apache.http.util  

 修改了数据库SQLite、图形接口、正则表达式、以及HTTP文件相关的如SSL、XML解析

 详细的改变有

Activity (活动窗口类)

  • onFreeze(Bundle) 改名为onSaveInstanceState(Bundle)
  • onFreeze() 改名为onSaveInstanceState()
  • onThaw(Parcelable) 改名为 onRestoreInstanceState(Parcelable)
  • onCompleteThaw(Bundle) 改名为 onRestoreInstanceState(Bundle)
  • Preferred Activity: 这个将自动选择赋予Activity组件 (Preferred Activity) 挡 Context.startActivity() 找到多个匹配的Activites时将通过intent filter. 这个 package管理器提供API设置管理preferred Activities.
  • setResult()方法采用一个新的字符串参数已经被新的setResult()方法作为一个Intent参数替代。

Adapters (适配器)

  • FilterQueryProvider从SimpleCursorAdapter提升到CursorAdapter
  • 移除getMeasurementView() 从Adapter
  • 重命名Adapter.stableIds()成Adapter.hasStableIds()
  • 在ArrayAdapter中addObject(), removeObject() 和insertObject()重命名为add(), remove() and insert()
  • 使用SimpleAdapter更简单轻松,Binding现在能控制被客户端传递一个SimpleAdapter.ViewBinder到SimpleAdapter
  • 重命名CursorAdapter的runQuery()方法为runQueryOnBackgroundThread

Android Manifest (Android清单文件)

  • 一个新的manageSpaceActivity属性让你指明activity启动一个管理空间在用户请求时.这个系统启动时指明activity应用程序的空间需要被管理统称在一个通过用户动作引用时
  • 一个新的<activity-alias> 标签让你声明一个新的activity以便指向一个activity在manifest中.

Animations (动画剪辑)

  • 移除Animation.willChangeTargetBounds(), 使用变换类型在Transformation class中替代。
  • AnimationListener现在收到目标Animation作为一个参数到每个自己的方法。
    ViewGroup的setKeepAnimations(), isKeepAnimations() 和android:keepAnimations已经完成
  • Animation的fillAfter默认方式是禁用的
  • 一个View的animation现在清楚的当fillAfter=false,fillAfter=true.这个之前改变keepAnimations不得不设置一个true如果你有可用的animation 不是View的标准状态
  • Animation的Order在xml文件中属性已经重命名为animationOrder

Audio Volume

  • Introduces an API for controlling volume and ringer, see documentation for VolumeManager
  • An Activity can suggest its default volume stream type (one of those in AudioSystem).  When the user presses the volume keys while the Activity is shown, the suggested stream's volume will be adjusted instead of the default ringer volume.

Content

  • DatabaseContentProvider class replaced by SyncableContentProvider

Context Menus

  • Context menu API parallels options menu API by dropping the need to set listener on each view.  Most activities can remove existing OnPopulateContextMenuListener implementations, move the code into Activity#onCreateContextMenu, and register the views that should be launch context menus with Activity#registerForContextMenu(View)
  • onPopulateContextMenu* is now onCreateContextMenu*
  • Activity implements OnCreateContextMenuListener
  • New methods: Activity#onCreateContextMenu, Activity#registerForContextMenu(View), Activity#unregisterForContextMenu(View), Activity#openContextMenu are new methods.
  • AdapterView.ContextMenuInfo has been renamed to AdapterView.AdapterContextMenuInfo
  • The type of menuInfo parameter is now the ContextMenuInfo interface.
  • You can use View.showContextMenu to programmatically open a context menu for a view.

Cursor

  • Renamed count() to getCount()
  • Renamed position() to getPosition()
  • Renamed moveTo() to moveToPosition()
  • Renamed first() to moveToFirst()
  • Renamed last() to moveToLast()
  • Renamed next() to moveToNext()
  • Renamed prev() to moveToPrevious()
  • The deleteRow() method has been removed. Instead, use ContentResolver.delete(Uri, String, String[])
  • The following methods have been removed. Instead of these, use ContentResolver.update() or SQLiteDatabase.update()
    • supportsUpdates()
    • hasUpdates()
    • updateBlob(int,byte[])
    • updateString(int,String)
    • updateShort(int,short)
    • updateInt(int,int)
    • updateLong(int,long)
    • updateFloat(int,float)
    • updateDouble(int,double)
    • updateToNull(int)
    • commitUpdates()
    • commitUpdates(Map<>)
    • abortUpdates()

Dalvik

  • Adds two new packages that expose an API for working with dalvik VM

Database

  • ArrayListCursor class changed to MatrixCursor.

Debug

  • The @ViewDebug.ExportedProperty annotation can be used on fields and methods. Caution: use only on methods with no side-effect, like View.getWidth()) to export the property in the new HierarchyViewer tool.

Dialogs

  • Renamed AlertDialogBuilder.setCheckBoxItems to setMultiChoiceItems
  • Renamed AlertDialogBuilder.setRadioButtonItems to setSingleChoiceItems
  • Added support for Cursors in the AlertDialog.Builder. They can be used to create a simple list, check box list or a radio button list
  • Get rid of the static AlertDialog.show methods and change everything to use the AlertDialog.Builder

Hardware

  • The SensorManager class now notifies SensorListener objects of sensor changes, rather than firing Intents. The registerListener and unregisterListener methods are used to add and remove listeners.
  • There is a new constant SensorManager.STANDARD_GRAVITY that may be useful to interpret accelerometer values.
  • Adds a new sensor service to control enabling/disabling the compass and accelerometer
  • Adds a new Camera class with APIs for
    • Autofocus
    • Setting callback for each camera review frame, to allow apps to do image processing.
    • Setting callback for YUV-snapshot-ready notifications.
  • The class CameraDevice is removed, in favor of Camera.

Hardware Acceleration

  • Applications can now request to be drawn using hardware-accelerated OpenGL (if present.) To do so call Activity.requestWindowFeature(Window.FEATURE_OPENGL). This feature has several caveats: not all of the drawing primitives can be used (for instance dashed curves) and any invalidate request, even of a small region, triggers the redrawing of the whole activity

Inflation

  • Renamed ViewInflate to LayoutInflater
  • Renamed Activity.getViewInflate() to Activity.getLayoutInflater()
  • Renamed Window.getViewInflate() to Window.getLayoutInflater()
  • Renamed Context.INFLATE_SERVICE to Context.INFLATER_SERVICE
  • Menus can be inflated via XML (see ApiDemos).

Intents, Intent Filters, Intent Broadcast

  • IntentReceiver renamed BroadcastReceiver
  • IntentReceiver.onReceiveIntent() renamed BroadcastReceiver.onReceive()
  • Context.broadcastIntent() renamed Context.sendBroadcast()
  • Context.broadcastIntentSerialized() renamed Context.sendSerializedBroadcast()
  • Context.broadcastStickyIntent() renamed Context.sendStickyBroadcast()
  • PathEntry type replaced by PatternMatcher
  • New PendingIntent class. This will be used instead of raw Intent objects everywhere we give an Intent to some other application which will then execute it for us (such as the alarm manager, status bar, location services, etc). The main point of this is to provide this functionality in a secure way, so that the service can have the Intent broadcast with the permissions of the client,and the client can control which intents the service can broadcast under its identity. This has an additional benefit of abstracting out the actual operation to be performed on the intent (starting an activity, broadcasting an intent, and later others) from the service itself, allowing the client to decide exactly what will happen.

Location (Geo)

  • The android.hardware.Sensors class has been replaced by android.hardware.SensorManager and android.hardware.SensorListener.
  • The SensorManager class now notifies SensorListener objects of sensor changes, rather than firing Intents. The registerListener and unregisterListener methods are used to add and remove listeners.
  • There is a new constant SensorManager.STANDARD_GRAVITY that may be useful to interpret accelerometer values.
  • A method LocationManager.getProviderNames() has been added that
  • returns the names of all providers, including ones for which the caller lacks permissions.
  • The LocationManager class now notifies LocationListener objects of location and status changes, rather than firing Intents.
  • The requestUpdates method has been renamed to requestLocationUpdates and now takes a LocationListener object rather than an Intent.
  • A new requestStatusUpdates method has been added, also taking a LocationListener object.
  • The removeUpdates method now takes a LocationListener object.
  • The LocationManager.request*Updates methods must be called from a Looper thread, such as the main thread of an Activity. Additional method variants have been added that take an explicit Looper argument to allow for use outside of a main thread.
  • A number of constants have been added to the LocationManager class.
  • The LocationProviderImpl class has been removed.
  • The Address class has several addtional fields and accessors in or order to better describe real locations.  Several incorrectly named methods have been renamed.
  • The Geocoder class contructor now requires a Context parameter.
  • The Location class now includes information on the estimated accuracy of a fix. It has new reset() and set() methods.

MapView

  • New required MapView attribute: android:apiKey. Just like the traditional Google Maps API, you will be required to provide an authentic API key for your Android application. For now, the value of this can be an arbitrary string, like "myapikey," but will need to be changed in order to work on actual devices. A process for acquiring a key is coming soon.
  • MapView.toggle* replaced with set*. DeviceType removed from all Overlay methods.
  • OverlayController removed, replaced with direct access to the Overlay List, with MapView.getOverlays(). The recommended practice is to use the new ItemizedOverlay class to manage map Overlays.
  • Adds support for "map pin" child view that marks a given geo-location on the map. Such a view would stay in the correct place as the map is scrolled and zoomed:
  • MapView child views can now be positioned relative to the Map or to the View.
  • MapView child views can now be aligned relative to their position point.
  • MapView no longer has a showMyLocation attribute; all methods referring to location are removed from MapActivity, MapView, and MapController. The new way to display location on the map is by creating a new MyLocationOverlay, enabling it, and adding it through the OverlayController.OverlayController.doZoom() is removed.
  • MapController.setFollowMyLocation() no longer accepts a zoom.
  • MapView.PixelCalculator was moved out into its own class PixelConverter, and its methods were renamed and changed to
  • use android.graphics.Point objects instead of int arrays.
  • Point renamed to GeoPoint

Media

  • Adds support for different types of ringtones -- ringtone, notification, and alarm. This brings some changes in related API:
    • RingtonePreference can specify which types of ringtones/sounds to show (ringtone, notification, sound) and whether to show an option to choose the default ringtone.
    • New RingtoneManager and Ringtone classes
    • Implement openFile in SettingsProvider for the RINGTONE and NOTIFICATION_SOUND settings. This will proxy (after ensuring proper permissions) to the drm/media providers' openFile() methods. This way, you can provide MediaPlayer the Uri of the default ringtone setting (Settings.System.DEFAULT_RINGTONE_URI for short), and it will get resolved to the current ringtone at the time of play.
    • All methods for getting Ringtone objects have been moved to RingtoneManager.
    • RingtonePickerActivity no longer returns a 'picked default' extra. Now 'picked uri' will point to one of the Settings Uris (for example, Settings.System.DEFAULT_RINGTONE if the default ringtone was picked). This means your application doesn't have to deal with the special case of picking default.
  • MediaPlayer's getFrameAt() has been deprecated. There is a new API for retrieving thumbnails: MediaMetadataRetriever.captureFrame(); It uses some heuristics to try and find a good frame for thumbnail. In the future, we will introduce a version that gives the developer control over which frame is retrieved.
  • The MediaPlayer now uses a different kind of surface so setting the surfaceholder's type to SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS is essential if you want to use it to play any video content.
  • android.media.VolumeManager adds new methods muteStream() and soloStream().

Menus

  • Visible and enabled are now separate states for a menu item.  It is now possible to have an enabled but not visible item that can be used for menu-chorded shortcuts.  However, to truly disable an item, the client must hide and disable it.
  • Expanded menu will only show items that are not in the icon menu.
  • XML attribute "titleIcon" renamed to "icon"
  • Expanded menu does not show icon anymore.
  • Menu items are added via simpler methods, and have setters that can be chained via a builder-style. (For example, menu.add("test").setIcon(R.drawable.test).setEnabled(false))
  • Menus can be inflated via XML.  See ApiDemos.

Network

  • HTTPClient (org.apache.http.*) is upgraded to version 4, Alpha 4.
  • Several classes were moved into to android.net from android core libraries.
  • Adds support for Wi-Fi management, based on wpa_supplicant, and for network connectivity management.
  • The connectivity manager monitors the state of connectivity on both the Wi-Fi and mobile data networks, and when connectivity is lost on one network, will attempt to establish connectivity to the other, according to user preferences that determine the circumstances under which each network type is to be preferred. 
  • Applications can now use the NetworkConnectivityBroadcastReceiver to find out about changes in network connectivity. Its use is analogous to that of the the DataStateIntentReceiver (which has been renamed MobileDataStateBroadcastReceiver) for keeping track    of mobile data connectivity changes. The latter is still available for applications that care specifically about mobile data as opposed to Internet connectivity in general. Applications may also subscribe directly to connectivity-related broadcasts instead of using the NetworkConnectivityBroadcastReceiver.  There are also broadcasts sent pertaining to Wi-Fi-specific state changes. 
  • When a notification of a loss of connectivity is broadcast, an indication is included in the broadcast as to whether the connectivity manager is attempting to connect to the other network. If no failover is possible, then the loss of connectivity is total, and it is not possible to send or receive data. If failover is possible, another broadcast will be sent when the failover either succeeds or fails. Many applications may only be interested in paying attention to events that indicate total loss of connectivity or restoration of connectivity following total loss. Further information about the use of the ConnectivityManager and WifiManager APIs is found in the reference documentation.

OS

  • android.os.IUsbService renamed to IMountService,
  • Several new methods added to android.os.Parcel.

OpenGL

  • Minor changes in OpenGL helper classes for debugging and exception handling (android.opengl.GLDebug and android.opengl.Exception)

Preferences

  • Introduces a framework for simplifying the implementation of preferences.  The framework lives in android.preference.  See ApiDemos > App > Preference.
  • Preferences are described in XML with attribute such as: key, default value, persistence on/off, title, summary, various preference-specific attributes, etc. 
  • A PreferenceActivity (see javadoc) can inflate a preference XML and automatically show a list-based UI for the declared preferences.  The preference framework takes care of restoring/storing values from the UI to the SharedPreferences for the application. 
  • Extensible so custom preference types can be implemented. 
  • Most features can be seen via the ApiDemos.
  • A 'selectable' attribute (android:selectable) in the preference framework prevents disabled items from not being selected in the list. 

Resources

  • Android private resources were moved from the public API to an internal area. There is now a limited subset of framework resources that are available to applications -- the available resources are all declared in android.R. Applications can no longer refer to Android private resources, either from XML (@ and ?) or programmatically. To determine what resources are public and available to your application, see android.R. In the API Differences report, resources moved to the internal area are listed as "removed".
  • Because of the change above, you may notice that for stateful drawables such as the button drawable, the only resource available is the actual stateful drawable. Your application can no longer access individual state images such as btn_default_normal. 
  • The <array> tag is replaced by <string-array>.
  • Resource based classes like AssetManager are moved to a new android.content.res package.
  • android.R.color adds several new color state lists.

Services

  • The superclass of android.app.Service changed from android.app.ApplicationContext to android.content.ContextWrapper.
  • Several methods are changed in visibility (to public).

Telephony

  • DataStateIntentReceiver has been renamed MobileDataStateBroadcastReceiver.
  • ACTION_ANY_DATA_CONNECTION_STATE_CHANGED has been added to track state changes for any requested GPRS connection.
  • This means that ACTION_DATA_CONNECTION_STATE_CHANGED now only reflects changes to the "default" GPRS connection.
  • Adds getIncomingNumber() to PhoneStateIntentReceiver to get the caller id from an incoming call for apps out side of phone process.
  • Adds APIs like getLocation() and notifyCellLocation() so that apps that are interested in service state are notified whenever the cell id changes.
  • PhoneNumberUtils class provides emergency number identification API.
  • A new PhoneNumberFormattingTextWatcher has been added to format phone numbers as you type them. It currently only supports NANP numbers and is keyed off of the country code in Locale.getDefault(). This class replaces the TelephoneNumberUtil for formatting phone numbers.
  • Adds APIs for Asynchronous Callerinfo queries.
  • Several GSM subscriber and device-related system properties are moved to new permission-checked API:
    PROPERTY_IMEI
    PROPERTY_IMEISV
    PROPERTY_IMSI
    PROPERTY_ICCID
    PROPERTY_LINE1_NUMBER
    PROPERTY_LINE1_TAG
    PROPERTY_LINE1_VOICE_MAIL_NUMBER
    PROPERTY_LINE1_VOICE_MAIL_TAG
    
    You can now access these phone/subscriber properties through the new PhoneSubInfoManager, using the IPhoneSubInfo interface. Note that, to get access phone/subscriber information through the IPhoneSubInfo interface, you must add the permission ACCESS_PHONE_SUB_INFO to your application's manifest file. For example:
    <uses-permission android:name="android.permission.ACCESS_PHONE_SUB_INFO" />
  • Several methods removed from android.telephony.gsm.SmsMessage

Threads

  • Message now uses a Bundle rather than a HashMap for its complex data payload
  • UiThreadUtilities has been removed
  • View.runOnUiThread() has been removed
  • View.isUiRhread() has been removed
  • Applications should use only Activity.runOnUiThread() from now on

Unit Testing and Instrumentation

  • The permission RUN_INSTRUMENTATION (android.permission.RUN_INSTRUMENTATION) is removed. This means that both an application containing instrumentation and the associated instrumentation .apk must now be signed by the same certificate.
  • An instrumentation test case can be annotated with @FlakyTest to force a specified number of reruns. For instance, @FlakyTest(tolerance = 2) will run the test one more time if the first run fails. The tolerance indicates the total number of runs allowed
  • An instrumentation test case can be annotated with @OnUiThread to be run on the UI thread instead of the JUnit thread
  • ActivityTestCase now makes key events sending easier as you can now use sendKeys(String), sendKeys(int...) and sendRepeatedKeys(int...) to send key events. This allows you to easily send several events in a more readable way. For instance: sendKeys("4*DPAD_RIGHT H E L L O DPAD_CENTER") or sendKeys(KEYCODE_DPAD_LEFT, KEYCODE_DPAD_CENTER) or sendRepeatedKeys(2, KEYCODE_DPAD_RIGHT, 1, DPAD_CENTER).

Views

  • Removed class VolumePanel
  • View.getViewTreeObserver() lets you register global listeners about the view hierarchy (for instance, when a layout happens, when touch mode changes...)
  • Removed View.getAbsoluteLocationOnScreen(), use View.getLocationOnScreen() instead
  • Removed View.getWindowFrame()
  • View.getDefaultSize() and View.resolveSize() are now static
  • Removed View.setPreferredWidth()/setPreferredHeight()
  • View.getHorizontalScrollbarHeight() and View.getVerticalScrollbarWidth() are now protected
  • Renamed View.isSaveDisabled() to View.isSaveEnabled()
  • Renamed View.setSaveDisabled() to View.setSaveEnabled()
  • Renamed View.setBackground(int) to View.setBackgroundResource(int)
  • Renamed View.setBackrgound(Drawable) to View.setBackgroundDrawable(Drawable)
  • Renamed android:saveDisabled to android:saveEnabled
  • Added minWidth and minHeight attributes for views.  An example use is for list items where you want to ensure the item is the preferred list item height, but still allow it to grow beyond that size if necessary (so, the item's height would be wrap_content and the minHeight="?android:attr/listPreferredItemHeight")
  • View can now use android:duplicateParentState="true" to get its drawable state from its parent
  • View.onDrawBackground() and View.hasBackground() are now gone. To draw your own background without using a Drawable, just set the background to null and override onDraw()
  • Allow only a subset of views to be inflated by the RemoteView mechanism. These views are marked with the new @RemoteView annotation
  • Combined focusType and blocksFocusInDescendants into one enum on ViewGroup (descendantFocusability)
  • Renamed the Resources.StyledAttributes class to a top-level TypedArray class
  • Added LONG_CLICKABLE flag for views (setLongClickable/isLongClickable)
  • The Map inflateParams parameter has been removed from the View constructors (and from all of the subclasses)
  • Removes many now-unsupported features of android.view.Gallery, such as different scale per offset, alpha, allow loop, selector.
  • Adds android.view.View.OnTouchListener, an interface definition for a callback to be invoked when a touch event is dispatched to this view. Several related methods are added.

Window

  • Window's progress bars can now be controlled separately. To use both progress bar, use requestWindowFeature(Window.FEATURE_PROGRESS | Window.FEATURE_INDETERMINATE_PROGRESS). Make sure your application uses the correct flag
  • Removed the window portrait/landscape orientation flags, replacing all uses with the newer activity orientation flags
  • IWindowManager: special "app token" management moved out of WindowToken and into a new AppWindowToken class.

Widgets

  • Added XML support for in and out animations in ViewAnimator
  • FrameLayout now supports margins and gravity
  • Clients of list view or grid view can now be notified when the view is in the process of scrolling or flinging. They can use this information to defer expensive operations
  • Added a choiceMode attribute to ListViews that allows the list to support either a single selection or multiple selections. By default, the selected item or items are displayed with check mark on the  right edge of the view. Added a CheckedTextView to display this, along with a Checkable interface that can be used to provide other views that can display a checked state
  • Added support for recycling multiple types of views in Lists and Grids. To use this, provide overrides for getItemViewType(int position) and getViewTypeCount() in your adapter. If your adapter creates 3 kinds of views, getViewTypeCount should return 3 and getItemViewType should return 0, 1, or 2 depending on the type of view that will be created for the specified position.  You can also return IGNORE_ITEM_VIEW_TYPE to force the recycler to ignore recycling the returned view.
  • Applications can now receive notifications when a view is moved to the scrap heap of the recycler in AbsListView
  • ScrollView now supports fillViewport property. This property lets you take all of the available space if the content is smaller than the screen
  • Renamed PopupWindow.setBackground(Drawable) to PopupWindow.setBackgroundDrawable(Drawable)
  • Renamed AdapterView's obtainItem and obtainItemId to getItemAtPosition and getItemIdAtPosition
  • Transformed spinners into popups
  • Removed ScaleLayout
  • EditText can show error messages
  • Added fixed-sized option to ImageView
  • Added a new scale type in ImageView which will shrink (but not grow) an image to make it fit within the specified bounds
  • ListView is now focusable in touch mode by default
  • Added a transcript mode to list/grid views. When in this mode, the list/grid will always scroll to the bottom when new items are added
  • Added a TextView feature to ellipsize text that is too big to fit
  • Added RatingBar, a touchable/draggable set of stars that can be used for rating
  • Added AutoCompleteList, an AutoCompleteTextView that adds the user entry into a list after confirmation (by typing enter for instance)
  • Added MultiAutoCompleteTextView, a subclass of AutoCompleteTextView that can show completion suggestions for the substring of the text where the user is typing instead of necessarily for the entire thing
  • Typing in a ListView filters the content of the ListView
  • Added SeekBar (progress bar with a thumb the user can move)
  • Added ToggleButton, a button that shows an on/off indicator
  • Added starStyle that should be applied to a CheckBox that will make the CheckBox appear as a star.

XML Layouts

  • Several new layout drawable attributes.
  • XML layouts can now be included in other XML layouts
    • Include element:  <include layout="@layout/..." />. If layout parameters (android:layout_* attributes) are specified on the <include /> tag, they override the layout parameters of the included layout. Similarly, specifying an android:id on the <include /> tag will override the id of the included layout's root. You can now use android:layout_margin to specify left, top, right and bottom margins at the same time (with the same value). The android:visibility attribute can also be overridden by the include tag
    • Merge element <merge /> tag for XML layout files. This lets you inflate the content of an existing view without an extra level in the view hierarchy.
      <merge xmlns:android="http://schemas.android.com/apk/res/android">
              <TextView
      		android:text="@string/include_label"
                	android:layout_width="wrap_content"
      		android:layout_height="wrap_content" />
      	<TextView
      		android:text="@string/include_label"
      		android:layout_width="wrap_content"
      		android:layout_height="wrap_content" />
      </merge>

      In this example, the <merge/> tag will be ignored by the parser and the two TextView will be added to the parent passed to the LayoutInflater. When you inflate a layout file with a <merge /> you must pass a root and attachToRoot must be true: (it is by default, as in the example below):

      mLayout = new LinearLayout(this);
      LayoutInflater.from(this).inflate(R.layout.merge_tag, mLayout, null);
       

      This works really well in conjunction with <include />. For instance, including the example above will include the two TextViews directly.

    • ViewStub element: ViewStub can perform lazy layout inflation at runtime. For instance:
      <ViewStub android:id="@+id/stub"
              android:inflatedId="@+id/subTree"
              android:layout="@layout/mySubTree"
      	android:layout_width="120dip
      	android:layout_height="40dip" />

      Calling findViewById(R.id.stub).setVisibility(View.VISIBLE) or ((ViewStub) findViewById(R.id.stub)).inflate() will cause the inflation of the layout called "mySubTree." The resulting view then replaces the ViewStub in the view hierarchy. The layout attributes of the ViewStub override those of the stubbed XML layout. The android:inflateId attribute overrides the android:id of the stubbed XML layout's root View.

Miscellaneous

  • An application’s individual components can be either public or private.  If private, only the application itself can access that component.  This state will automatically be set for you based on whether you have specified any intent-filters for the component (if you have, it will be made public, on the assumption that the reason for doing so is to allow others to launch it).  You can override that default with a new android:exported tag on the component.
  • Add android.separate_processes property you can use to force application components to run in their own process.  There are two ways you can use this:    
    1. setprop debug.separate_processes - This will apply to every process in every package.
    2. setprop debug.separate_processes "com.google.process.content,com.google.android.samples" - This will impact only the code whose manifest involves one of the given processes (here com.google.process.content com.google.android.samples) -- either as the manifest package name, or listed as an explicit android:process tag. Note that using this option will either split a process into parts (corresponding to the packages inside of it)or combine multiple processes into one (if they come from the same package).  That is, it forces all impacted components to run in the process for their own .apk, regardless of what android:process attributes specify.
  • The AlertDialog was changed/extended to allow the custom view to be used in addition to the list view.
  • Added support for application aliases., where you can create a .apk that contains no code, only an activity definition for a system-supplied "AliasActivity," which looks at meta-data in your manifest to determine which actual Intent to start.
  • Notifications can have default pattern for sound, vibrate, and/or lights. Notifications also have a flag to automatically cancel the notification when selected.
  • A new WallpaperService which will be responsible for setting and getting the wallpaper. The wallpaper will be stored in settings.
  • Two new methods let you check the desired height and width of wallpaper
  • The package android.accounts adds helper classes and interfaces that let your app receive notifications of changes in the active Google account(s)

Browser/WebView

  • The browser itself no longer downloads content that it can not render. When content is discovered that it can't render, the DownloadListener.onDownloadStart() method is called with the details of the content. It is up to the client application of WebView to handle this situation.
  • When a WebView requests a new window to be created via WebChromeClient.shouldCreateWindow() a flag is now passed to indicate if the window should be treated as a dialog (ie, the window has no chrome of it's own)
  • WebViews now support plugins. The location of the plugin is set via WebView.setPluginsPath(). Plugins are native (C/C++) code that implement the NPAPI interface.

Google Maps

  • New Maps menu alphabetic shortcuts This adds four invisible menu items:
    • menu+I - zoom in
      menu+O - zoom out
      menu+J - previous result
      menu+K - next result
  • Add a new style attribute to enable/disable MapView's My Location feature. By default it's disable meaning no extra location based permissions are required for developers wanting to write a Maps based app.
  • Move Overlay.PixelCalculator -> MapView.PixelCalculator and added a MapView.getPixelCalculator.
  • A new GestureDetector to help detect common gestures.
  • The OverlayController, MyLocationOverlay and MapController classes are changed to final
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值