packageInstalled函数的第二个参数returnCode的源码解读
来源:互联网 发布:长江证券mac版本下载 编辑:程序博客网 时间:2024/05/29 17:37
http://www.eoeandroid.com/forum.php?mod=viewthread&tid=328636
这几天在弄安装的事情,发现很多安装包不能安装成功。IPackageInstallObserver会用回调函数packageInstalled(String packageName, int returnCode)告诉我们returnCode安装结果。
安卓源码中是这么定义这些returnCode的:public static final int INSTALL_SUCCEEDED = 1;
/**
* Installation return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package is
* already installed.
* @hide
*/
public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
/**
* Installation return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package archive
* file is invalid.
* @hide
*/
public static final int INSTALL_FAILED_INVALID_APK = -2;
/**
* Installation return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the URI passed in
* is invalid.
* @hide
*/
public static final int INSTALL_FAILED_INVALID_URI = -3;
/**
* Installation return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package manager
* service found that the device didn't have enough storage space to install the app.
* @hide
*/
public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
/**
* Installation return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if a
* package is already installed with the same name.
* @hide
*/
public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
/**
* Installation return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
* the requested shared user does not exist.
* @hide
*/
public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
/**
* Installation return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
* a previously installed package of the same name has a different signature
* than the new package (and the old package's data was not removed).
* @hide
*/
public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
/**
* Installation return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
* the new package is requested a shared user which is already installed on the
* device and does not have matching signature.
* @hide
*/
public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
/**
* Installation return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
* the new package uses a shared library that is not available.
* @hide
*/
public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
/**
* Installation return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
* the new package uses a shared library that is not available.
* @hide
*/
public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
/**
* Installation return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
* the new package failed while optimizing and validating its dex files,
* either because there was not enough storage or the validation failed.
* @hide
*/
public static final int INSTALL_FAILED_DEXOPT = -11;
/**
* Installation return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
* the new package failed because the current SDK version is older than
* that required by the package.
* @hide
*/
public static final int INSTALL_FAILED_OLDER_SDK = -12;
/**
* Installation return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
* the new package failed because it contains a content provider with the
* same authority as a provider already installed in the system.
* @hide
*/
public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
/**
* Installation return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
* the new package failed because the current SDK version is newer than
* that required by the package.
* @hide
*/
public static final int INSTALL_FAILED_NEWER_SDK = -14;
/**
* Installation return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
* the new package failed because it has specified that it is a test-only
* package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST}
* flag.
* @hide
*/
public static final int INSTALL_FAILED_TEST_ONLY = -15;
/**
* Installation return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
* the package being installed contains native code, but none that is
* compatible with the the device's CPU_ABI.
* @hide
*/
public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
/**
* Installation return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
* the new package uses a feature that is not available.
* @hide
*/
public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
// ------ Errors related to sdcard
/**
* Installation return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
* a secure container mount point couldn't be accessed on external media.
* @hide
*/
public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;
/**
* Installation return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
* the new package couldn't be installed in the specified install
* location.
* @hide
*/
public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;
/**
* Installation return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
* the new package couldn't be installed in the specified install
* location because the media is not available.
* @hide
*/
public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;
/**
* Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
* if the parser was given a path that is not a file, or does not end with the expected
* '.apk' extension.
* @hide
*/
public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
/**
* Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
* if the parser was unable to retrieve the AndroidManifest.xml file.
* @hide
*/
public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
/**
* Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
* if the parser encountered an unexpected exception.
* @hide
*/
public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
/**
* Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
* if the parser did not find any certificates in the .apk.
* @hide
*/
public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
/**
* Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
* if the parser found inconsistent certificates on the files in the .apk.
* @hide
*/
public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
/**
* Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
* if the parser encountered a CertificateEncodingException in one of the
* files in the .apk.
* @hide
*/
public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
/**
* Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
* if the parser encountered a bad or missing package name in the manifest.
* @hide
*/
public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
/**
* Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
* if the parser encountered a bad shared user id name in the manifest.
* @hide
*/
public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
/**
* Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
* if the parser encountered some structural problem in the manifest.
* @hide
*/
public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
/**
* Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
* if the parser did not find any actionable tags (instrumentation or application)
* in the manifest.
* @hide
*/
public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
/**
* Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
* if the system failed to install the package because of system issues.
* @hide
*/
public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;
下面一一来看一下每个对应的意义:
《1》
public static final int INSTALL_SUCCEEDED = 1;
这个自不用说,就是你安装成功了。
《-1》public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
大侠,我都已经安装了啊,你还装
《-2》public static final int INSTALL_FAILED_INVALID_APK = -2;
文件无效啊,请看看路径是否对,再看看权限是不是rw-rw-rw-啊
《-3》 public static final int INSTALL_FAILED_INVALID_URI = -3;
靠,这个文件路径根本无法解析嘛!请用英文命名你的apk包。
《-4》public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
装了你我就满了,拿什么装其他东西,fk
《-5》 public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
已经有和我名字一样的一共用了,请把那个冒牌货删除好吗?
《-6》public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
共享用户都不存在,你搞什么哦
《-7》public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
不能更新,请卸载原来的版本,并把data剩余的东西弄干净
《-8》public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
我们是共享用户啊,为什么给我的签名不一样
《-9》 public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
老子的LIBRARY呢,去哪里了?
《-10》public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
LIBRARY有是有,但是用不了额。。。
《-11》public static final int INSTALL_FAILED_DEXOPT = -11;
空间不足或者验证失败了
《-12》public static final int INSTALL_FAILED_OLDER_SDK = -12;
安装包要求的安卓版本太高了啊,4.5的平台滚粗,还是1.6好
《-13》public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
Provider已经被别人定义了啊,你换个名字吧亲
《-14》public static final int INSTALL_FAILED_NEWER_SDK = -14;
哥,你还真把1.6的应用往4.4的手机上装啊。
《-15》public static final int INSTALL_FAILED_TEST_ONLY = -15;
只供测试,你哪来的包?
《-16》 public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
哥,你调底层的东西,手机cpu办不到啊。。。
《-17》public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
你要的效果我没有,请把对应部分注释掉
《-18》 public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;
你说装哪就装哪?还是给系统一个选择吧,用auto最好了
《-19》 public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;
路径不对
《-20》public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;
你把我当U盘用,还要同时在我上面装东西,你还有良心吗
《-100》 public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
这个好像是zip,不是apk
《-101》public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
MANIFEST啊,多少次死在你手里
《-102》public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
解析失败了,也许你是把txt文件改成.apk文件了,但是本质是不会变的
《-103》public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
你会签名吗。。。
《-104》 public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
签名是会签了,但是要一致哦
《-105》public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
签名解码失败
《-106》 public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
有包名吗,正确吗
《-107》public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
共享用户有吗,名字对吗
《-108》 public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
在检查检查MANIFEST吧
《-109》public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
我靠,你这个应用啥也么木有啊。
《-110》public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;
0 0
- packageInstalled函数的第二个参数returnCode的源码解读
- 解读replace的第二个参数为函数
- 关于main函数的第二个参数
- (一)ghostscript源码分析之interp()函数的第二个参数
- ExpandEnvironmentStrings函数的第二个参数的使用要注意
- 对accept函数第二个参数的理解
- JS的replace 使用 第二个参数为函数
- replace第二个参数为函数的情况
- replace 第二个参数为函数的情况
- setTimeout的第二个参数
- Angular源码解读的setupModuleLoader函数
- 讨论:GetMessage()的第二个参数使用
- CList第二个参数的意思(原创)
- 关于 jquery 的第二个参数 undefined
- addEventListener第二个参数的handleEvent
- GTK+中GtkFileChooser的第二个参数
- [php] json_encode 的第二个参数详解
- 关于 jquery 的第二个参数 undefined
- 二、Live555 基础类
- JFreeChart各种图表练习(已修改bug)
- [PHP+xdebug] 在Ubuntu 14.04下的PhpStorm中配置xdebug调试环境
- isnan function in matlab
- 单源最短路径问题——Dijkstra算法
- packageInstalled函数的第二个参数returnCode的源码解读
- KeyValueTextInputFormat 分割key value 设置问题:key.value.separator.in.input.line
- 从及时通讯软件跨平台使用思考《适配器模式》
- 通用电商项目关于登陆注册自动的实现
- Java中父类与子类之间的转化
- Python-Bubble Sort
- iOS缓存机制(二)
- IO流第四课,原理、分类、标准步骤
- RequiredJs学习笔记