Some way to detect version of Android app from JavaScript?

2,320 views
Skip to first unread message

pamela fox

unread,
Dec 13, 2011, 5:18:01 PM12/13/11
to phonegap
Hey there-

To help me in debugging problems that users encounter in my PhoneGap
Android app, I currently log device information using the phonegap
API. I would also like to log what version they are using (per what's
in AndroidManifest.xml). Is this something that can be exposed to my
JavaScript from PhoneGap?
Otherwise I'll do some sort of make script that writes the version
number programmatically to the XML and the JS. Thanks!

- pamela

Dan Shookowsky

unread,
Dec 13, 2011, 10:57:15 PM12/13/11
to phonegap
Please look at the PhoneGap documentation for the Device object. It
should provide all the information you need.

http://docs.phonegap.com/en/1.2.0/phonegap_device_device.md.html#Device

Dan Shookowsky

unread,
Dec 13, 2011, 11:05:51 PM12/13/11
to phonegap
Oops...just read your email again and see that you're looking for
software version information rather than hardware information. You
could build a plugin to return the application version.

take a look at http://www.practicaldeveloper.net/2011/09/creating-plugin-with-phonegap-10.html

then create a plugin class that returns version from:

import android.content.pm.PackageManager.NameNotFoundException;
try {
//recall in the manifest version number is simply a sequential
integer identifying versions. Version name is a string like "1.0" or
"2.1", etc that is more
//commonly associated with a version identifier.
String version =
getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
} catch (NameNotFoundException e) {
Log.e("tag", e.getMessage());
}

On Dec 13, 5:18 pm, pamela fox <pamela...@everyday.io> wrote:

Reply all
Reply to author
Forward
Message has been deleted
0 new messages