拿到包的版本被替换Android中 [英] Get the version of the package been replaced in Android

查看:68
本文介绍了拿到包的版本被替换Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个广播接收器注册时得到通知发送PACKAGE_REPLACED意图。
在onReceiver我需要的软件包的版本的基础上执行某些操作被取代。
是否有一种方式来获得这些信息?我想:

I have a Broadcast receiver registered to be notified when PACKAGE_REPLACED intent is sent. In the onReceiver I need to perform some operations on the basis of the version of the package been replaced. Is there a way to get that information? I tried:

Uri data = intent.getData();
final String intentPackageName = data.getEncodedSchemeSpecificPart();
pi = context.getPackageManager().getPackageInfo(intentPackageName , PackageManager.GET_META_DATA);
versionCode = pi.versionCode;
versionName = pi.versionName;
packageName = pi.packageName;

因为版本已经更换,我所得到的是新的,而不是旧的它不工作。

It does not work because the version is already replaced and what I get is the new and not the old one.

推荐答案

在姜饼版本的源刚才检查。我想这是不可能的检查。应用程序的previous版本没有被存储。我不知道为什么。您可以创建一个功能请求,谷歌添加此功能。

Just checked in the sources of Gingerbread version. I guess that this is impossible to check. Previous version of the application is not stored. I do not know why. You can create a feature request to Google to add this feature.

这篇关于拿到包的版本被替换Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