Example usage for org.apache.cordova CordovaPlugin onActivityResult

List of usage examples for org.apache.cordova CordovaPlugin onActivityResult

Introduction

In this page you can find the example usage for org.apache.cordova CordovaPlugin onActivityResult.

Prototype

public void onActivityResult(int requestCode, int resultCode, Intent intent) 

Source Link

Document

Called when an activity you launched exits, giving you the requestCode you started it with, the resultCode it returned, and any additional data from it.

Usage

From source file:com.AlcaldiaSucre.App.CordovaActivity.java

License:Apache License

@Override
/**//from  w  w w  .ja  v a  2s .  c  o  m
 * Called when an activity you launched exits, giving you the requestCode you started it with,
 * the resultCode it returned, and any additional data from it.
 *
 * @param requestCode       The request code originally supplied to startActivityForResult(),
 *                          allowing you to identify who this result came from.
 * @param resultCode        The integer result code returned by the child activity through its setResult().
 * @param data              An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
 */
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    LOG.d(TAG, "Incoming Result");
    super.onActivityResult(requestCode, resultCode, intent);
    Log.d(TAG, "Request code = " + requestCode);
    if (appView != null && requestCode == CordovaChromeClient.FILECHOOSER_RESULTCODE) {
        ValueCallback<Uri> mUploadMessage = this.appView.getWebChromeClient().getValueCallback();
        Log.d(TAG, "did we get here?");
        if (null == mUploadMessage)
            return;
        Uri result = intent == null || resultCode != Activity.RESULT_OK ? null : intent.getData();
        Log.d(TAG, "result = " + result);
        //            Uri filepath = Uri.parse("file://" + FileUtils.getRealPathFromURI(result, this));
        //            Log.d(TAG, "result = " + filepath);
        mUploadMessage.onReceiveValue(result);
        mUploadMessage = null;
    }
    CordovaPlugin callback = this.activityResultCallback;
    if (callback == null && initCallbackClass != null) {
        // The application was restarted, but had defined an initial callback
        // before being shut down.
        this.activityResultCallback = appView.pluginManager.getPlugin(initCallbackClass);
        callback = this.activityResultCallback;
    }
    if (callback != null) {
        LOG.d(TAG, "We have a callback to send this result to");
        callback.onActivityResult(requestCode, resultCode, intent);
    }
}

From source file:com.easycom.cordova.moodstocksScanner.CordovaFragment.java

License:Open Source License

@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    CordovaPlugin callback = this.activityResultCallback;
    if (callback != null) {
        callback.onActivityResult(requestCode, resultCode, intent);
    }/* w  w w .  java 2s  .  co  m*/
}

From source file:com.example.androidcordovawebviewdemo.CordovaInterfaceImpl.java

License:Apache License

/**
 * Routes the result to the awaiting plugin. Returns false if no plugin was waiting.
 *//*  w w  w  .jav a 2s .com*/
public boolean onActivityResult(int requestCode, int resultCode, Intent intent) {
    CordovaPlugin callback = activityResultCallback;
    if (callback == null && initCallbackService != null) {
        // The application was restarted, but had defined an initial callback
        // before being shut down.
        savedResult = new ActivityResultHolder(requestCode, resultCode, intent);
        if (pluginManager != null) {
            callback = pluginManager.getPlugin(initCallbackService);
        }
    }
    activityResultCallback = null;

    if (callback != null) {
        Log.d(TAG, "Sending activity result to plugin");
        initCallbackService = null;
        savedResult = null;
        callback.onActivityResult(requestCode, resultCode, intent);
        return true;
    }
    Log.w(TAG, "Got an activity result, but no plugin was registered to receive it"
            + (savedResult != null ? " yet!" : "."));
    return false;
}

From source file:org.rti.olutindo_app.Olutindo.java

License:Apache License

@Override
/**//  w  w w.java  2  s.  co  m
* Called when an activity you launched exits, giving you the requestCode you started it with,
* the resultCode it returned, and any additional data from it.
*
* @param requestCode       The request code originally supplied to startActivityForResult(),
*                          allowing you to identify who this result came from.
* @param resultCode        The integer result code returned by the child activity through its setResult().
* @param data              An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
*/
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    Log.d(TAG, "Incoming Result");
    super.onActivityResult(requestCode, resultCode, intent);
    Log.d(TAG, "Request code = " + requestCode);
    if (appView != null && requestCode == CordovaChromeClient.FILECHOOSER_RESULTCODE) {
        ValueCallback<Uri> mUploadMessage = this.appView.getWebChromeClient().getValueCallback();
        Log.d(TAG, "did we get here?");
        if (null == mUploadMessage)
            return;
        Uri result = intent == null || resultCode != Activity.RESULT_OK ? null : intent.getData();
        Log.d(TAG, "result = " + result);
        //               Uri filepath = Uri.parse("file://" + FileUtils.getRealPathFromURI(result, this));
        //               Log.d(TAG, "result = " + filepath);
        mUploadMessage.onReceiveValue(result);
        mUploadMessage = null;
    }
    CordovaPlugin callback = this.activityResultCallback;
    if (callback == null && initCallbackClass != null) {
        // The application was restarted, but had defined an initial callback
        // before being shut down.
        this.activityResultCallback = appView.pluginManager.getPlugin(initCallbackClass);
        callback = this.activityResultCallback;
    }
    if (callback != null) {
        Log.d(TAG, "We have a callback to send this result to");
        callback.onActivityResult(requestCode, resultCode, intent);
    }
}