當前位置: 首頁>>代碼示例>>Java>>正文


Java PluginResult類代碼示例

本文整理匯總了Java中org.apache.cordova.PluginResult的典型用法代碼示例。如果您正苦於以下問題:Java PluginResult類的具體用法?Java PluginResult怎麽用?Java PluginResult使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PluginResult類屬於org.apache.cordova包,在下文中一共展示了PluginResult類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onRequestPermissionResult

import org.apache.cordova.PluginResult; //導入依賴的package包/類
public void onRequestPermissionResult(int requestCode, String[] permissions,
                                      int[] grantResults) throws JSONException {
    for (int r : grantResults) {
        if (r == PackageManager.PERMISSION_DENIED) {
            this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, PERMISSION_DENIED_ERROR));
            return;
        }
    }
    switch (requestCode) {
        case TAKE_PIC_SEC:
            takePicture(this.destType, this.encodingType);
            break;
        case SAVE_TO_ALBUM_SEC:
            this.getImage(this.srcType, this.destType, this.encodingType);
            break;
    }
}
 
開發者ID:Andy-Ta,項目名稱:COB,代碼行數:18,代碼來源:CameraLauncher.java

示例2: onEvent

import org.apache.cordova.PluginResult; //導入依賴的package包/類
/**
 * Listener for event that some error happened during the update installation.
 *
 * @param event event information
 * @see UpdateInstallationErrorEvent
 * @see EventBus
 * @see UpdatesInstaller
 */
@SuppressWarnings("unused")
@Subscribe
public void onEvent(UpdateInstallationErrorEvent event) {
    Log.d("CHCP", "Failed to install");

    PluginResult jsResult = PluginResultHelper.pluginResultFromEvent(event);

    // notify js
    if (installJsCallback != null) {
        installJsCallback.sendPluginResult(jsResult);
        installJsCallback = null;
    }

    sendMessageToDefaultCallback(jsResult);

    rollbackIfCorrupted(event.error());
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:26,代碼來源:HotCodePushPlugin.java

示例3: onRequestPermissionResult

import org.apache.cordova.PluginResult; //導入依賴的package包/類
public void onRequestPermissionResult(int requestCode, String[] permissions,
                                      int[] grantResults) throws JSONException
{
    for(int r:grantResults)
    {
        if(r == PackageManager.PERMISSION_DENIED)
        {
            mCallbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, PERMISSION_DENIED_ERROR));
            return;
        }
    }
    switch(requestCode)
    {
        case SAVE_SCREENSHOT_SEC:
            saveScreenshot();
            break;
        case SAVE_SCREENSHOT_URI_SEC:
            getScreenshotAsURI();
            break;
    }
}
 
開發者ID:disit,項目名稱:siiMobilityAppKit,代碼行數:22,代碼來源:Screenshot.java

示例4: onEvent

import org.apache.cordova.PluginResult; //導入依賴的package包/類
/**
 * Listener for event that there is no update available at the moment.
 * We are as fresh as possible.
 *
 * @param event event information
 * @see EventBus
 * @see NothingToUpdateEvent
 * @see UpdatesLoader
 */
