Saturday, December 17, 2011

AndroidManifest.xml is a public API

The main function of AndroidManifest.xml is essentially to declare a public API of your application for use by other applications and the Android system. Each component, you personally do not represent manifest (ie, with Android: the country exported correctly) to be treated as a public API and never changed in a way that breaks compatibility.
A subtle but important for what constitutes a break in compatibility is android: name attribute of your business, and service components of the receiver. This may be surprising because we think the name refers to the implementation of Android as our application code private, but also (in conjunction with the name of the package manifest) the official name for this unique component of the community, as represented by class ComponentName.
Change the name of the components in an application can have negative consequences for your users. Some examples are:

    *

      If the name of the main activities of your application change, all the shortcuts that are created for the user no longer works. Shortcut is the intention that determines directly ComponentName should work.
    *

      If the service name to apply changes to Live Wallpaper and users who have wallpaper Wallpaper Live will have their back to the default system when acquiring new version of your application. The same applies to methods of entry, service accessibility, new honeycomb Advanced Widgets, and so on.
    *

      If the recipient's name changed to implement Admin Tool, then as wallpaper live by example, admin features will be disabled when the application is updated. This also applies to other types of receptors, such as the Widget App.
Behavior is the result of the way the system is for use on Android. There are two basic types of intentions:

    *

      Implicit intention is only to determine "what" they should fit, using actions, categories, data, MIME types, and so on. They will find the exact composition is determined at runtime, the package manager in accordance with current applications.
    *

      Specify a single explicit intention explicit "that" they should fit, through a ComponentName. In spite of all it is the intention, it is only associated with the exact name of the manifest package and class name as given in ComponentName.
Both types of intention is crucial to how applications interact with your Android. A typical example of this is the way users browse and select the funds directly.
To allow users to choose the line of wallpaper, the first thing to do is show them a list of services available Android live wallpaper. This is done by building implicit intentions with actions appropriate to the wallpaper of life and asked the manager to package all the services that support this intention. The result is then a list of animated wallpapers presented to the user.
When the user selects a special wallpaper gives the life they want to use, however, now have to build an Android explicit intent that identifies a particular living wallpaper. It was given to WallpaperManager to tell him what wallpaper to show.
This is why changing the name of the component in realizing you will cause the wallpaper to disappear: the explicit intent previously recorded are now invalid, because it refers ComponentName no longer exists. There is no information to indicate that the new component name. (As an example, consider whether your application has two different services living wallpaper user can choose.) Conversely, Android should treat this life as the wallpaper is removed and returned to the default wallpaper.
Thus, input methods, devices director, account manager, application widgets, and even the application shortcuts to work. ComponentName is the unique name of a public component which you stated in your manifesto, and not have to change if they are seen by other applications.
Conclusion: There is a certain part of your application can not be changed. Please be careful.

No comments:

Post a Comment