[英]Gluon Charm Down Barcode Scanner - Intent handler not found
I am using Netbeans 8.1 and the gluonhq jfxplugin 2.2.0.我正在使用 Netbeans 8.1 和 gluonhq jfxplugin 2.2.0。
I am trying to read a barcode, and created a new project (the standard hello world).我正在尝试读取条形码,并创建了一个新项目(标准的 hello world)。 I changed the button handler to call a function UpdateText() (below) which in turn calls the Charm Down Scan service.
我更改了按钮处理程序以调用函数 UpdateText()(如下),该函数又调用 Charm Down Scan 服务。
When I run the app, and click on the button I get the following error in the Android Device Manager:当我运行应用程序并单击按钮时,我在 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 }
This crash is happening on the scanservice.scan() line.此崩溃发生在 scanservice.scan() 行上。
Button click handler code:按钮单击处理程序代码:
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));
}
I would greatly appreciate any help我将不胜感激任何帮助
You need to define the com.gluonhq.charm.down.android.scan.SCAN
intent in your AndroidManifest.xml file.您需要在 AndroidManifest.xml 文件中定义
com.gluonhq.charm.down.android.scan.SCAN
意图。 Add the following activity definition below your main activity definition:在您的主要活动定义下方添加以下活动定义:
<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>
By default, the AndroidManifest.xml file is generated for you under the hood by the plugin.默认情况下,AndroidManifest.xml 文件是由插件在后台为您生成的。 If you haven't setup a custom AndroidManifest.xml file yet, you can copy the one that the plugin generates.
如果您还没有设置自定义 AndroidManifest.xml 文件,您可以复制插件生成的文件。 The default version is located in
build/javafxports/tmp/android/AndroidManifest.xml
.默认版本位于
build/javafxports/tmp/android/AndroidManifest.xml
。 Just copy that one to a persistent location, ie src/android
.只需将那个复制到一个永久位置,即
src/android
。 Then update your build.gradle to tell the plugin that it should use the custom AndroidManifest.xml file instead of generating the default one:然后更新您的 build.gradle 以告诉插件它应该使用自定义 AndroidManifest.xml 文件而不是生成默认文件:
jfxmobile {
android {
manifest = 'src/android/AndroidManifest.xml'
}
}
update: You also need to add an extra dependency to the zxing core library as it seems it isn't included automatically when depending on the charm library alone:更新:您还需要向 zxing 核心库添加额外的依赖项,因为当仅依赖于魅力库时,它似乎不会自动包含在内:
dependencies {
androidRuntime 'com.google.zxing:core:3.2.1'
}
Furthermore, you'll have to add the CAMERA permission to your manifest as well:此外,您还必须将 CAMERA 权限添加到您的清单中:
<uses-permission android:name="android.permission.CAMERA"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.