FrontPanel Android

FrontPanel Android support is currently in beta as of FrontPanel 5.2.

Opening a Device

Use of FrontPanel on Android requires the use of the Android USB support libraries, listed below:

import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbDeviceConnection;
import android.hardware.usb.UsbManager;Code language: CSS (css)

The okCFrontPanelManager and okCFrontPanelDevices classes are not available on Android. The only supported method of opening a device on Android is obtaining a file descriptor for the FrontPanel device from Android then passing the file descriptor to the okCFrontPanel constructor. Note that this specialized okCFrontPanel constructor taking a file descriptor is only available on Android.

mActionUSBPermissionReceiver = new BroadcastReceiver() {
    public void onReceive(Context context, Intent intent) {
        UsbDevice device = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);

        if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
            UsbManager usbManager = (UsbManager)context.getSystemService(Context.USB_SERVICE);
            UsbDeviceConnection conn = usbManager.openDevice(device);
            if (conn == null) {
                Toast.makeText(context, "Opening the device failed", Toast.LENGTH_LONG)
                        .show();
                return;
            }

            int fd = conn.getFileDescriptor();

            mFrontPanel = new okCFrontPanel(fd);
        } else {
            mDeviceAvailable = false;

            Log.d("FrontPanel", "Permission denied for device " + device);
        }
    }
};
registerReceiver(mActionUSBPermissionReceiver, new IntentFilter(ACTION_USB_PERMISSION));Code language: JavaScript (javascript)

Device Support

An Android device used to host a FrontPanel device over USB must support USB host, whether through a dedicated USB host port or through USB-OTG with an appropriate adapter.

When using FrontPanel devices that draw power from the USB connection, it is important to ensure that the Android device is capable of sourcing the necessary power over USB. Not all Android devices will provide a notification for overcurrent conditions.