0

我遇到了一个错误,ionic3,帮帮我:/?

openGallery() {
console.log("oepn galery");
this.loadfoto = 0;
if (this.platform.is('android')) {
    console.log("if androidk");
    const options: ImagePickerOptions = {
        quality: 80,
    }

    let fotoloading: Loading = this.loading.create({
        content: 'Please wait...'
    });
    console.log("this.imagepicert");
    try {
        console.log("try");
        //close app in this line :// 
        this.imagePicker.getPictures(options).then(results => {
            console.log("image iii");

            this.galleryimagesize = results.length;
            for (var i = 0; i < results.length; i++) {
                console.log("for için");

                this.base64.encodeFile(results[i]).then((base64File: string) => {
                    var re = 'data:image/*;charset=utf-8;base64,';
                    base64File = base64File.replace(re, "");
                    let attachment: AttachmentObj = {
                        field: "resimler",
                        parentType: "Sehitaile",
                        role: "Attachment",
                        name: "image.jpg",
                        file: 'data:image/jpeg;base64,' + base64File,
                        type: "image/jpeg",
                        size: base64File.length,
                    };

                    this.attachments.push(attachment);

                })
            }
            fotoloading.dismiss();
            this.attachmentsize = this.attachmentsize + this.galleryimagesize;
            this.fotoyukleniyormu = true;

        }, (err) => {
            console.log(err)
        });
    } catch (e) {
        console.log(e);
    }
}
else {
    const options: ImagePickerOptions = {
        maximumImagesCount: 3 - this.attachmentsize,
        quality: 70,
    }
    this.imagePicker.getPictures(options).then(results => {
        this.galleryimagesize = results.length;
        for (var i = 0; i < results.length; i++) {
            var itemSrc = results[i].replace(/^file:\/\//, '');
            this.base64.encodeFile(itemSrc).then((base64File: string) => {
                this.imagetype = base64File.substring(5, 14);
                if (this.imagetype == "image/jpe")
                    this.imagetype = "image/jpeg";
                else
                    this.imagetype = "image/png";
                let attachment: AttachmentObj = {
                    field: "resimler",
                    parentType: "Sehitaile",
                    role: "Attachment",
                    name: "image.jpg",
                    file: base64File,
                    type: this.imagetype,
                    size: base64File.length,
                };
                this.attachments.push(attachment);

            })

        }
        this.attachmentsize = this.attachmentsize + this.galleryimagesize;
        this.fotoyukleniyormu = true;

    }, (err) => {
        console.log(err)
    });
}

我想从图库中选择照片,ios可以,但是android不行:///

 this.imagePicker.getPictures(options).then(results => {

<<- 当涉及到上面的行时,应用程序关闭。没有错误没有警告。只需关闭应用程序

当中间应用程序关闭时,我收到一条通知,上面写着background tracking enabled.

我该如何进行,你能帮帮我吗?

4

0 回答 0