如何在胶子魅力创建自定义插件下来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();
}
在构造函数中(我用胶子移动)基本看法是这样的:
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包文件夹我有包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 {
// ...
}
但isPresent永远是假的!