Could you explain more what you are doing?  If you are doing an about box
for yourself, you either already know your package name or you can use
Context.getPackageName() to find the one you are using.

I guess you could open your AndroidManifest.xml using the AssetManager and
parse it, but there really should be no call for this.

On Sun, Mar 22, 2009 at 6:41 AM, Carl Whalley
<carl.whal...@googlemail.com>wrote:

>
> 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
>
>
> >
>


-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them.

--~--~---------~--~----~------------~-------~--~----~
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