package uk.co.whiteoctober.cordova;

import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.PluginResult;
import org.json.JSONArray;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.PackageManager;

public class AppVersion extends CordovaPlugin {

	@Override
	public PluginResult execute(String arg0, JSONArray arg1, String arg2) {

		try {
			PackageManager packageManager = this.cordova.getActivity().getPackageManager();
			return new PluginResult(PluginResult.Status.OK, packageManager.getPackageInfo(this.cordova.getActivity().getPackageName(), 0).versionName);
		} catch (NameNotFoundException e) {
			return new PluginResult(PluginResult.Status.ERROR, "");
		}
	}

}

@@ -97,27 +97,30 @@
 cordova.
-PluginResul
+CallbackContex
 t;%0Aimpor
@@ -296,17 +296,16 @@
 lugin %7B%0A
-%0A
 %09@Overri
@@ -311,28 +311,30 @@
 ide%0A
-%09public PluginResult
+        public boolean
  exe
@@ -350,11 +350,13 @@
 ng a
-rg0
+ction
 , JS
@@ -370,35 +370,122 @@
  arg
-1, String arg2) %7B%0A%0A%09%09try
+s, CallbackContext callbackContext) throws JSONException %7B%0A%0A%09%09try %7B%09%0A%09%09%09if (action.equals(%22getVersionNumber%22))
  %7B%0A
+%09
 %09%09%09P
@@ -566,39 +566,40 @@
 r();%0A%09%09%09
-return new PluginResult
+%09callbackContext.success
 (PluginR
@@ -707,16 +707,54 @@
 nName);%0A
+%09%09%09return true;%0A%09%09%09%7D%0A%09%09%09return false;%0A
 %09%09%7D catc
@@ -790,62 +790,56 @@
 %0A%09%09%09
-return new PluginResult(PluginResult.Status.ERROR, %22%22)
+callbackContext.success('Error');%0A%09%09%09return true
 ;%0A%09%09

Update AppVersion.java