@SuppressWarnings("unused")
@Subscribe
public void onEvent(NothingToUpdateEvent event) {
    Log.d("CHCP", "Nothing to update");

    PluginResult jsResult = PluginResultHelper.pluginResultFromEvent(event);

    //notify JS
    if (downloadJsCallback != null) {
        downloadJsCallback.sendPluginResult(jsResult);
        downloadJsCallback = null;
    }

    sendMessageToDefaultCallback(jsResult);
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:25,代碼來源:HotCodePushPlugin.java

示例5: stopLocation

import org.apache.cordova.PluginResult; //導入依賴的package包/類
/**
 * Full stop using brute force. Works with many Android versions.
 */
public void stopLocation(){

    if(_phoneStateListener != null && _telephonyManager != null){
        _telephonyManager.listen(_phoneStateListener, PhoneStateListener.LISTEN_NONE);
        _telephonyManager.listen(_signalStrengthListener, PhoneStateListener.LISTEN_NONE);
        _phoneStateListener = null;
        _signalStrengthListener = null;
        _telephonyManager = null;

        try {
            Thread.currentThread().interrupt();
        }
        catch(SecurityException exc){
            Log.e(TAG, exc.getMessage());
            sendCallback(PluginResult.Status.ERROR,
                    JSONHelper.errorJSON(CELLINFO_PROVIDER, ErrorMessages.FAILED_THREAD_INTERRUPT()));
        }

        Log.d(TAG, "Stopping cell location listeners");
    }
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:25,代碼來源:CellLocationController.java

示例6: initialize

import org.apache.cordova.PluginResult; //導入依賴的package包/類
@Override
public void initialize(final CordovaInterface cordova, final CordovaWebView webView) {
    super.initialize(cordova, webView);

    parseCordovaConfigXml();
    loadPluginInternalPreferences();

    Log.d("CHCP", "Currently running release version " + pluginInternalPrefs.getCurrentReleaseVersionName());

    // clean up file system
    cleanupFileSystemFromOldReleases();

    handler = new Handler();
    fileStructure = new PluginFilesStructure(cordova.getActivity(), pluginInternalPrefs.getCurrentReleaseVersionName());
    appConfigStorage = new ApplicationConfigStorage();
    defaultCallbackStoredResults = new ArrayList<PluginResult>();
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:18,代碼來源:HotCodePushPlugin.java

示例7: alertDialog

import org.apache.cordova.PluginResult; //導入依賴的package包/類
/**
 * For working with pre-Android M security permissions
 * @param gpsEnabled If the cacheManifest and system allow gps
 * @param networkLocationEnabled If the cacheManifest and system allow network location access
 * @param cellularEnabled If the cacheManifest and system allow cellular data access
 */
private void alertDialog(boolean gpsEnabled, boolean networkLocationEnabled, boolean cellularEnabled){

    if(!gpsEnabled || !networkLocationEnabled){
        sendCallback(PluginResult.Status.ERROR,
                JSONHelper.errorJSON(PROVIDER_PRIMARY, ErrorMessages.LOCATION_SERVICES_UNAVAILABLE()));

        final DialogFragment gpsFragment = new GPSAlertDialogFragment();
        gpsFragment.show(_cordovaActivity.getFragmentManager(), "GPSAlert");
    }

    if(!cellularEnabled){
        sendCallback(PluginResult.Status.ERROR,
                JSONHelper.errorJSON(PROVIDER_PRIMARY, ErrorMessages.CELL_DATA_NOT_AVAILABLE()));

        final DialogFragment networkUnavailableFragment = new NetworkUnavailableDialogFragment();
        networkUnavailableFragment.show(_cordovaActivity.getFragmentManager(), "NetworkUnavailableAlert");
    }
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:25,代碼來源:AdvancedGeolocation.java

示例8: javascriptCallback

import org.apache.cordova.PluginResult; //導入依賴的package包/類
private void javascriptCallback(String event, JSONObject arguments,
		CallbackContext callbackContext) {
	if (callbackContext == null) {
		return;
	}
	JSONObject options = new JSONObject();
	try {
		options.putOpt("callback", event);
		options.putOpt("arguments", arguments);
	} catch (JSONException e) {
		callbackContext.sendPluginResult(new PluginResult(
				PluginResult.Status.JSON_EXCEPTION));
		return;
	}
	PluginResult result = new PluginResult(Status.OK, options);
	result.setKeepCallback(true);
	callbackContext.sendPluginResult(result);

}
 
開發者ID:jefflinwood,項目名稱:twilio-voice-phonegap-plugin,代碼行數:20,代碼來源:TwilioVoicePlugin.java

示例9: execute

import org.apache.cordova.PluginResult; //導入依賴的package包/類
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    LOG.d(TAG, "We are entering execute");
    context = callbackContext;
    if(action.equals("getPermission"))
    {
        if(hasPermisssion())
        {
            PluginResult r = new PluginResult(PluginResult.Status.OK);
            context.sendPluginResult(r);
            return true;
        }
        else {
            PermissionHelper.requestPermissions(this, 0, permissions);
        }
        return true;
    }
    return false;
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:19,代碼來源:Geolocation.java

示例10: execute

import org.apache.cordova.PluginResult; //導入依賴的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

示例11: save

import org.apache.cordova.PluginResult; //導入依賴的package包/類
private void save(JSONArray args) throws JSONException {
    final JSONObject contact = args.getJSONObject(0);
    this.cordova.getThreadPool().execute(new Runnable(){
        public void run() {
            JSONObject res = null;
            String id = contactAccessor.save(contact);
            if (id != null) {
                try {
                    res = contactAccessor.getContactById(id);
                } catch (JSONException e) {
                    LOG.e(LOG_TAG, "JSON fail.", e);
                }
            }
            if (res != null) {
                callbackContext.success(res);
            } else {
                callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, UNKNOWN_ERROR));
            }
        }
    });
}
 
開發者ID:rodrigonsh,項目名稱:alerta-fraude,代碼行數:22,代碼來源:ContactManager.java

示例12: onRequestPermissionResult

import org.apache.cordova.PluginResult; //導入依賴的package包/類
public void onRequestPermissionResult(int requestCode, String[] permissions,
                                      int[] grantResults) /* throws JSONException */ {
    for(int result:grantResults) {
        if(result == PackageManager.PERMISSION_DENIED)
        {
            LOG.d(TAG, "User *rejected* Coarse Location Access");
            this.permissionCallback.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, PERMISSION_DENIED_ERROR));
            return;
        }
    }

    switch(requestCode) {
        case REQUEST_ACCESS_COARSE_LOCATION:
            LOG.d(TAG, "User granted Coarse Location Access");
            findLowEnergyDevices(permissionCallback, serviceUUIDs, scanSeconds);
            this.permissionCallback = null;
            this.serviceUUIDs = null;
            this.scanSeconds = -1;
            break;
    }
}
 
