I need to figure out how to get or make a build number for my Android application. I need the build number to display in the UI.
Do I have to do something with AndroidManifest.xml
?
I need to figure out how to get or make a build number for my Android application. I need the build number to display in the UI.
Do I have to do something with AndroidManifest.xml
?
I have SOLVE this by using Preference class.
If you're using PhoneGap, then create a custom PhoneGap plugin:
Create a new class in your app's package:
In the plugins.xml, add the following line:
In your deviceready event, add the following code:
Then, you can get the versionName attribute by doing:
Derived from here and here.
Here is the simple way to get version name and version code
Here is a clean solution, based on the solution of scottyab (edited by Xavi). It shows how to get the context first, if it's not provided by your method. Furthermore it uses multiple lines instead of calling multiple methods per line. This makes it easier when you have to debug your application.
Now that you received the version name in the String
myVersionName
, you can set it to a TextView or whatever you like..Example for inside Fragment usage.