Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to get Package Version Information to display in an "About" message

Tags:

I have been struggling with getting the versionName for a running application from the PackageInfo Object type.

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.

I cannot seem to figure out how to correctly associate these Parcelable, Parcel, and PackageInfo objects.

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.

Thanks Jazz

like image 703
user313135 Avatar asked Apr 09 '10 19:04

user313135


1 Answers

Sample code:

try {     PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);     return packageInfo.versionName; } catch (NameNotFoundException e) {     //Handle exception } 
like image 197
Casebash Avatar answered Oct 04 '22 15:10

Casebash