開發者ID:disit,項目名稱:siiMobilityAppKit,代碼行數:22,代碼來源:BLECentralPlugin.java

示例13: onCharacteristicChanged

import org.apache.cordova.PluginResult; //導入依賴的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

示例14: onActivityResult

import org.apache.cordova.PluginResult; //導入依賴的package包/類
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
  super.onActivityResult(requestCode, resultCode, intent);
  if (_callbackContext != null) {
    switch (requestCode) {
      case ACTIVITY_CODE_SEND__BOOLRESULT:
        _callbackContext.sendPluginResult(new PluginResult(
            PluginResult.Status.OK,
            resultCode == Activity.RESULT_OK));
        break;
      case ACTIVITY_CODE_SEND__OBJECT:
        JSONObject json = new JSONObject();
        try {
          json.put("completed", resultCode == Activity.RESULT_OK);
          json.put("app", ""); // we need a completely different approach if we want to support this on Android. Idea: https://clickclickclack.wordpress.com/2012/01/03/intercepting-androids-action_send-intents/
          _callbackContext.sendPluginResult(new PluginResult(
              PluginResult.Status.OK,
              json));
        } catch (JSONException e) {
          _callbackContext.error(e.getMessage());
        }
        break;
      default:
        _callbackContext.success();
    }
  }
}
 
開發者ID:disit,項目名稱:siiMobilityAppKit,代碼行數:28,代碼來源:SocialSharing.java

示例15: sendCallback

import org.apache.cordova.PluginResult; //導入依賴的package包/類
private static void sendCallback(PluginResult.Status status, String message){
    if(!Thread.currentThread().isInterrupted()){
        final PluginResult result = new PluginResult(status, message);
        result.setKeepCallback(true);
        _callbackContext.sendPluginResult(result);
    }
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:8,代碼來源:NetworkLocationController.java


注:本文中的org.apache.cordova.PluginResult類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。