quasarframework / quasar

Quasar Framework - Build high-performance VueJS user interfaces in record time
https://quasar.dev
MIT License
25.55k stars 3.45k forks source link

Cannot Access Camera in Android Platform #1436

Closed tunathoni closed 6 years ago

tunathoni commented 6 years ago

Software version

Quasar: 0.6.4 OS: Mac OSX (High Sierra) Node: 7.6.0 NPM: 4.1.2 Browsers: Chrome iOS: - Android: 6.0.1

I already installed cordova plugin in cordova/ folder, and also implement a code to take a Picture :

<template>
  <div class="hello">
    <h5>Welcome to your Quasar PWA</h5>
    <label for="">{{$q.platform.is.cordova}}</label>
    <ul>
      <li><a href="http://quasar-framework.org" target="_blank" rel="noopener">Docs</a></li>
      <li><a href="http://forum.quasar-framework.org" target="_blank" rel="noopener">Forum</a></li>
      <li><a href="https://gitter.im/quasarframework/Lobby" target="_blank" rel="noopener">Gitter Chat</a></li>
      <li><a href="https://twitter.com/quasarframework" target="_blank" rel="noopener">Twitter</a></li>
    </ul>

    <q-btn icon="create" @click.native="takePicture">Take Picture</q-btn>
  </div>
</template>

<script>
import {
  QBtn
} from 'quasar'

export default {
  name: 'hello',
  components: {
    QBtn
  },
  methods: {
    takePicture: function () {
      if (!navigator.camera) {
        window.alert('cordova.camera not found !')
        return
      }
      // TODO Check for geo-position before taking picture
      navigator.camera.getPicture((imageURI) => {
        this.photoURL = imageURI
        // window.alert(imageURI)
        this.photo = imageURI.split('/').pop()
        var filepath = imageURI.split('/').splice(2)
        filepath.pop()
        filepath = filepath.join('/')
        this.path = filepath + '/'
        this.$refs.maximizedModal.open()
      }, (message) => {
        window.alert('FAILED : ' + message)
      }, {
        quality: 90,
        targetWidth: 500,
        targetHeight: 500,
        destinationType: navigator.camera.DestinationType.FILE_URI
      })
    }
  }
}
</script>

Get an error

After click the button, i got an alert that shown cordova.camera not found !'

mohamedzajith commented 6 years ago

ues this package npm install --save vue-cordova its working.. http://kartsims.github.io/vue-cordova/

demo site https://github.com/kartsims/vue-cordova-demo

rstoenescu commented 6 years ago

Hi,

This is a delicate matter when using a custom webview library as I bet you do. Don't really have time to offer a thorough explanation, but v0.15 is around the corner and it fixes any such potential problems out of the box. Furthermore, "$q.cordova" will point to the Cordova global object for convenience, which is similar to what vue-cordova package does. In v0.15 you'll also be able to use HMR in the emulator or directly on your phone without the need of Quasar Play, and it will also support cordova plugins along the HMR.

If "cordova" global gets to be undefined at runtime in your project, then please add (as a temporary workaround to support your custom webview) this script in index.html: <script type="text/javascript" src="cordova.js"></script>

As v0.15 release is 1-2 weeks in the worst case away, will close this so all dev resources can go to making the release happen. I'm sorry for any inconvenience.

aleddulla commented 1 year ago

I cannot access camera video on android studio , i am using Quasar cordova & android Studio Any help can you please suggest?