Open dblanco16 opened 10 years ago
I don't think your changes in java would compile properly as the code requires all of those libraries to work properly.
I haven't tried this but according to phonegap2.2 API, you should only need to update the execute method in deviceinformation.java to something like this:
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) {
if (action.equals("get")) {
TelephonyManager tm = (TelephonyManager) this.cordova.getActivity().getSystemService(Context.TELEPHONY_SERVICE);
AccountManager am = AccountManager.get(this.cordova.getActivity());
String result = getDetails(tm,am);
if (result != null) {
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
return true;
}
}
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR));
return false;
}
Dont work that change
Try to implement this plugin on a project with phonegap 2 .. 2.
In java change:
org.apache.cordova.api.CallbackContext import; org.apache.cordova.api.CordovaPlugin import; org.apache.cordova.api.PluginResult import;
Compiles ok.
In HTML use:
var deviceInfo = cordova.require("cordova/plugin/DeviceInformation"); alert('start'); deviceInfo.get(function(result) { alert("result = " + result); }, function() { alert("error"); }); alert ('final');
But dont alert "start".
More info:
How should initialize the variable deviceInfo ? thanks