安卓在Flatter(dart)项目中使用Java JAR库文件
我对飞舞和飞镖还不熟悉。我需要知道在Dart项目中使用JAR库文件的可能性。使用JAR文件的原因是,JAR文件用于我的RFID和条形码扫描仪API
因此,我需要导入引用,然后在dart项目中使用它们。下面是调用库文件的JAVA代码示例
套餐应用
导入com。senter。支持openapi。StKeyManager; 导入com。senter。支持openapi。斯图夫
公共课堂活动扩展了课堂活动{
StKeyManager.ShortcutKeyMonitor monitorScan = StKeyManager.ShortcutKeyMonitor.isShortcutKeyAvailable(StKeyManager.ShortcutKey.Scan) ?
StKeyManager.getInstanceOfShortcutKeyMonitor(StKeyManager.ShortcutKey.Scan) : null;
private boolean isScaning;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (monitorScan != null) monitorScan.reset(this, listener, null);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
doRFID();
switch (keyCode) {
case KeyEvent.KEYCODE_BACK: {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
doRFID();
}
break;
}
default:
break;
}
return super.onKeyDown(keyCode, event);
}
StKeyManager.ShortcutKeyMonitor.ShortcutKeyListener listener = new StKeyManager.ShortcutKeyMonitor.ShortcutKeyListener() {
public void onKeyDown(int keycode,int repeatCount,StKeyManager.ShortcutKeyMonitor.ShortcutKeyEvent event){
if(isScaning==false){
isScaning=true;
doRFID();
}
}
public void onKeyUp(int keycode,int repeatCount,StKeyManager.ShortcutKeyMonitor.ShortcutKeyEvent event){
isScaning=false;
}
};
public void doRFID() {
if(App.getUhf(StUhf.InterrogatorModel.InterrogatorModelD2) == null){
Toast.makeText(this, "Device not supported", Toast.LENGTH_SHORT).show();
}else {
TextView editText = this.findViewById(R.id.textRFID);
TextView editTextRaw = this.findViewById(R.id.textRFIDRAW);
TextView editTextGTIN = this.findViewById(R.id.textRFIDGTIN);
textRFID.setText("");
textRFIDRAW.setText("");
textRFIDGTIN.setText("");
ScanRfid scanner = new ScanRfid(this, editText, editTextRaw, editTextGTIN);
scanner.startScan();
}
}
}
//下面是我调用Java代码的部分:
//ScanRfid scanner=new ScanRfid(this,editText,editTextRaw,editTextGTIN); //扫描仪。startScan()
谢谢你的帮助
共 (0) 个答案