versionName is not a method, it's a property. Remove the braces (i.e.:
"pi.versionName");

On Sun, Jan 31, 2010 at 12:14 PM, bpell <[email protected]> wrote:

> A few thoughts, and them my code that's producing the above error (and
> I'm perplexed as to why).
>
> 1.)  I'm using API 6
> 2.)  I have "import android.content.pm.PackageInfo;" and "import
> android.content.pm.PackageManager;" at the top of the java class.
> 3.)  I've hit "control-shift-o" in eclipse to try to get it to import
> anything that might be missing.
> 4.)  Eclipse shows the methods avaiable on PackageInfo (and it lists
> versionName as one of them) but then gives the error message "The
> method versionName() is undefined for the type PackageInfo".
>
> My question, what am I doing wrong (I've tried other variations of the
> getPackageManager line where I specified META_DATA, etc.)
>
> // Begin Code
> String version = " (Development)";
>
> try {
>  PackageInfo pi = getPackageManager().getPackageInfo
> ("com.testdoman.testapplication", 0);
>  version = pi.versionName();     // this is the line Eclipse complains
> about
> }
> catch (PackageManager.NameNotFoundException e) {
>        // eat error, for testing
> }
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Beginners" group.
>
> NEW! Try asking and tagging your question on Stack Overflow at
> http://stackoverflow.com/questions/tagged/android
>
> To unsubscribe from this group, send email to
> [email protected]<android-beginners%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-beginners?hl=en
>



-- 

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to