2

How can I get the build number of my Android app and setText to a textview?

For example, "Build # 91".

3
  • 1
    Which build system are you using? What do you mean by build number? (version code?) Commented Feb 10, 2014 at 11:03
  • No i don't need the version number, i need the number of build of the app. The textview should change according to the build of the app. Commented Feb 10, 2014 at 11:10
  • I need to get the build. For example "Build # 91". Please anyone help for this. Commented Feb 11, 2014 at 4:20

1 Answer 1

7

Simple and short way: implement into your activity

String versionName = getApplicationContext().getPackageManager()
.getPackageInfo(getApplicationContext().getPackageName(), 0).versionName;
TextView tv=(TextView)findViewById(R.id.tv); 
tv.setText(versionName);
Sign up to request clarification or add additional context in comments.

6 Comments

But it is used to get the version number right? I need the Build number.
@user3098684 what u want?
So, you really mean versionCode! Just replace versionName with versionCode in the proposed answer. TheHippo already pointed this out, correctly (first comment to your question).
No..We have build for each app right? When we make any changes in that each time it create a different build.
I need to get the build. For example "Build # 91". Please anyone help for this.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.