繁体   English   中英

Gluon Charm Down 条码扫描仪 - 未找到意图处理程序

[英]Gluon Charm Down Barcode Scanner - Intent handler not found

我正在使用 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));
    }

我将不胜感激任何帮助

您需要在 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"/>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM