L
L
Leonid2019-07-10 11:44:15
Android
Leonid, 2019-07-10 11:44:15

QR code scanner not launching camera in PhoneGap app on Adnroid?

There is a PhoneGap application.
The adnroid version stopped opening the camera to use the QR code scanner, while on iOS everything works fine. Where to look?
JS Code Scanner QR Code:

function ticketScan() {
    cordova.plugins.barcodeScanner.scan(
      function (result) {
          if (result.format=='QR_CODE') {
              if (result.text) {
                  $$.get(getTokenUrl(result.text), function (data, status, xhr) {
                        data = JSON.parse(data);
                        if (data.mess) myApp.alert(data.mess);
                        if (data.notice) setNotice(data.notice);
                        if (data.html) {
                            $$('#scanner-result').html(data.html + '<br /><p><a href="#" onclick="$$(' + "'#scanner-result').html('')" + '" class="button">Очистить</a></p>');                            
                        }
                  });
              } else {
                  myApp.alert('Нет результата сканирования!');
              }
          } else {
              myApp.alert('QR-код не найден!');
          }
      }, 
      function (error) {
          myApp.alert("Ошибка сканирования: " + error);
      }
   );
}

config.xml file:
<?xml version='1.0' encoding='utf-8'?>
<widget id="ru.myapp.mobapps" version="1.1.6" versionCode="73" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
    <name>MyApp</name>
    <description>
        Mobile application site
    </description>
    <content src="index.html" />
    <preference name="android-build-tool" value="gradle" />
    <preference name="DisallowOverscroll" value="true" />
    <preference name="android-minSdkVersion" value="16" />
    <preference name = "android-targetSdkVersion" value = "26" />
    <plugin name="cordova-plugin-battery-status" source="npm" spec="~1.2.4" />
    <plugin name="cordova-plugin-camera" source="npm" spec="~4.0.3">
       <param name="CAMERA_USAGE_DESCRIPTION" value="We are using the Camera for something..." />
       <param name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="We are using the Photo Library for something..." />
    </plugin>
    <plugin name="cordova-plugin-media-capture" source="npm" spec="~1.4.3" />
    <plugin name="cordova-plugin-console" source="npm" spec="~1.0.2" />
    <plugin name="cordova-plugin-contacts" source="npm" spec="~2.0.1" />
    <plugin name="cordova-plugin-device" source="npm" spec="~1.1.6" />
    <plugin name="cordova-plugin-device-motion" source="npm" spec="~1.2.0" />
    <plugin name="cordova-plugin-device-orientation" source="npm" spec="~1.0.2" />
    <plugin name="cordova-plugin-dialogs" source="npm" spec="~1.2.0" />
    <plugin name="cordova-plugin-file" source="npm" spec="~4.3.3" />
    <plugin name="cordova-plugin-file-transfer" source="npm" spec="~1.5.0" />
    <plugin name="cordova-plugin-geolocation" source="npm" spec="~2.4.3" />
    <plugin name="cordova-plugin-globalization" source="npm" spec="~1.0.7" />
    <plugin name="cordova-plugin-inappbrowser" source="npm" spec="~1.7.1" />
    <plugin name="cordova-plugin-media" source="npm" spec="~2.2.0" />
    <plugin name="cordova-plugin-network-information" source="npm" spec="~1.3.3" />
    <plugin name="cordova-plugin-splashscreen" source="npm" spec="~3.2.1" />
    <plugin name="cordova-plugin-statusbar" source="npm" spec="~2.1.2" />
    <plugin name="cordova-plugin-vibration" source="npm" spec="~2.1.5" />
    <plugin name="cordova-plugin-whitelist" source="npm" spec="~1.2.1" />
    <plugin name="phonegap-plugin-barcodescanner">
      <param name="CAMERA_USAGE_DESCRIPTION" value="To scan barcodes." />
    </plugin>
    ....
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="mailto:*" />
    <platform name="android">
        <allow-intent href="market:*" />
        <allow-intent href="http://*/*" />
        <allow-intent href="https://*/*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
    <feature name="Camera">
        <param name="android-package" value="org.apache.cordova.CameraLauncher" />
    </feature>
</widget>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question