简体   繁体   中英

Gluon Charm Down Barcode Scanner - Intent handler not found

I am using Netbeans 8.1 and the gluonhq jfxplugin 2.2.0.

I am trying to read a barcode, and created a new project (the standard hello world). I changed the button handler to call a function UpdateText() (below) which in turn calls the Charm Down Scan service.

When I run the app, and click on the button I get the following error in the Android Device Manager:

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.

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. 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. If you haven't setup a custom AndroidManifest.xml file yet, you can copy the one that the plugin generates. The default version is located in build/javafxports/tmp/android/AndroidManifest.xml . Just copy that one to a persistent location, ie 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:

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:

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

Furthermore, you'll have to add the CAMERA permission to your manifest as well:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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