Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Works with phonegap 2.2? #5

Open
dblanco16 opened this issue Mar 1, 2014 · 2 comments
Open

Works with phonegap 2.2? #5

dblanco16 opened this issue Mar 1, 2014 · 2 comments

Comments

@dblanco16
Copy link

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:

  • plugins.xml
  • deviceinformation.java
    package com.mobilesoftware.cordova.plugins;

How should initialize the variable deviceInfo ? thanks

@vliesaputra
Copy link
Owner

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;
        }

@dblanco16
Copy link
Author

Dont work that change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants