【问题标题】:Gluon Charm Down Barcode Scanner - Intent handler not foundGluon Charm Down 条码扫描仪 - 未找到 Intent 处理程序
【发布时间】:2016-05-11 12:05:29
【问题描述】:

我正在使用 Netbeans 8.1 和 gluonhq jfxplugin 2.2.0。

我正在尝试读取条形码,并创建了一个新项目(标准的 hello world)。我更改了按钮处理程序以调用函数 UpdateText()(如下),该函数又调用 Charm Down Scan 服务。

当我运行应用程序并单击按钮时,我在 Android 设备管理器中收到以下错误:

E/AndroidRuntime(3583): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.gluonhq.charm.down.android.scan.SCAN cat=[android.intent.category.DEFAULT] flg=0x4080000 }

此崩溃发生在 scanservice.scan() 行。

按钮点击处理代码:

    protected void UpdateText(Label label) {
        ScanService scanService = PlatformFactory.getPlatform().getScanService();
        StringProperty scannedString = scanService.scan();
        scannedString.addListener((obs, ov, nv) -> System.out.println("Scanned String = " + nv));
    }

如果有任何帮助,我将不胜感激

【问题讨论】:

    标签: android mobile barcode-scanner gluon charm


    【解决方案1】:

    您需要在 AndroidManifest.xml 文件中定义 com.gluonhq.charm.down.android.scan.SCAN 意图。在您的主要活动定义下方添加以下活动定义:

    <activity android:name="com.gluonhq.charm.down.android.scan.zxing.CaptureActivity"
            android:screenOrientation="sensorLandscape"
            android:clearTaskOnLaunch="true"
            android:stateNotNeeded="true"
            android:windowSoftInputMode="stateAlwaysHidden">
        <intent-filter>
            <action android:name="com.gluonhq.charm.down.android.scan.SCAN"/>
            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
    </activity>
    

    默认情况下,插件会在后台为您生成 AndroidManifest.xml 文件。如果您尚未设置自定义 AndroidManifest.xml 文件,则可以复制插件生成的文件。默认版本位于build/javafxports/tmp/android/AndroidManifest.xml。只需将其复制到一个永久位置,即src/android。然后更新你的 build.gradle 告诉插件它应该使用自定义的 AndroidManifest.xml 文件而不是生成默认文件:

    jfxmobile {
        android {
            manifest = 'src/android/AndroidManifest.xml'
        }
    }
    

    更新: 您还需要向 zxing 核心库添加一个额外的依赖项,因为它似乎不会在仅依赖于魅力库时自动包含:

    dependencies {
        androidRuntime 'com.google.zxing:core:3.2.1'
    }
    

    此外,您还必须将 CAMERA 权限添加到清单中:

    <uses-permission android:name="android.permission.CAMERA"/>
    

    【讨论】:

    • AndroidManifest.xml 已经在 'src/android' 文件夹中。添加活动后,当我单击按钮时,ZXing 屏幕在应用程序崩溃之前在屏幕上闪烁。现在的错误是:java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/zxing/BarcodeFormat;
    猜你喜欢
    • 2014-05-14
    • 2012-05-21
    • 1970-01-01
    • 2016-01-09
    • 1970-01-01
    • 1970-01-01
    • 2011-12-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多