Example usage for org.apache.cordova.api LOG d

List of usage examples for org.apache.cordova.api LOG d

Introduction

In this page you can find the example usage for org.apache.cordova.api LOG d.

Prototype

public static void d(String tag, String s) 

Source Link

Document

Debug log message.

Usage

From source file:com.androguide.apkreator.fragments.PhoneGapFragment.java

License:Open Source License

@Override
public Object onMessage(String id, Object data) {
    LOG.d("PhoneGapFragment", "onMessage(" + id + "," + data + ")");
    if ("exit".equals(id))
        fa.finish();// w w  w .  j a  va2 s  .  com
    return null;
}

From source file:com.cloudstudio.camera.ForegroundCameraLauncher.java

License:Apache License

/**
 * Called when the camera view exits./*from  w  w  w.j a va  2 s . c o  m*/
 * 
 * @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 intent
 *            An Intent, which can return result data to the caller (various
 *            data can be attached to Intent "extras").
 */
public void onActivityResult(int requestCode, int resultCode, Intent intent) {

    // If image available
    if (resultCode == Activity.RESULT_OK) {
        try {
            // Create an ExifHelper to save the exif data that is lost
            // during compression
            ExifHelper exif = new ExifHelper();
            exif.createInFile(
                    getTempDirectoryPath(this.cordova.getActivity().getApplicationContext()) + "/Pic.jpg");
            exif.readExifData();

            // Read in bitmap of captured image
            Bitmap bitmap;
            try {
                bitmap = android.provider.MediaStore.Images.Media
                        .getBitmap(this.cordova.getActivity().getContentResolver(), imageUri);
            } catch (FileNotFoundException e) {
                Uri uri = intent.getData();
                android.content.ContentResolver resolver = this.cordova.getActivity().getContentResolver();
                bitmap = android.graphics.BitmapFactory.decodeStream(resolver.openInputStream(uri));
            }

            bitmap = scaleBitmap(bitmap);

            // Create entry in media store for image
            // (Don't use insertImage() because it uses default compression
            // setting of 50 - no way to change it)
            ContentValues values = new ContentValues();
            values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
            Uri uri = null;
            try {
                Log.d("camera", "external_content_uri:"
                        + android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                uri = this.cordova.getActivity().getContentResolver()
                        .insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
            } catch (UnsupportedOperationException e) {
                LOG.d(LOG_TAG, "Can't write to external media storage.");
                try {
                    uri = this.cordova.getActivity().getContentResolver()
                            .insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values);
                } catch (UnsupportedOperationException ex) {
                    LOG.d(LOG_TAG, "Can't write to internal media storage.");
                    this.failPicture("Error capturing image - no media storage found.");
                    return;
                }
            }
            Log.d("camera", "uri:" + uri.toString());
            // Add compressed version of captured image to returned media
            // store Uri
            OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri);
            bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os);
            os.close();

            // Restore exif data to file
            exif.createOutFile(getRealPathFromURI(uri, this.cordova));
            exif.writeExifData();

            // Send Uri back to JavaScript for viewing image
            this.callbackContext.success(getRealPathFromURI(uri, this.cordova));

            bitmap.recycle();
            bitmap = null;
            System.gc();

            checkForDuplicateImage();
        } catch (IOException e) {
            e.printStackTrace();
            this.failPicture("Error capturing image.");
        }
    }

    // If cancelled
    else if (resultCode == Activity.RESULT_CANCELED) {
        this.failPicture("Camera cancelled.");
    }

    // If something else
    else {
        this.failPicture("Did not complete!");
    }
}

From source file:com.djoin.parking.parking.java

License:Apache License

@SuppressLint("NewApi")
@Override/*from w  ww  .  j a v  a  2  s  . c  om*/
public void init(CordovaWebView webView, CordovaWebViewClient webViewClient,
        CordovaChromeClient webChromeClient) {
    LOG.d(TAG, "CordovaActivity.init()");

    // Set up web container
    this.appView = webView;
    this.appView.setId(100);

    //js?
    this.appView.addJavascriptInterface(new JsInterface(), "jsinterface");

    this.appView.setWebViewClient(webViewClient);
    this.appView.setWebChromeClient(webChromeClient);
    webViewClient.setWebView(this.appView);
    webChromeClient.setWebView(this.appView);

    this.appView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, 1.0F));

    if (this.getBooleanProperty("disallowOverscroll", false)) {
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD) {
            this.appView.setOverScrollMode(CordovaWebView.OVER_SCROLL_NEVER);
        }
    }

    // Add web view but make it invisible while loading URL
    this.appView.setVisibility(View.INVISIBLE);

    View v = getLayoutInflater().inflate(R.layout.main, null);

    mDrawerLayout = (DrawerLayout) v.findViewById(R.id.drawer_layout);
    myroot = (LinearLayout) v.findViewById(R.id.content_frame);
    mLeftNav = (ListView) v.findViewById(R.id.left_nav);

    mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);

    myroot.setBackgroundColor(Color.BLACK);

    setTheme(R.style.gray);

    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);

    myroot.addView(this.appView);

    setContentView(mDrawerLayout);
    // Clear cancel flag
    this.cancelLoadUrl = false;

}

