Gluon Charm下降3.0.0 - 如何创建cusom插件

时间:2016-10-26 11:43:16

标签: javafxports gluon-mobile

如何在Gluon Charm 3.0.0中创建自定义插件? 或类似的东西。

我有包sk.ltorok.gluon.bluetooth.plugins,这个包包含两个类BluetoothServiceFactory和BluetoothService,这是代码:

package sk.ltorok.gluon.bluetooth.plugins;

import com.gluonhq.charm.down.DefaultServiceFactory;

public class BluetoothServiceFactory extends DefaultServiceFactory<BluetoothService> {

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

}

......和下​​一堂课

package sk.ltorok.gluon.bluetooth.plugins;

import java.util.List;

public interface BluetoothService {

    List<String> getPairedDevices();
}

在构造函数的基本视图中(我使用的是Gluon Mobile)是这样的:

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();
        }

...等下一个代码...

在Andoid / Java Packages文件夹中我有包sk.ltorok.gluon.bluetooth.plugins.android并且有实现AndroidBluetoothService类

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 {
    // ...
}

但是现在总是假的!

0 个答案:

没有答案