Camera image is not working in Android mobile


#1

I implemented cordova-plugin-camera in my apps, the code as below.

The image is show in emulator, but it doesn’t display in device (I am using Samsung Note 3 to test it).

How do I know what is my problem?

js

Camera.getPicture(options).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
// If it’s base64:
this.imgSrc = “data:image/jpeg;base64,” + imageData;
// this.imgSrc = imageData;
}, (err) => {
});

HTML

<img [src]="imgSrc" id="imgPlacement">
    <button block (click)="takePhoto()">
    Take Photo
  </button>
  <button block danger (click)="choosePhoto()">
    From Gallery
  </button>

#2

what version are you using?

run ionic info in your project directory, be sure you are using the latest versions


#3

Below is the ionic info

Cordova CLI: 6.0.0
Ionic Version: 2.0.0-beta.3
Ionic CLI Version: 2.0.0-beta.22
Ionic App Lib Version: 2.0.0-beta.12
OS:
Node Version: v4.4.1


#4

you are two versions behind on ionic, this is the latest

Cordova CLI: 6.0.0
Ionic Framework Version: 2.0.0-beta.6
Ionic CLI Version: 2.0.0-beta.25
Ionic App Lib Version: 2.0.0-beta.15
OS:
Node Version: v4.4.1

#5

Will it caused the img is not working in Device?


#6

I have updated all version, but still not able to display the img.

Cordova CLI: 6.0.0
Ionic Version: 2.0.0-beta.6-201604212137
Ionic CLI Version: 2.0.0-beta.22
Ionic App Lib Version: 2.0.0-beta.12
OS:
Node Version: v4.4.1

Between, I am wondering could it be the picture after capture is not save? Because I can’t find any photo after capture appear in the device, even I have click the save button


#7

try

Camera.getPicture(option).then((imageData)=> {
     var imgPlacementSrc = document.getElementById("imgPlacement");
     imgPlacementSrc.src = "data:image/jpeg;base64," + imageData;
});