From source file:com.example.android.actionbarcompat.MainActivity.java

License:Apache License

/**
 * Called when a message is sent to plugin.
 *
 * @param id            The message id/*from   www  .  j a  v  a2  s.c o  m*/
 * @param data          The message data
 * @return              Object or null
 */
public Object onMessage(String id, Object data) {
    LOG.d(TAG, "onMessage(" + id + "," + data + ")");
    if ("exit".equals(id)) {
        super.finish();
    }
    return null;
}

From source file:com.example.android.actionbarcompat.MainActivity.java

License:Apache License

@Override
/**//  ww w  . j av a 2  s.  c o  m
 * The final call you receive before your activity is destroyed.
 */
public void onDestroy() {
    LOG.d(TAG, "onDestroy()");
    super.onDestroy();
    if (mainView.pluginManager != null) {
        mainView.pluginManager.onDestroy();
    }

    if (this.mainView != null) {

        // Send destroy event to JavaScript
        this.mainView.loadUrl(
                "javascript:try{cordova.require('cordova/channel').onDestroy.fire();}catch(e){console.log('exception firing destroy event from native');};");

        // Load blank page so that JavaScript onunload is called
        this.mainView.loadUrl("about:blank");

        // Forward to plugins
        if (this.mainView.pluginManager != null) {
            this.mainView.pluginManager.onDestroy();
        }
    } else {
        //this.endActivity();
    }
}

From source file:com.example.hardtosay.MainActivity.java

License:Apache License

@Override
public void onCreate(Bundle savedInstanceState) {
    LOG.d("MainActivity", "MainActivity start");
    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites()
            .detectNetwork().penaltyLog().build());
    StrictMode.setVmPolicy(/*from w w w .j a  v  a 2  s  .  c om*/
            new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects().penaltyLog().penaltyDeath().build());
    super.onCreate(savedInstanceState);
    docPlugin.deviceMac = getLocalMacAddress();
    //      super.setIntegerProperty("splashscreen", R.drawable.splash);
    //      super.loadUrl("file:///android_asset/www/index.html", 1500);
    super.loadUrl("file:///android_asset/www/index.html");
}

From source file:com.foregroundcameraplugin.ForegroundCameraLauncher.java

License:Apache License

/**
 * Called when the camera view exits./*from  w ww .j a va 2s . c o m*/
 * 
 * @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 intent
 *            An Intent, which can return result data to the caller (various
 *            data can be attached to Intent "extras").
 */
public void onActivityResult(int requestCode, int resultCode, Intent intent) {

    // If image available
    if (resultCode == Activity.RESULT_OK) {
        try {
            // Create an ExifHelper to save the exif data that is lost
            // during compression
            ExifHelper exif = new ExifHelper();
            exif.createInFile(
                    getTempDirectoryPath(this.cordova.getActivity().getApplicationContext()) + "/Pic.jpg");
            exif.readExifData();

            // Read in bitmap of captured image
            Bitmap bitmap;
            try {
                bitmap = android.provider.MediaStore.Images.Media
                        .getBitmap(this.cordova.getActivity().getContentResolver(), imageUri);
            } catch (FileNotFoundException e) {
                Uri uri = intent.getData();
                android.content.ContentResolver resolver = this.cordova.getActivity().getContentResolver();
                bitmap = android.graphics.BitmapFactory.decodeStream(resolver.openInputStream(uri));
            }

            bitmap = scaleBitmap(bitmap);

            // Create entry in media store for image
            // (Don't use insertImage() because it uses default compression
            // setting of 50 - no way to change it)
            ContentValues values = new ContentValues();
            values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
            Uri uri = null;
            try {
                uri = this.cordova.getActivity().getContentResolver()
                        .insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
            } catch (UnsupportedOperationException e) {
                LOG.d(LOG_TAG, "Can't write to external media storage.");
                try {
                    uri = this.cordova.getActivity().getContentResolver()
                            .insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values);
                } catch (UnsupportedOperationException ex) {
                    LOG.d(LOG_TAG, "Can't write to internal media storage.");
                    this.failPicture("Error capturing image - no media storage found.");
                    return;
                }
            }

            // Add compressed version of captured image to returned media
            // store Uri
            OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri);
            bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os);
            os.close();

            // Restore exif data to file
            exif.createOutFile(getRealPathFromURI(uri, this.ctx));
            exif.writeExifData();

            // Send Uri back to JavaScript for viewing image
            this.success(new PluginResult(PluginResult.Status.OK, getRealPathFromURI(uri, this.ctx)),
                    this.callbackId);

            bitmap.recycle();
            bitmap = null;
            System.gc();

            checkForDuplicateImage();
        } catch (IOException e) {
            e.printStackTrace();
            this.failPicture("Error capturing image.");
        }
    }

    // If cancelled
    else if (resultCode == Activity.RESULT_CANCELED) {
        this.failPicture("Camera cancelled.");
    }

    // If something else
    else {
        this.failPicture("Did not complete!");
    }
}

