问题描述
我一直在努力与获得的VERSIONNAME从PackageInfo对象类型运行的应用程序。
I have been struggling with getting the versionName for a running application from the PackageInfo Object type.
我已经建立了一个Parcelable接口与所有的PackageInfo对象类型相关的字段。该接口方法的主要投入是一个包裹对象。
I have constructed a Parcelable Interface with all of the fields associated with the PackageInfo Object type. The primary input for that interface method is a Parcel object.
我似乎无法弄清楚如何正确关联这些Parcelable,包裹和PackageInfo对象。
I cannot seem to figure out how to correctly associate these Parcelable, Parcel, and PackageInfo objects.
有什么样code,在那里,我可以看看?似乎并不像它应该是困难的,但它似乎是绊倒了我。
Is there any sample code out there that I can look at? Doesn't seem like it should be that difficult but it seems to be stumping me.
谢谢爵士
推荐答案
样品code:
try {
PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
return packageInfo.versionName;
} catch (NameNotFoundException e) {
//Handle exception
}
这篇关于试图让软件包版本信息显示在[关于"信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!