IONIC, TS, native camera plugin restarts app on MOTOROLA G4 PLUS


#1

Everyone, good night.

Has anyone had this problem that when taking a photo restarts the application in the code below ??

This problem only happens on MOTOROLA G4 PLUS, I tried another phone with Android 6.0 and it worked correctly.

import { Component, OnInit } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { UsuarioService } from '../../domain/usuario/usuario-service';
import { Camera } from 'ionic-native';

@Component({
  selector: 'page-perfil',
  templateUrl: 'perfil.html'
})
export class PerfilPage implements OnInit {

  public url: string;

  constructor(
    public navCtrl: NavController, 
    public navParams: NavParams,
    private _service: UsuarioService) {}

  get usuarioLogado() {
    return this._service.obtemUsuarioLogado();
  }

  ngOnInit() {
    this.url = this._service.obtemAvatar();
  }

  tiraFoto() {
    Camera.getPicture({
      destinationType: Camera.DestinationType.FILE_URI,
      saveToPhotoAlbum: true, 
      correctOrientation: true
    }).then(url => {
      this._service.guardaAvatar(url);
      this.url = url;
    })
    .catch(err => console.log(err));

  }

}

#2

Please edit your post and use the </> button above the post input field to format your code or error message or wrap it in ``` (“code fences”) manually. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.