Код: Выделить всё
public class MyPiccManager {
private PiccManager mScanManager;
Context context;
public MyPiccManager(Context context) {
this.context = context;
mScanManager = new PiccManager();
}
public int open() {
if (mScanManager == null) {
mScanManager = new PiccManager();
}
int ret = mScanManager.open(); // Use mScanManager instead of piccManager
if (ret != 0) {
// Handle error
}
return ret;
}
public int close() {
int ret = mScanManager.open(); // Call open before closing (check if needed)
if (ret == 0) {
mScanManager.close(); // Use mScanManager instead of piccManager
}
return ret;
}
public int activate() {
mScanManager.open(); // Call open before activation
byte[] atr = new byte[32];
int ret = mScanManager.activateEx(atr); // Use mScanManager instead of piccManager
if (ret != 0) {
// Handle error
}
return ret;
}
public int deactivate(byte mode) {
// Corrected comment syntax and moved public static final byte MODE inside method
final byte MODE = 0x00;
int ret = mScanManager.deactivate(MODE); // Use mScanManager instead of piccManager
if (ret != 0) {
// Handle error
}
return ret;
}
public int activateEx(byte[] art) {
mScanManager.open(); // Call open before activation
byte[] atr = new byte[32];
int ret = mScanManager.activateEx(atr); // Use mScanManager instead of piccManager
if (ret != 0) {
// Handle error
}
return ret;
}
public int apduTransmit(byte[] cmd, int cmdLen, byte[] rsp, byte[] sw) {
// Implementation
return 0; // Placeholder return
}
public int apduTransmit(byte[] cmd, int cmdLen, byte[] rsp, int crc, int speed) {
// Implementation
return 0; // Placeholder return
}
public int apduTransmitFelica(byte[] cmd, int cmdLen, byte[] rsp) {
// Implementation
return 0; // Placeholder return
}
public void SetTimeOutFelica(int timeOut) {
// Implementation
}
public int enableRATS(byte value) {
// Implementation
return 0; // Placeholder return
}
public String getVersion() {
// Implementation
return ""; // Placeholder return
}
}
Код: Выделить всё
public class MainActivity extends FlutterActivity {
private static final String CHANNEL = "com.example.mobileapp/pic";
private MyPiccManager myPiccManager; // Declare MyPiccManager
@Override
public void configureFlutterEngine(FlutterEngine flutterEngine) {
super.configureFlutterEngine(flutterEngine);
new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(), CHANNEL)
.setMethodCallHandler(
new MethodChannel.MethodCallHandler() {
@Override
public void onMethodCall(MethodCall call, MethodChannel.Result result) {
if (myPiccManager == null) {
myPiccManager = new MyPiccManager(getApplicationContext());
}
switch (call.method) {
case "open":
result.success(myPiccManager.open());
break;
case "close":
result.success(myPiccManager.close());
break;
case "activate":
result.success(myPiccManager.activate());
break;
case "deactivate":
int mode = call.argument("mode");
result.success(myPiccManager.deactivate((byte) mode));
break;
case "activateEx":
List atrList = call.argument("atr");
byte[] atr = new byte[32];
for (int i = 0; i < atrList.size(); i++) {
atr[i] = atrList.get(i).byteValue();
}
result.success(myPiccManager.activateEx(atr));
break;
default:
result.notImplemented();
break;
}
}
}
);
}
}
Однако при попытке я сталкиваюсь со следующей ошибкой для инициализации RFID-сканера:
W/vo_rfid_scanne(10416): Landroid/device/PiccReaderNative; не удалось
инициализация: java.lang.UnsatisfiedLinkError: ошибка dlopen:
библиотека "libpicc_jni.so" не найдена
Похоже приложению не удается найти или загрузить файл libpicc_jni.so,
который необходим для доступа к собственным функциям считывателя RFID. Я включил библиотеку Urovo в свой проект, но эта ошибка сохраняется.
Кто-нибудь успешно интегрировал функцию RFID-сканирования Urovo с Flutter или сталкивался с подобными проблемами? Будем очень признательны за любые рекомендации по устранению ошибки libpicc_jni.so not Found.
Подробнее здесь: https://stackoverflow.com/questions/790 ... o-not-foun
Мобильная версия