diff --git a/src/android/IntentShim.java b/src/android/IntentShim.java index 9b31d32..967109a 100644 --- a/src/android/IntentShim.java +++ b/src/android/IntentShim.java @@ -32,9 +32,6 @@ import static android.R.attr.filter; -/** - * @todo - */ public class IntentShim extends CordovaPlugin { private static final String LOG_TAG = "Cordova Intents Shim"; @@ -81,9 +78,6 @@ public boolean execute(String action, JSONArray args, final CallbackContext call { bExpectResult = true; this.onActivityResultCallbackContext = callbackContext; - PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT); - result.setKeepCallback(true); - callbackContext.sendPluginResult(result); } else { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK)); @@ -92,10 +86,6 @@ public boolean execute(String action, JSONArray args, final CallbackContext call return true; } - else if (action.equals("startService")) - { - // todo - } else if (action.equals("sendBroadcast")) { // Credit: https://github.com/chrisekelley/cordova-webintent @@ -122,6 +112,13 @@ else if (action.equals("sendBroadcast")) callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK)); return true; } else if (action.equals("registerBroadcastReceiver")) { + try + { + // Ensure we only have a single registered broadcast receiver + ((CordovaActivity)this.cordova.getActivity()).unregisterReceiver(myBroadcastReceiver); + } + catch (IllegalArgumentException e) {} + // No error callback if(args.length() != 1) { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION)); @@ -171,7 +168,6 @@ else if (action.equals("onIntent")) result.setKeepCallback(true); callbackContext.sendPluginResult(result); return true; - // todo } else if (action.equals("onActivityResult")) { @@ -256,8 +252,7 @@ public void onNewIntent(Intent intent) { public void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); - // todo - if (onActivityResultCallbackContext != null) + if (onActivityResultCallbackContext != null && intent != null) { intent.putExtra("requestCode", requestCode); intent.putExtra("resultCode", resultCode); @@ -265,6 +260,10 @@ public void onActivityResult(int requestCode, int resultCode, Intent intent) result.setKeepCallback(true); onActivityResultCallbackContext.sendPluginResult(result); } + else if (onActivityResultCallbackContext != null) + { + onActivityResultCallbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION)); + } } diff --git a/www/IntentShim.js b/www/IntentShim.js index cef7986..d2f9974 100644 --- a/www/IntentShim.js +++ b/www/IntentShim.js @@ -1,7 +1,3 @@ -//cordova.define("com.darryncampbell.cordova.plugin.intent.IntentShim", function(require, exports, module) { -//exports.coolMethod = function(arg0, success, error) { -// exec(success, error, "EnterpriseBarcode", "coolMethod", [arg0]); -//}; var argscheck = require('cordova/argscheck'), channel = require('cordova/channel'), @@ -31,7 +27,6 @@ function IntentShim() { // StartActivityForResult IntentShim.prototype.ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT"; IntentShim.prototype.ACTION_PICK = "android.intent.action.PICK"; - IntentShim.prototype.PICK_CONTACT = "content://com.android.contacts/contacts"; /** * @param {Function} successCallback The function to call when the heading data is available @@ -47,11 +42,6 @@ IntentShim.prototype.startActivityForResult = function(params, successCallback, exec(successCallback, errorCallback, "IntentShim", "startActivityForResult", [params]); }; -IntentShim.prototype.startService = function(params, successCallback, errorCallback) { - argscheck.checkArgs('off', 'IntentShim.startService', arguments); - exec(successCallback, errorCallback, "IntentShim", "startService", [params]); -}; - IntentShim.prototype.sendBroadcast = function(params, successCallback, errorCallback) { argscheck.checkArgs('off', 'IntentShim.sendBroadcast', arguments); exec(successCallback, errorCallback, "IntentShim", "sendBroadcast", [params]); @@ -91,5 +81,3 @@ window.plugins = window.plugins || {}; window.plugins.intentShim = window.intentShim; - -//});