Having a problem pulling the versionCode from the manifest..

Put your problem here if it does not fit any of the other categories.

Having a problem pulling the versionCode from the manifest..

Postby GasBot » Thu Nov 06, 2008 5:54 pm

I'm using this code to pull the versionCode from the manifest, but it keeps coming back as 0. Looking at it in Debug mode and the entire object is nulls and 0s.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. PackageInfo myPI = new PackageInfo();
  3.  
  4. myPI.versionCode;
  5.  
  6.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


I'm actually concatenating that myPI.versionCode into a string. Anyone have any idea why it's doing that?
GasBot
Experienced Developer
Experienced Developer
 
Posts: 50
Joined: Fri Oct 17, 2008 7:19 am

Top

Postby MrSnowflake » Thu Nov 06, 2008 6:04 pm

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. getPackageManager().getPackageInfo("com.mypackage.android", int flags).versionCode;
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby GasBot » Thu Nov 06, 2008 6:06 pm

MrSnowflake wrote:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. getPackageManager().getPackageInfo("com.mypackage.android", int flags).versionCode;
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


Assigning that to my myPI variable just gives an error because it doesn't like the "int flags" part.
GasBot
Experienced Developer
Experienced Developer
 
Posts: 50
Joined: Fri Oct 17, 2008 7:19 am

Postby GasBot » Thu Nov 06, 2008 6:25 pm

Yeah, this won't even compile...

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. verCode = getPackageManager().getPackageInfo("[mypackagename]", 0).versionCode;
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


I even tried using the getPackageName() in place of the static string for my name space.

Here's the error I'm getting just after saving the file...

Unhandled exception type PackageManager.NameNotFoundException
GasBot
Experienced Developer
Experienced Developer
 
Posts: 50
Joined: Fri Oct 17, 2008 7:19 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 15 guests