Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 从gallery ionic2 angular 2加载图像_Android_Angular_Cordova_Ionic Framework_Ionic2 - Fatal编程技术网

Android 从gallery ionic2 angular 2加载图像

Android 从gallery ionic2 angular 2加载图像,android,angular,cordova,ionic-framework,ionic2,Android,Angular,Cordova,Ionic Framework,Ionic2,我正在使用ionic2和angular2开发移动应用程序 在页面中,用户必须从画廊/相机加载图像 从相机加载图像工作正常。但从图库加载图像不起作用。这也导致了相机 此.camera.PictureSourceType.PHOTOLIBRARY也指向摄影机 我的代码如下: import { Camera, CameraOptions } from '@ionic-native/camera'; import { SpeechRecognition } from '@ionic-native/spe

我正在使用ionic2和angular2开发移动应用程序

在页面中,用户必须从画廊/相机加载图像

从相机加载图像工作正常。但从图库加载图像不起作用。这也导致了相机

此.camera.PictureSourceType.PHOTOLIBRARY也指向摄影机

我的代码如下:

import { Camera, CameraOptions } from '@ionic-native/camera';
import { SpeechRecognition } from '@ionic-native/speech-recognition';
..
..
..

 takePicture(type) {
 this.showActionSheet(type);
  }

  public showActionSheet(type) {
   let actionSheet = this.actionSheetCtrl.create({
    title: 'Choose the source type',
    buttons: [{
     icon: 'camera',
     text: 'Camera',
     handler: () => {
      this.loadImage(this.camera.PictureSourceType.CAMERA, type);
     }
    }, {
     icon: 'image',
     text: 'Gallery',
     handler: () => {
      this.loadImage(this.camera.PictureSourceType.PHOTOLIBRARY, type);
     }
    }, {
     text: 'Cancel',
     role: 'cancel'
    }]
   });
   actionSheet.present();
  }

  private loadImage(selectedSourceType: number, type) {
   let cameraOptions: CameraOptions = {
    sourceType: selectedSourceType,
    destinationType: this.camera.DestinationType.FILE_URI,
    quality: 100,
    allowEdit : true,
    encodingType: this.camera.EncodingType.JPEG,
    mediaType: this.camera.MediaType.PICTURE,
    correctOrientation: true,
   }
   this.camera.getPicture({
    destinationType: this.camera.DestinationType.DATA_URL,
   }).then((imageData) => {
    if (type === 'single') {
     this.base64Image = "data:image/jpeg;base64," + imageData;
    } else {
     this.image = "data:image/jpeg;base64," + imageData;
     this.imageList.push(this.image);
    }
   }, (err) => {
    console.log(err);
   });
  }
请帮帮我。提前谢谢

此外,安卓系统中的麦克风工作正常,没有任何问题。但对于ios而言,麦克风无法正常工作。我需要做些修改吗

listenForSpeech(): void {
  this.isSpeechSupported();
  this.getPermission();
  this.hasPermission();
  this.getSupportedLanguages();

  this.iosOptions = {
   language: 'en-US'
  }

  if (this.platform.is('android')) {
   this.speech.startListening().subscribe(data => this.ivr(data), error =>                                
  console.log(error));
  } else if (this.platform.is('ios')) {
  this.speech.startListening().subscribe(data => this.speechList = data[0], 
 error => console.log(error));
 }
 }