From source file:com.magictools.phonegap.demos.ForegroundCameraLauncher.java

License:Apache License

/**
 * Called when the camera view exits.//from   ww w  .  ja v a  2s  . com
 * 
 * @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 intent
 *            An Intent, which can return result data to the caller (various
 *            data can be attached to Intent "extras").
 */
//--------------------------------
public void onActivityResult(int requestCode, int resultCode, Intent intent)
//--------------------------------
{
    // If image available
    if (resultCode == Activity.RESULT_OK) {
        try {
            // Create an ExifHelper to save the exif data that is lost
            // during compression
            ExifHelper exif = new ExifHelper();
            exif.createInFile(
                    getTempDirectoryPath(this.cordova.getActivity().getApplicationContext()) + "/Pic.jpg");
            exif.readExifData();

            // Read in bitmap of captured image
            Bitmap bitmap;
            try {
                bitmap = android.provider.MediaStore.Images.Media
                        .getBitmap(this.cordova.getActivity().getContentResolver(), imageUri);
            } catch (FileNotFoundException e) {
                Uri uri = intent.getData();
                android.content.ContentResolver resolver = this.cordova.getActivity().getContentResolver();
                bitmap = android.graphics.BitmapFactory.decodeStream(resolver.openInputStream(uri));
            }

            bitmap = scaleBitmap(bitmap);

            // Create entry in media store for image
            // (Don't use insertImage() because it uses default compression
            // setting of 50 - no way to change it)
            ContentValues values = new ContentValues();
            values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
            Uri uri = null;
            try {
                uri = this.cordova.getActivity().getContentResolver()
                        .insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
            } catch (UnsupportedOperationException e) {
                LOG.d(LOG_TAG, "Can't write to external media storage.");

                try {
                    uri = this.cordova.getActivity().getContentResolver()
                            .insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values);
                } catch (UnsupportedOperationException ex) {
                    LOG.d(LOG_TAG, "Can't write to internal media storage.");
                    this.failPicture("Error capturing image - no media storage found.");
                    return;
                }
            }

            // Add compressed version of captured image to returned media
            // store Uri
            OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri);
            bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os);
            os.close();

            // Restore exif data to file
            exif.createOutFile(getRealPathFromURI(uri, this.cordova));
            exif.writeExifData();

            // Send Uri back to JavaScript for viewing image
            this.callbackContext.success(getRealPathFromURI(uri, this.cordova));

            bitmap.recycle();
            bitmap = null;
            System.gc();

            checkForDuplicateImage();
        } catch (IOException e) {
            e.printStackTrace();
            this.failPicture("Error capturing image.");
        }
    }
    // If cancelled
    else if (resultCode == Activity.RESULT_CANCELED) {
        this.failPicture("Camera cancelled.");
    }
    // If something else
    else {
        this.failPicture("Did not complete!");
    }
}

From source file:com.MustacheMonitor.MustacheMonitor.StacheCam.java

License:Apache License

/**
 * Create entry in media store for image
 *
 * @return uri//from ww w .j  a va2s.c  om
 */
private Uri getUriFromMediaStore() {
    ContentValues values = new ContentValues();
    values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
    Uri uri;
    try {
        uri = this.cordova.getActivity().getContentResolver()
                .insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
    } catch (UnsupportedOperationException e) {
        LOG.d(LOG_TAG, "Can't write to external media storage.");
        try {
            uri = this.cordova.getActivity().getContentResolver()
                    .insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values);
        } catch (UnsupportedOperationException ex) {
            LOG.d(LOG_TAG, "Can't write to internal media storage.");
            return null;
        }
    }
    return uri;
}

