RSS

Code to retrieve Version name present in AndroidManifest.xml dynamically

15 Aug

private void retrieveAppVersion()
{
CharSequence name = “com.nikhil.android”;
try {
PackageInfo pkgInfo = getPackageManager().getPackageInfo(name.toString(), 0);
textViewAppVersion.setText(String.format(
getString(R.string.app_version),
pkgInfo.versionName
));
}
catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}

Note : Just call this fuction in pageload.
All is well.

Advertisements
 
Leave a comment

Posted by on August 15, 2011 in Android Source Code

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: