当前位置: 首页>>代码示例>>Java>>正文


Java CallbackContext.sendPluginResult方法代码示例

本文整理汇总了Java中org.apache.cordova.CallbackContext.sendPluginResult方法的典型用法代码示例。如果您正苦于以下问题:Java CallbackContext.sendPluginResult方法的具体用法?Java CallbackContext.sendPluginResult怎么用?Java CallbackContext.sendPluginResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cordova.CallbackContext的用法示例。


在下文中一共展示了CallbackContext.sendPluginResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
/**
 * Executes the request and returns PluginResult.
 *
 * @param action            The action to execute.
 * @param args              JSONArry of arguments for the plugin.
 * @param callbackContext   The callback id used when calling back into JavaScript.
 * @return                  True if the action was valid, false otherwise.
 */
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) {
    if (action.equals("getConnectionInfo")) {
        this.connectionCallbackContext = callbackContext;
        NetworkInfo info = sockMan.getActiveNetworkInfo();
        String connectionType = "";
        try {
            connectionType = this.getConnectionInfo(info).get("type").toString();
        } catch (JSONException e) {
            LOG.d(LOG_TAG, e.getLocalizedMessage());
        }

        PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, connectionType);
        pluginResult.setKeepCallback(true);
        callbackContext.sendPluginResult(pluginResult);
        return true;
    }
    return false;
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:27,代码来源:NetworkManager.java

示例2: startActivity

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
private void startActivity(String action, Uri uri, String type, Map<String, String> extras, boolean bExpectResult, int requestCode, CallbackContext callbackContext) {
    //  Credit: https://github.com/chrisekelley/cordova-webintent
    Intent i = (uri != null ? new Intent(action, uri) : new Intent(action));

    if (type != null && uri != null) {
        i.setDataAndType(uri, type); //Fix the crash problem with android 2.3.6
    } else {
        if (type != null) {
            i.setType(type);
        }
        if (uri != null)
        {
            i.setData(uri);
        }
    }

    for (String key : extras.keySet()) {
        String value = extras.get(key);
        // If type is text html, the extra text must sent as HTML
        if (key.equals(Intent.EXTRA_TEXT) && type.equals("text/html")) {
            i.putExtra(key, Html.fromHtml(value));
        } else if (key.equals(Intent.EXTRA_STREAM)) {
            // allowes sharing of images as attachments.
            // value in this case should be a URI of a file
            final CordovaResourceApi resourceApi = webView.getResourceApi();
            i.putExtra(key, resourceApi.remapUri(Uri.parse(value)));
        } else if (key.equals(Intent.EXTRA_EMAIL)) {
            // allows to add the email address of the receiver
            i.putExtra(Intent.EXTRA_EMAIL, new String[] { value });
        } else {
            i.putExtra(key, value);
        }
    }

    i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    if (i.resolveActivityInfo(this.cordova.getActivity().getPackageManager(), 0) != null)
    {
    if (bExpectResult)
    {
        cordova.setActivityResultCallback(this);
        ((CordovaActivity) this.cordova.getActivity()).startActivityForResult(i, requestCode);
    }
    else
        {
        ((CordovaActivity)this.cordova.getActivity()).startActivity(i);
            callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
        }
    }
    else
    {
        //  Return an error as there is no app to handle this intent
        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR));
    }
}
 
开发者ID:darryncampbell,项目名称:darryncampbell-cordova-plugin-intent,代码行数:56,代码来源:IntentShim.java

示例3: addCallback

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
void addCallback(CallbackContext callbackContext) {
    this.callbackContexts.add(callbackContext);

    if (this.callbackContexts.size() > 10) {
        this.callbackContexts.removeFirst();
    }

    if (!isInit) {
        return;
    }

    if (this.error != null) {
        callbackContext.sendPluginResult(this.getErrorResult(error));
    } else {
        callbackContext.sendPluginResult(this.getPositionResult(this.latitude, this.longitude));
    }
}
 
开发者ID:luocongqiu,项目名称:cordova-plugin-navigation,代码行数:18,代码来源:LocationListener.java

示例4: installUpdate

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
/**
 * Install update if any available.
 *
 * @param jsCallback callback where to send the result;
 *                   used, when installation os requested manually from JavaScript
 */
private void installUpdate(CallbackContext jsCallback) {
    if (!isPluginReadyForWork) {
        return;
    }

    ChcpError error = UpdatesInstaller.install(cordova.getActivity(), pluginInternalPrefs.getReadyForInstallationReleaseVersionName(), pluginInternalPrefs.getCurrentReleaseVersionName());
    if (error != ChcpError.NONE) {
        if (jsCallback != null) {
            PluginResult errorResult = PluginResultHelper.createPluginResult(UpdateInstallationErrorEvent.EVENT_NAME, null, error);
            jsCallback.sendPluginResult(errorResult);
        }

        return;
    }

    if (jsCallback != null) {
        installJsCallback = jsCallback;
    }
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:26,代码来源:HotCodePushPlugin.java

示例5: init

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
public void init(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
    final String key = args.getString(0);

    final Activity activity = this.cordova.getActivity();
    Radar.initialize(activity, key);

    if (!Radar.checkSelfPermissions()) {
        Radar.requestPermissions(activity);
    }

    callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
}
 
开发者ID:Corollarium,项目名称:cordova-plugin-radar,代码行数:13,代码来源:RadarCordovaPlugin.java

示例6: sendToken

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
public static void sendToken(String token) {
    if (MessagingComponent.tokenRefreshCallbackContext == null) {
        return;
    }

    Log.i(TAG, "Sending token " + token);

    final CallbackContext callbackContext = MessagingComponent.tokenRefreshCallbackContext;
    if (callbackContext != null && token != null) {
        PluginResult pluginresult = new PluginResult(PluginResult.Status.OK, token);
        pluginresult.setKeepCallback(true);
        callbackContext.sendPluginResult(pluginresult);
    }
}
 
开发者ID:jsayol,项目名称:cordova-plugin-firebase-sdk,代码行数:15,代码来源:MessagingComponent.java

示例7: requestFileSystem

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
/**
 * Requests a filesystem in which to store application data.
 *
 * @param type of file system requested
 * @param requiredSize required free space in the file system in bytes
 * @param callbackContext context for returning the result or error
 * @throws JSONException
 */
private void requestFileSystem(int type, long requiredSize, final CallbackContext callbackContext) throws JSONException {
    Filesystem rootFs = null;
    try {
        rootFs = this.filesystems.get(type);
    } catch (ArrayIndexOutOfBoundsException e) {
        // Pass null through
    }
    if (rootFs == null) {
        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, FileUtils.NOT_FOUND_ERR));
    } else {
        // If a nonzero required size was specified, check that the retrieved filesystem has enough free space.
        long availableSize = 0;
        if (requiredSize > 0) {
            availableSize = rootFs.getFreeSpaceInBytes();
        }

        if (availableSize < requiredSize) {
            callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, FileUtils.QUOTA_EXCEEDED_ERR));
        } else {
            JSONObject fs = new JSONObject();
            fs.put("name", rootFs.name);
            fs.put("root", rootFs.getRootEntry());
            callbackContext.success(fs);
        }
    }
}
 
开发者ID:rodrigonsh,项目名称:alerta-fraude,代码行数:35,代码来源:FileUtils.java

示例8: muteCall

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
private void muteCall(final CallbackContext callbackContext) {
	if (mCall == null) {
		callbackContext.sendPluginResult(new PluginResult(
				PluginResult.Status.ERROR));
		return;
	}
	cordova.getThreadPool().execute(new Runnable(){
		public void run() {
			mCall.mute(true);
			callbackContext.success(); 
		}
	});
}
 
开发者ID:jefflinwood,项目名称:twilio-voice-phonegap-plugin,代码行数:14,代码来源:TwilioVoicePlugin.java

示例9: isCallMuted

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
private void isCallMuted(CallbackContext callbackContext) {
	if (mCall == null) {
		callbackContext.sendPluginResult(new PluginResult(
               PluginResult.Status.OK,false));
		return;
	}
	PluginResult result = new PluginResult(PluginResult.Status.OK,mCall.isMuted());
	callbackContext.sendPluginResult(result);
}
 
开发者ID:jefflinwood,项目名称:twilio-voice-phonegap-plugin,代码行数:10,代码来源:TwilioVoicePlugin.java

示例10: jsGetVersionInfo

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
/**
 * Get information about app and web versions.
 *
 * @param callback callback where to send the result
 */
private void jsGetVersionInfo(final CallbackContext callback) {
    final Context context = cordova.getActivity();
    final Map<String, Object> data = new HashMap<String, Object>();
    data.put("currentWebVersion", pluginInternalPrefs.getCurrentReleaseVersionName());
    data.put("readyToInstallWebVersion", pluginInternalPrefs.getReadyForInstallationReleaseVersionName());
    data.put("previousWebVersion", pluginInternalPrefs.getPreviousReleaseVersionName());
    data.put("appVersion", VersionHelper.applicationVersionName(context));
    data.put("buildVersion", VersionHelper.applicationVersionCode(context));

    final PluginResult pluginResult = PluginResultHelper.createPluginResult(null, data, null);
    callback.sendPluginResult(pluginResult);
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:18,代码来源:HotCodePushPlugin.java

示例11: fetchUpdate

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
/**
 * Perform update availability check.
 *
 * @param jsCallback callback where to send the result;
 *                   used, when update is requested manually from JavaScript
 */
private void fetchUpdate(CallbackContext jsCallback, FetchUpdateOptions fetchOptions) {
    if (!isPluginReadyForWork) {
        return;
    }

    Map<String, String> requestHeaders = null;
    String configURL = chcpXmlConfig.getConfigUrl();
    if (fetchOptions == null) {
        fetchOptions = defaultFetchUpdateOptions;
    }
    if (fetchOptions != null) {
        requestHeaders = fetchOptions.getRequestHeaders();
        final String optionalConfigURL = fetchOptions.getConfigURL();
        if (!TextUtils.isEmpty(optionalConfigURL)) {
            configURL = optionalConfigURL;
        }
    }

    final UpdateDownloadRequest request = UpdateDownloadRequest.builder(cordova.getActivity())
            .setConfigURL(configURL)
            .setCurrentNativeVersion(chcpXmlConfig.getNativeInterfaceVersion())
            .setCurrentReleaseVersion(pluginInternalPrefs.getCurrentReleaseVersionName())
            .setRequestHeaders(requestHeaders)
            .build();

    final ChcpError error = UpdatesLoader.downloadUpdate(request);
    if (error != ChcpError.NONE) {
        if (jsCallback != null) {
            PluginResult errorResult = PluginResultHelper.createPluginResult(UpdateDownloadErrorEvent.EVENT_NAME, null, error);
            jsCallback.sendPluginResult(errorResult);
        }
        return;
    }

    if (jsCallback != null) {
        downloadJsCallback = jsCallback;
    }
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:45,代码来源:HotCodePushPlugin.java

示例12: onCharacteristicChanged

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
@Override
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
    super.onCharacteristicChanged(gatt, characteristic);
    LOG.d(TAG, "onCharacteristicChanged " + characteristic);

    CallbackContext callback = notificationCallbacks.get(generateHashKey(characteristic));

    if (callback != null) {
        PluginResult result = new PluginResult(PluginResult.Status.OK, characteristic.getValue());
        result.setKeepCallback(true);
        callback.sendPluginResult(result);
    }
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:14,代码来源:Peripheral.java

示例13: execute

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
  this._callbackContext = callbackContext; // only used for onActivityResult
  this.pasteMessage = null;
  if (ACTION_AVAILABLE_EVENT.equals(action)) {
    callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
    return true;
  } else if (ACTION_SHARE_EVENT.equals(action)) {
    return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), null, null, false, true);
  } else if (ACTION_SHARE_WITH_OPTIONS_EVENT.equals(action)) {
    return shareWithOptions(callbackContext, args.getJSONObject(0));
  } else if (ACTION_SHARE_VIA_TWITTER_EVENT.equals(action)) {
    return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), "twitter", null, false, true);
  } else if (ACTION_SHARE_VIA_FACEBOOK_EVENT.equals(action)) {
    return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), "com.facebook.katana", null, false, true, "com.facebook.composer.shareintent");
  } else if (ACTION_SHARE_VIA_FACEBOOK_WITH_PASTEMESSAGEHINT.equals(action)) {
    this.pasteMessage = args.getString(4);
    return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), "com.facebook.katana", null, false, true, "com.facebook.composer.shareintent");
  } else if (ACTION_SHARE_VIA_WHATSAPP_EVENT.equals(action)) {
    if (notEmpty(args.getString(4))) {
      return shareViaWhatsAppDirectly(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), args.getString(4));
    } else {
      return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), "whatsapp", null, false, true);
    }
  } else if (ACTION_SHARE_VIA_INSTAGRAM_EVENT.equals(action)) {
    if (notEmpty(args.getString(0))) {
      copyHintToClipboard(args.getString(0), "Instagram paste message");
    }
    return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), "instagram", null, false, true);
  } else if (ACTION_CAN_SHARE_VIA.equals(action)) {
    return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), args.getString(4), null, true, true);
  } else if (ACTION_CAN_SHARE_VIA_EMAIL.equals(action)) {
    if (isEmailAvailable()) {
      callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
      return true;
    } else {
      callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, "not available"));
      return false;
    }
  } else if (ACTION_SHARE_VIA.equals(action)) {
    return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), args.getString(4), null, false, true);
  } else if (ACTION_SHARE_VIA_SMS_EVENT.equals(action)) {
    return invokeSMSIntent(callbackContext, args.getJSONObject(0), args.getString(1));
  } else if (ACTION_SHARE_VIA_EMAIL_EVENT.equals(action)) {
    return invokeEmailIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.isNull(3) ? null : args.getJSONArray(3), args.isNull(4) ? null : args.getJSONArray(4), args.isNull(5) ? null : args.getJSONArray(5));
  } else {
    callbackContext.error("socialSharing." + action + " is not a supported function. Did you mean '" + ACTION_SHARE_EVENT + "'?");
    return false;
  }
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:51,代码来源:SocialSharing.java

示例14: sendPluginResult

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
/**
 * Send badge number has the plugin result back to the JS caller.
 *
 * @param callback The callback to invoke.
 * @param badge    The badge number to pass with.
 */
private void sendPluginResult(CallbackContext callback, int badge) {
    PluginResult result = new PluginResult(OK, badge);
    callback.sendPluginResult(result);
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:11,代码来源:Badge.java

示例15: sendPluginNotReadyToWork

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
/**
 * Send to JS side event with message, that plugin is installing assets on the external storage and not yet ready for work.
 * That happens only on the first launch.
 *
 * @param eventName event name, that is send to JS side
 * @param callback  JS callback
 */
private void sendPluginNotReadyToWork(String eventName, CallbackContext callback) {
    PluginResult pluginResult = PluginResultHelper.createPluginResult(eventName, null, ChcpError.ASSETS_FOLDER_IN_NOT_YET_INSTALLED);
    callback.sendPluginResult(pluginResult);
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:12,代码来源:HotCodePushPlugin.java


注:本文中的org.apache.cordova.CallbackContext.sendPluginResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。