From source file:com.phonegap.plugins.wsiCapture.WsiCapture.java

License:Apache License

/**
 * Called when the video view exits./* ww w .  j ava 2 s . co  m*/
 * 
 * @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 intent
 *            An Intent, which can return result data to the caller (various
 *            data can be attached to Intent "extras").
 * @throws JSONException
 */
public void onActivityResult(int requestCode, int resultCode, Intent intent) {

    // Result received okay
    if (resultCode == Activity.RESULT_OK) {
        // An audio clip was requested
        if (requestCode == CAPTURE_AUDIO) {
            // Get the uri of the audio clip
            Uri data = intent.getData();
            // create a file object from the uri
            results.put(createMediaFile(data));

            if (results.length() >= limit) {
                // Send Uri back to JavaScript for listening to audio
                this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, results));
            } else {
                // still need to capture more audio clips
                captureAudio();
            }
        } else if (requestCode == CAPTURE_IMAGE) {
            // For some reason if I try to do:
            // Uri data = intent.getData();
            // It crashes in the emulator and on my phone with a null
            // pointer exception
            // To work around it I had to grab the code from
            // CameraLauncher.java
            try {
                // Create entry in media store for image
                // (Don't use insertImage() because it uses default
                // compression setting of 50 - no way to change it)
                ContentValues values = new ContentValues();
                values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, IMAGE_JPEG);
                Uri uri = null;
                try {
                    uri = this.cordova.getActivity().getContentResolver()
                            .insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
                } catch (UnsupportedOperationException e) {
                    LOG.d(LOG_TAG, "Can't write to external media storage.");
                    try {
                        uri = this.cordova.getActivity().getContentResolver()
                                .insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values);
                    } catch (UnsupportedOperationException ex) {
                        LOG.d(LOG_TAG, "Can't write to internal media storage.");
                        this.fail(createErrorObject(CAPTURE_INTERNAL_ERR,
                                "Error capturing image - no media storage found."));
                        return;
                    }
                }
                FileInputStream fis = new FileInputStream(
                        this.getTempDirectoryPath(this.cordova.getActivity()) + "/Capture.jpg");
                OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri);
                byte[] buffer = new byte[4096];
                int len;
                while ((len = fis.read(buffer)) != -1) {
                    os.write(buffer, 0, len);
                }
                os.flush();
                os.close();
                fis.close();

                String mid = generateRandomMid();

                FileInputStream fi = new FileInputStream(
                        this.getTempDirectoryPath(this.cordova.getActivity()) + "/Capture.jpg");
                Bitmap bitmap = BitmapFactory.decodeStream(fi);
                fi.close();

                ExifInterface exif = new ExifInterface(
                        this.getTempDirectoryPath(this.cordova.getActivity()) + "/Capture.jpg");

                int rotate = 0;

                if (exif.getAttribute(ExifInterface.TAG_ORIENTATION) != null) {
                    int o = Integer.parseInt(exif.getAttribute(ExifInterface.TAG_ORIENTATION));

                    Log.d(LOG_TAG, "z7");

                    if (o == ExifInterface.ORIENTATION_NORMAL) {
                        rotate = 0;
                    } else if (o == ExifInterface.ORIENTATION_ROTATE_90) {
                        rotate = 90;
                    } else if (o == ExifInterface.ORIENTATION_ROTATE_180) {
                        rotate = 180;
                    } else if (o == ExifInterface.ORIENTATION_ROTATE_270) {
                        rotate = 270;
                    } else {
                        rotate = 0;
                    }

                    Log.d(LOG_TAG, "z8");

                    Log.d(LOG_TAG, "rotate: " + rotate);

                    // try to correct orientation
                    if (rotate != 0) {
                        Matrix matrix = new Matrix();
                        Log.d(LOG_TAG, "z9");
                        matrix.setRotate(rotate);
                        Log.d(LOG_TAG, "z10");
                        bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(),
                                matrix, true);
                        Log.d(LOG_TAG, "z11");
                    }
                }

                String filePath = this.getTempDirectoryPath(this.cordova.getActivity()) + "/econ_" + mid
                        + ".jpg";
                FileOutputStream foEcon = new FileOutputStream(filePath);
                fitInsideSquare(bitmap, 850).compress(CompressFormat.JPEG, 45, foEcon);
                foEcon.flush();
                foEcon.close();

                String filePathMedium = this.getTempDirectoryPath(this.cordova.getActivity()) + "/medium_" + mid
                        + ".jpg";
                FileOutputStream foMedium = new FileOutputStream(filePathMedium);
                makeInsideSquare(bitmap, 320).compress(CompressFormat.JPEG, 55, foMedium);
                foMedium.flush();
                foMedium.close();

                String filePathThumb = this.getTempDirectoryPath(this.cordova.getActivity()) + "/thumb_" + mid
                        + ".jpg";
                FileOutputStream foThumb = new FileOutputStream(filePathThumb);
                makeInsideSquare(bitmap, 175).compress(CompressFormat.JPEG, 55, foThumb);
                foThumb.flush();
                foThumb.close();

                bitmap.recycle();
                System.gc();

                // Add image to results
                JSONObject mediaFile = createMediaFile(uri);
                try {
                    mediaFile.put("typeOfPluginResult", "initialRecordInformer");
                    mediaFile.put("mid", mid);
                    mediaFile.put("mediaType", "photo");
                    mediaFile.put("filePath", filePath);
                    mediaFile.put("filePathMedium", filePathMedium);
                    mediaFile.put("filePathThumb", filePathThumb);
                } catch (JSONException e) {
                    Log.d(LOG_TAG, "error: " + e.getStackTrace().toString());
                }

                // checkForDuplicateImage(); // i dont know what this does but i'm taken it out anyways!

                PluginResult pluginResult = new PluginResult(PluginResult.Status.OK,
                        (new JSONArray()).put(mediaFile));
                pluginResult.setKeepCallback(true);
                this.callbackContext.sendPluginResult(pluginResult);
                new UploadFilesToS3Task().execute(new File(filePath), new File(filePathMedium),
                        new File(filePathThumb), this.callbackContext, mid, mediaFile);
            } catch (IOException e) {
                e.printStackTrace();
                this.fail(createErrorObject(CAPTURE_INTERNAL_ERR, "Error capturing image."));
            }
        } else if (requestCode == CAPTURE_VIDEO) {
            // Get the uri of the video clip

            Log.d(LOG_TAG, "activity result video");

            Uri uri = intent.getData();

            Log.d(LOG_TAG, "before create thumbnail");
            Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(
                    (new File(this.getRealPathFromURI(uri, this.cordova))).getAbsolutePath(),
                    MediaStore.Images.Thumbnails.MINI_KIND);
            Log.d(LOG_TAG, "after create thumbnail");
            String mid = generateRandomMid();

            try {
                String filePathMedium = this.getTempDirectoryPath(this.cordova.getActivity()) + "/medium_" + mid
                        + ".jpg";
                FileOutputStream foMedium = new FileOutputStream(filePathMedium);
                bitmap.compress(CompressFormat.JPEG, 100, foMedium);
                foMedium.flush();
                foMedium.close();

                bitmap.recycle();
                System.gc();

                // Add image to results
                JSONObject mediaFile = createMediaFile(uri);
                try {
                    mediaFile.put("typeOfPluginResult", "initialRecordInformer");
                    mediaFile.put("mid", mid);
                    mediaFile.put("mediaType", "video");
                    mediaFile.put("filePath", filePathMedium);
                    mediaFile.put("filePathMedium", filePathMedium);
                    mediaFile.put("filePathThumb", filePathMedium);
                    String absolutePath = (new File(this.getRealPathFromURI(uri, this.cordova)))
                            .getAbsolutePath();
                    mediaFile.put("fileExt", absolutePath.substring(absolutePath.lastIndexOf(".") + 1));
                } catch (JSONException e) {
                    Log.d(LOG_TAG, "error: " + e.getStackTrace().toString());
                }
                Log.d(LOG_TAG, "mediafile at 638" + mediaFile.toString());
                PluginResult pluginResult = new PluginResult(PluginResult.Status.OK,
                        (new JSONArray()).put(mediaFile));
                pluginResult.setKeepCallback(true);
                this.callbackContext.sendPluginResult(pluginResult);
                new UploadVideoToS3Task().execute(new File(this.getRealPathFromURI(uri, this.cordova)),
                        this.callbackContext, mid, mediaFile);
            } catch (FileNotFoundException e1) {
                e1.printStackTrace();
            } catch (IOException e1) {
                e1.printStackTrace();
            }
        }
    }
    // If canceled
    else if (resultCode == Activity.RESULT_CANCELED) {
        // If we have partial results send them back to the user
        if (results.length() > 0) {
            this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, results));
        }
        // user canceled the action
        else {
            this.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Canceled."));
        }
    }
    // If something else
    else {
        // If we have partial results send them back to the user
        if (results.length() > 0) {
            //this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, results));
        }
        // something bad happened
        else {
            this.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Did not complete!"));
        }
    }
}