Gluon Charm down 3.0.0 - how to create cusom plugin

╄→尐↘猪︶ㄣ 提交于 2019-12-24 06:43:40

问题


How to create custom plugin in Gluon Charm down 3.0.0? Or something similar.

I have package sk.ltorok.gluon.bluetooth.plugins and this package contains two classes BluetoothServiceFactory and BluetoothService and this is code:

package sk.ltorok.gluon.bluetooth.plugins;

import com.gluonhq.charm.down.DefaultServiceFactory;

public class BluetoothServiceFactory extends DefaultServiceFactory<BluetoothService> {

    public BluetoothServiceFactory() {
        super(BluetoothService.class);
    }  

}

... and next class

package sk.ltorok.gluon.bluetooth.plugins;

import java.util.List;

public interface BluetoothService {

    List<String> getPairedDevices();
}

In Basic view in constructor (I using Gluon Mobile) is this:

public class BasicView extends View {

    private BluetoothService bluetoothService;

    public BasicView(String name) {
        super(name);
        Services.registerServiceFactory(new BluetoothServiceFactory());
        System.out.println("REGISTER BLUETOOTH");
        boolean isPresent = Services.get(BluetoothService.class).isPresent();
        System.out.println("BLUETOOTH PRESENT: " + isPresent);
        if (isPresent) {
            Optional<BluetoothService> opt = Services.get(BluetoothService.class);
            bluetoothService = opt.get();
        }

... etc. next code ...

In Andoid/Java Packages folder I have package sk.ltorok.gluon.bluetooth.plugins.android and there is implementation AndroidBluetoothService class

package sk.ltorok.gluon.bluetooth.plugins.android;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Intent;
import android.os.Build;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import javafxports.android.FXActivity;
import sk.ltorok.gluon.bluetooth.plugins.BluetoothService;

public class AndroidBluetoothService implements BluetoothService {
    // ...
}

BUT isPresent is always false!

来源:https://stackoverflow.com/questions/40261409/gluon-charm-down-3-0-0-how-to-create-cusom-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!