Sometimes a developer will make a change to an application that has surprising results when installed as an update to a previous version — shortcuts break, widgets disappear, or it can’t even be installed at all.There are certain parts of an application that are immutable once you publish it, and you can avoid surprises by understanding them.

Your package name and certificate

The most obvious and visible of these is the “manifest package name,” the unique name you give to your application in its AndroidManifest.xml. The name uses a Java-language-style naming convention, with Internet domain ownership helping to avoid name collisions. For example, since Google owns the domain “google.com”, the manifest package names of all of our applications should start with “com.google.” It’s important for developers to follow this convention in order to avoid conflicts with other developers.

Once you publish your application under its manifest package name, this is the unique identity of the application forever more. Switching to a different name results in an entirely new application, one that can’t be installed as an update to the existing application.

Just as important as the manifest package name is the certificate that application is signed with.The signing certificate represents the author of the application.If you change the certificate an application is signed with, it is now a different application because it comes from a different author. This different application can’t be uploaded to Market as an update to the original application, nor can it be installed onto a device as an update.

The exact behavior the user sees when installing an application that has changed in one of these two ways is different:

  • If the manifest package name has changed, the new application will be installed alongside the old application, so they both co-exist on the user’s device at the same time.

  • If the signing certificate changes, trying to install the new application on to the device will fail until the old version is uninstalled.

If you change the signing certificate of your application, you should always change its manifest package name as well to avoid failures when it’s installed. In other words, the application coming from a different author makes it a different application, and its package name should be changed appropriately to reflect that.(Of course it’s fine to use the same package name for the development builds of your app signed with your test keys, because these are not published.)

Your AndroidManifest.xml is a public API

More than just your package name that is immutable. A major function of the AndroidManifest.xml is essentially to declare a public API from your application for use by other applications and the Android system.Every component you declare in the manifest that is not private (that is whose android:exported state is true) should be treated as a public API and never changed in a way that breaks compatibility.

A subtle but important aspect of what constitutes a break in compatibility is the android:name attribute of your activity, service, and receiver components. This can be surprising because we think of android:name as pointing to the private code implementing our application, but it is also (in combination with the manifest package name) the official unique public name for that component, as represented by the ComponentName class.

Changing the component name inside of an application can have negative consequences for your users. Some examples are:

  • If the name of a main activity of your application is changed, any shortcuts the user made to it will no longer work. A shortcut is an Intent that directly specifies the ComponentName it should run.

  • If the name of a service implementing a Live Wallpaper changes, then a user who has enabled your Live Wallpaper will have their wallpaper revert to the system default when getting the new version of your app. The same is true for Input Methods, Accessibility Services, Honeycomb’s new advanced Widgets, and so on.

  • If the name of a receiver implementing a Device Admin changes, then as with the live wallpaper example, the device admin will be disabled when the application is updated. This also applies to other kinds of receivers, such as App Widgets.

These behaviors are an outcome of how the Intent system is used on Android. There are two main kinds of Intents:

  • Implicit Intents only specify “what” they should match, using actions, categories, data, MIME types, and so on. The exact components that they will find are only determined at run-time, by the Package Manager matching it against the current applications.

  • Explicit Intents specify a single explicit “who” they should match, through a ComponentName. Regardless of whatever else is in the Intent, it is only associated with the exact manifest package name and class name as given in its ComponentName.

Both of these types of Intents are important to how Android interacts with your application. A typical example of this is how users browse and select live wallpapers.

To let the user pick a live wallpaper, the first thing Android must do is show them a list of the available live wallpaper services. It does this by building an implicit Intent with the appropriate action for a live wallpaper and asking the Package Manager for all services that support this Intent. The result is then the list of live wallpapers shown to the user.

When the user actually selects a specific live wallpaper they want to use, however, Android now must build an explicit Intent that identifies that particular live wallpaper. This is what is handed to the WallpaperManager to tell it which wallpaper to show.

This is why changing the name of the component in your manifest will cause the wallpaper to disappear: the explicit Intent that was previously saved is now invalid because the ComponentName it references no longer exists. There is no information available to indicate what the new name of the component is. (For example consider if your application had two different live wallpaper services the user could select.) Instead, Android must treat that live wallpaper as uninstalled and revert to its default wallpaper.

This is how input methods, device administrators, account managers, app widgets, and even application shortcuts work. The ComponentName is the public unique name of the components you declare in your manifest, and must not change if they are visible to other applications.

In conclusion: There are some parts of your application that can not change. Please be careful.

https://android-developers.googleblog.com/2011/06/things-that-cannot-change.html

Things That Cannot Change相关推荐

  1. mysql中change用法,mysql 中alter的用法以及一些步骤

    mysql 中alter的用法以及一些方法 在用到alter的时间,查到了这个文章,就copy下来了,详细进入下面链接: MySQL之alter语句用法总结 1:删除列 ALTER TABLE [表名 ...

  2. Linux下stat + 文件名后, Access,Modify,Change的含义

    我们首先在一个目录下创建了一个文件使用命令touch file 然后输入命令:stat file,这个时候会输出一系列信息 大家注意红色框中的三个时间 Access : 文件最近一次被访问的时间 Mo ...

  3. java changelistener_ListChangeListener.Change

    表示对Observablelist进行的更改的报告. 更改可能包含一个或多个实际更改,并且必须由next()方法迭代. 每个更改必须是以下之一: 在这种情况下, 排列变化 : wasPermutate ...

  4. jQuery绑定事件的三种常见方式(bind、one、【change、click、keydown、hover】)

    一.bind(type,[data],fn):为每个匹配元素的特定事件绑定对应的事件处理函数. 也可以同时给一个元素绑定多个事件,我们来看一下例子: <!DOCTYPE html> < ...

  5. Oracle CDC (Change Data Capture)更新数据捕获——概述

    Change Data Capture能高效识别并捕获数据的插入.修改和删除,使更新数据供个人或应用使用. CDC从oracle 9i开始引入,//TODO 在11G R2之后的版本里将取消支持,被O ...

  6. ORACLE HANDBOOK系列之十四:变化通知(Change Notification)

    在App开发的过程中,有些数据访问频率很高但是数据变化不大,我们一般会让它驻留内存以提高访问性能,但是此种机制存在一个问题,那就是如何监测数据的变化,Oracle 10g中引入的 Change Not ...

  7. 差异基因分析:fold change(差异倍数), P-value(差异的显著性)

    做基因表达分析时必然会要做差异分析(DE) DE的方法主要有两种: Fold change t-test fold change的意思是样本质检表达量的差异倍数,log2 fold change的意思 ...

  8. Error in setwd(***) : cannot change working directory

    Error in setwd(***) :   cannot change working directory 目录 Error in setwd(***) :   cannot change wor ...

  9. seaborn可视化散点图并自定义数据轴标签(X轴和Y轴的轴标签,Change X Y Axis Labels to a Seaborn Plot)

    seaborn可视化散点图并自定义数据轴标签(X轴和Y轴的轴标签,Change X & Y Axis Labels to a Seaborn Plot) 目录

  10. seaborn可视化散点图并自定义可视化结果图像的大小(Change the Size of a Seaborn Plot)

    seaborn可视化散点图并自定义可视化结果图像的大小(Change the Size of a Seaborn Plot) 目录 seaborn可视化散点图并自定义可视化结果图像的大小(Change ...

最新文章

  1. php 指定表格字体大小_PHPExcel根据单元格值设置字体/背景颜色
  2. setuid与capability
  3. cocos2dx之lua项目开发中MVC框架的简单应用
  4. [转载] python 一个简单的天气预报程序
  5. linux系统新磁盘可视化挂载方法
  6. 计算机基础制作幻灯片讲解,计算机应用基础_幻灯片制作.ppt
  7. 表格列宽怎么设置?(excel表格)
  8. 推荐9个能让你看一天的网站
  9. Intel 处理器发展年历
  10. 关联规则Apriori(python实现):Bakery Bussiness Model
  11. gitlab上创建新的分支并发布代码
  12. Lingo 语言程序设计基础
  13. Nginx 日志和监控 - HTTP 健康监测
  14. java基础知识点、面试选择题归纳整理
  15. LVS专题-(3) 虚拟ip理解
  16. 百数智慧社区细分领域合作案例展示
  17. uni-app - ios禁止页面滑动(无法上下滚动屏幕页面)
  18. android4以下的音乐播放器,Android平台四大音乐播放器对比评测
  19. dpo指标详解买入绝技_极少人知道的“DPO MADPO”组合指标,完胜MACD,实战性很强!...
  20. AWS亚马逊云账号注册、免费申请1年云服务器以及Amazon EC2服务与Amazon Lightsail服务的配置与使用

热门文章

  1. 想要快速搭建开发测试环境?这么做就可以!
  2. 184使用 Core Image 框架处理照片
  3. 清橙 A1120 拦截导弹 -- 动态规划(最长上升子序列)
  4. 控件不响应点击事件解决办法
  5. SQL Server 2008 R2 中不能删除复制(replication) 的解决方法
  6. bzoj2754: [SCOI2012]喵星球上的点名
  7. 程序员也要寻找贸易的机会,要参加研讨会
  8. gbk utf-8 string java
  9. openstack cluster 封装
  10. Python爬虫! 单爬,批量爬,这都不是事!