List of usage examples for org.apache.cordova PluginResult PluginResult
public PluginResult(Status status)
From source file:BarcodeReaderPlugin.java
private void SendNoResult(CallbackContext callbackContext, boolean keepCallback) { // Return "no result" result - neither success nor failure callbacks will be called PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT); pluginResult.setKeepCallback(keepCallback); callbackContext.sendPluginResult(pluginResult); }
From source file:ai.api.ApiAiPlugin.java
License:Apache License
@Override public void onListeningStarted() { if (listeningStartCallback != null) { final PluginResult pluginResult = new PluginResult(PluginResult.Status.OK); pluginResult.setKeepCallback(true); listeningStartCallback.sendPluginResult(pluginResult); }//from www .ja v a2 s . c o m }
From source file:ai.api.ApiAiPlugin.java
License:Apache License
@Override public void onListeningFinished() { if (listeningFinishCallback != null) { final PluginResult pluginResult = new PluginResult(PluginResult.Status.OK); pluginResult.setKeepCallback(true); listeningFinishCallback.sendPluginResult(pluginResult); }/*from w ww . j av a2 s . co m*/ }
From source file:ai.api.ApiAiPlugin.java
License:Apache License
@Override public void onListeningCanceled() { if (listeningCanceledCallback != null) { final PluginResult pluginResult = new PluginResult(PluginResult.Status.OK); pluginResult.setKeepCallback(true); listeningCanceledCallback.sendPluginResult(pluginResult); }/*from www. ja v a 2 s . c o m*/ }
From source file:at.modalog.cordova.plugin.cache.Cache.java
License:MIT License
@Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { /*try//w ww . j ava 2 s .com { */ if (action.equals("clear")) { Log.v(LOG_TAG, "Cordova Android Cache.clear() called."); this.callbackContext = callbackContext; final Cache self = this; cordova.getActivity().runOnUiThread(new Runnable() { public void run() { try { // clear the cache self.webView.clearCache(true); // send success result to cordova PluginResult result = new PluginResult(PluginResult.Status.OK); result.setKeepCallback(false); self.callbackContext.sendPluginResult(result); } catch (Exception e) { String msg = "Error while clearing webview cache."; Log.e(LOG_TAG, msg); // return error answer to cordova PluginResult result = new PluginResult(PluginResult.Status.ERROR, msg); result.setKeepCallback(false); self.callbackContext.sendPluginResult(result); } } }); return true; } return false; /* } catch (JSONException e) { // TODO: signal JSON problem to JS //callbackContext.error("Problem with JSON"); return false; } */ }
From source file:ch.liquidconcept.cordova.appversion.AppVersion.java
License:Open Source License
@Override public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException { PluginResult result = new PluginResult(PluginResult.Status.INVALID_ACTION); PackageManager packageManager = cordova.getActivity().getPackageManager(); if (action.equals("name")) { try {/* w w w. ja v a 2s. co m*/ PackageInfo packageInfo = packageManager .getPackageInfo(cordova.getActivity().getApplicationContext().getPackageName(), 0); result = new PluginResult(PluginResult.Status.OK, packageInfo.versionName); } catch (PackageManager.NameNotFoundException exception) { result = new PluginResult(PluginResult.Status.ERROR, exception.getMessage()); } } callbackContext.sendPluginResult(result); return true; }
From source file:co.mwater.foregroundcameraplugin.ForegroundCameraLauncher.java
License:Apache License
/** * Executes the request and returns PluginResult. * //from w ww .j a v a2 s . c o m * @param action * The action to execute. * @param args * JSONArry of arguments for the plugin. * @param callbackId * The callback id used when calling back into JavaScript. * @return A PluginResult object with a status and message. */ @Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { PluginResult.Status status = PluginResult.Status.OK; String result = ""; this.callbackContext = callbackContext; try { if (action.equals("takePicture")) { this.mQuality = args.getInt(0); this.destinationType = args.getInt(1); this.targetWidth = args.getInt(3); this.targetHeight = args.getInt(4); this.takePicture(); PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT); r.setKeepCallback(true); callbackContext.sendPluginResult(r); return true; } return false; } catch (JSONException e) { e.printStackTrace(); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); return true; } }
From source file:com.adobe.phonegap.csdk.AssetBrowser.java
License:Apache License
/** * Executes the request and returns PluginResult. * * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @param callbackContext The callback context from which we were invoked. *///from w w w . ja va 2 s .c o m @SuppressLint("NewApi") public boolean execute(String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException { this.callbackContext = callbackContext; Log.d(LOG_TAG, "+++++++++++"); if (action.equals("downloadFiles")) { // setup data source types JSONArray dataSourceTypes = args.getJSONArray(0); int typeLength = dataSourceTypes.length(); int[] sources = new int[typeLength]; for (int i = 0; i < typeLength; i++) { sources[i] = dataSourceTypes.getInt(i); } Log.d(LOG_TAG, ">>>>>>>>>>>>>>>>>>"); // setup output file name downloadLocation = args.getString(1); Intent i = new Intent(cordova.getActivity(), AssetBrowserActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); i.putExtra("dataSources", sources); cordova.startActivityForResult(this, i, 0); PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT); r.setKeepCallback(true); callbackContext.sendPluginResult(r); } else if (action.equals("uploadFile")) { String url = args.getString(0); URL assetUrl = !url.startsWith("content") ? createURL(url) : createURL(FileHelper.getRealPath(cordova.getActivity(), Uri.parse(url))); String filename = assetUrl.getFile(); String mimeType = FileHelper.getMimeType(url, cordova); String uploadName = args.getString(1); if (uploadName == null || "".equals(uploadName)) { uploadName = filename; } boolean overwrite = args.getBoolean(2); Log.d(LOG_TAG, "url: " + url); Log.d(LOG_TAG, "filename: " + filename); Log.d(LOG_TAG, "mimeType: " + mimeType); Log.d(LOG_TAG, "uploadName: " + uploadName); AdobeAssetFile.create(uploadName, AdobeAssetFolder.getRoot(), assetUrl, mimeType, uploadCallback, null); } else { return false; } return true; }
From source file:com.adobe.phonegap.csdk.ImageEditor.java
License:Apache License
/** * Executes the request and returns PluginResult. * * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @param callbackContext The callback context from which we were invoked. *///from w w w .j a va 2 s .com @SuppressLint("NewApi") public boolean execute(String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException { this.callbackContext = callbackContext; if (action.equals("edit")) { String imageStr = args.getString(0); if (imageStr == null || "".equals(imageStr)) { this.callbackContext.error("Image Path must be specified"); } Uri imageUri = Uri.parse(imageStr); AdobeImageIntent.Builder builder = new AdobeImageIntent.Builder( this.cordova.getActivity().getApplicationContext()).setData(imageUri); // setup options setOutputType(builder, args.getInt(1)); setToolsArray(builder, args.getJSONArray(2)); builder.withOutputQuality(args.getInt(3)); builder.withNoExitConfirmation(args.getBoolean(4)); builder.withOutputSize(MegaPixels.valueOf("Mp" + args.getString(5))); builder.saveWithNoChanges(args.getBoolean(6)); builder.withVibrationEnabled(args.getBoolean(7)); int color = args.getInt(8); if (color != 0) { builder.withAccentColor(color); } int previewSize = args.getInt(9); if (previewSize > 0) { builder.withPreviewSize(previewSize); } String outputFile = args.getString(10); if (!"".equals(outputFile)) { File fp = new File(outputFile); builder.withOutput(fp); } Intent imageEditorIntent = builder.build(); this.cordova.startActivityForResult((CordovaPlugin) this, imageEditorIntent, 1); PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT); r.setKeepCallback(true); callbackContext.sendPluginResult(r); } else { return false; } return true; }
From source file:com.appfeel.cordova.analytics.adid.CPGoogleAnalyticsAdId.java
License:Open Source License
private PluginResult executeStartAdIdTracker(String id, CallbackContext callbackContext) { PluginResult result = null;//from w w w . ja v a2 s . c om if (null != id && id.length() > 0) { CPGoogleAnalytics.tracker = GoogleAnalytics.getInstance(this.cordova.getActivity()).newTracker(id); GoogleAnalytics.getInstance(this.cordova.getActivity()).setLocalDispatchPeriod(30); GoogleAnalytics.getInstance(this.cordova.getActivity()).getLogger().setLogLevel(LogLevel.ERROR); CPGoogleAnalytics.tracker.enableAdvertisingIdCollection(true); result = new PluginResult(Status.OK); } else { result = new PluginResult(Status.ERROR, "Invalid tracker"); } return result; }