Giter Site home page Giter Site logo

Comments (7)

hemachandsai avatar hemachandsai commented on June 18, 2024 1

Thanks for your time @breautek . From my observation, I guess it is due to app state being killed by android to save ram when we switch to the camera app. As a word around I had made the app as a background process while capturing the image so that the state remains. As a permanent fix, I would consider using a native app camera plugin instead of going through the camera app.

Thanks again

from cordova-plugin-media-capture.

breautek avatar breautek commented on June 18, 2024 1

Glad we got to the bottom of this and that you've discovered some solutions.

FYI that gotcha is also documented as an android quirk at https://github.com/apache/cordova-plugin-media-capture#android-lifecycle-quirks

So listening to the pendingcaptureresult event may also be a workaround.

I'm not 100% sure if using a background process is a reliable solution or not, I think the phone (although maybe more forgiving) may still kill the app activity.

Using the native camera APIs instead of interfacing through the camera app has their own set of problems, particularly with permissions that are treated as "dangerous". So I would vote negative on adding camera API support as a part of this plugin.

Please let me know if this issue can be considered as close or not.

from cordova-plugin-media-capture.

breautek avatar breautek commented on June 18, 2024

Please include your environment detail and versions for

  • cordova cli version
  • cordova-android
  • installed android sdk
  • target sdk (if overwritten)
  • cordova-plugin-media-capture version
  • android os version

and please include the code snippet that is causing this stacktrace.

thanks

from cordova-plugin-media-capture.

hemachandsai avatar hemachandsai commented on June 18, 2024

cordova-android:@8.0.0
[email protected]
cordova-plugin-media-capture [email protected]
androidversion@9

 navigator.device.capture.captureImage(image => {
    let win: any = window;
    win.resolveLocalFileSystemURL(
      image[0].fullPath,
      fileEntry => {
        fileEntry.file(
          file => {
            let data = new FileReader();
            data.onloadend = () => {
              console.log(data.result);
              let blob = new Blob([data.result]);
              this.kycData[code].httpCall = true;
              this.cd.detectChanges();
              this.kycService
                .uploadKyc(type, blob, image[0].name)
                .subscribe(
                  (res: any) => {
                    if (res.status) {
                      this.processUpload(code);
                    }
                  },
                  err => {
                    err.status === 0
                      ? this.presentToast("Please Check your Connection")
                      : this.presentToast(
                          typeof err.error === "string"
                            ? err.error
                            : err.error.message
                        );
                    console.log(err);
                  }
                )
                .add(() => {
                  this.kycData[code].httpCall = false;
                  this.cd.detectChanges();
                });
            };
            data.readAsArrayBuffer(file);
          },
          err => {
            console.log(err);
          }
        );
      },
      err => {
        console.log(err);
      }
    );
  }, (err) => {
    console.log(err)
  });

from cordova-plugin-media-capture.

hemachandsai avatar hemachandsai commented on June 18, 2024

the error is triggered from file capture.java from this method

private JSONObject createMediaFile(Uri data) {
File fp = webView.getResourceApi().mapUriToFile(data);
JSONObject obj = new JSONObject();
Class webViewClass = webView.getClass();

Here there is no null check for the input being passed from onImageActivityResult method also iam sure why the imageUri is being null after capturing the image. Because of that null exception it is crashing the app

from cordova-plugin-media-capture.

breautek avatar breautek commented on June 18, 2024

Thanks for your information. This is to determine and ensure everything is up to date. cordova-android is missing a minor release, but I don't believe this is significant here.

Here there is no null check for the input being passed from onImageActivityResult method also iam sure why the imageUri is being null after capturing the image.

Yes, but even if we add a null check, I don't think it will solve the main problem which is the image uri being null in the first place unexpectedly.

I'm not very familiar with this codebase but bear with me. The next steps to move this forward I think is to create a reproduction app that contains the minimal code required to reproduce this issue. Ensure to include only what is necessary (no ionic or other frameworks, just pure cordova and the plugins required to reproduce the issue).

I have an android 9 device that I can use to test and hopefully reproduce.

https://github.com/apache/cordova-contribute/blob/master/create-reproduction.md

from cordova-plugin-media-capture.

betocantu93 avatar betocantu93 commented on June 18, 2024

Any solution for 2020? We're getting this error with:

cordova-android:@9.0.0
cordova-plugin-media-capture version@master
androidversion@10
targetSdk 29

from cordova-plugin-media-capture.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.