Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6753295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:08:39+00:00 2026-05-26T13:08:39+00:00

In my android application I need to get the version of the application programatically.

  • 0

In my android application I need to get the version of the application programatically. But whenever I try with this code it crashes at this line. Is there anything that I am missing

PackageInfo pinfo = getPackageManager().getPackageInfo(
                    this.getPackageName(), 0);

I tried getting it from PackageManager and PackageInfo. In both the cases the application crashes and launches ViewRoot.handleMessage and I get a message “Source Not found”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:08:39+00:00Added an answer on May 26, 2026 at 1:08 pm

    Please try below function.

    public int getVersion(Context context) 
    {
            try 
            {
                PackageInfo pInfo = context.getPackageManager().getPackageInfo("here.thenameofyour.package", PackageManager.GET_META_DATA);
                return pInfo.versionCode;
            } 
            catch (NameNotFoundException e) 
            {
                return 0;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an android application in which I need to get the HTML code
Whenever I press F11 to debug my Android application I get 'Debug as' window
I have application using Android 2.1 which utilize LocationManager to get the altitude. But
In one of my Android Application I need to keep the title bar same
I need to add a shake feature that will refresh my Android application. All
My open-source Android application uses this in an SQL query: String.format(%f, someDoubleValue); Unfortunately, in
I'm relatively new to java and android, in my android application I need to
In my android application i need to insert an array into an array and
From within my Android application, I need to make the phone 'checkin' with Google
As part of the Android application I am developing in eclipse, I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.