Skip to content

Commit

Permalink
Fixed UnsatisfiedLinkError when initializing the HIDDeviceManager in …
Browse files Browse the repository at this point in the history
…some cases
  • Loading branch information
slouken committed Oct 1, 2018
1 parent 6e35e42 commit 679d355
Showing 1 changed file with 13 additions and 1 deletion.
Expand Up @@ -80,6 +80,14 @@ public void onReceive(Context context, Intent intent) {
public HIDDeviceManager(Context context) {
mContext = context;

// Make sure we have the HIDAPI library loaded with the native functions
try {
System.loadLibrary("hidapi");
} catch (Exception e) {
Log.w(TAG, "Couldn't load hidapi: " + e.toString());
return;
}

HIDDeviceRegisterCallback(this);

mSharedPreferences = mContext.getSharedPreferences("hidapi", Context.MODE_PRIVATE);
Expand Down Expand Up @@ -180,7 +188,11 @@ UsbManager getUSBManager() {
}

protected void shutdownUSB() {
mContext.unregisterReceiver(mUsbBroadcast);
try {
mContext.unregisterReceiver(mUsbBroadcast);
} catch (Exception e) {
// We may not have registered, that's okay
}
}

protected boolean isHIDDeviceUSB(UsbDevice usbDevice) {
Expand Down

0 comments on commit 679d355

Please sign in to comment.