I'm trying to implement an About box. The PackageInfo class is great
for this, but I see it needs a package name as an argument to
instantiate it:

PackageManager pm = getPackageManager();
String version = getString(R.string.about_unknown);
try {
        PackageInfo pi =  pm.getPackageInfo(getString
(R.string.about_package), 0);

        version = getString(R.string.about_version) +
                " " +
                Integer.toString(pi.versionCode)+"/"+pi.versionName;
} catch (NameNotFoundException e) {
        e.printStackTrace();
}

I added the package name as an entry in strings.xml to get this
working. However, I'd like to know if I can remove this duplication as
I see the package name is already present in AndroidManifest.xml.

Thanks.

--
Android Academy: http://www.androidacademy.com


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to