mik3y / usb-serial-for-android

Android USB host serial driver library for CDC, FTDI, Arduino and other devices.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

getSystemService's parameters have changed

jhy-dev opened this issue · comments

Hi, I have been trying to use the sample code in the read me that you have written, but it seems not to work for me. i have googled few hours to figure out the issue..

below is the kotlin code that i tried for getting usb manager

import android.hardware.usb.UsbManager
import com.hoho.android.usbserial.driver.UsbSerialPort
import com.hoho.android.usbserial.driver.UsbSerialProber

val manager = getSystemService(Context.USB_SERVICE) as UsbManager?

below is the required parameters for getSystemService

public static <T> T getSystemService(@NonNull Context context, @NonNull Class<T> serviceClass) {
        if (Build.VERSION.SDK_INT >= 23) {
            return Api23Impl.getSystemService(context, serviceClass);
        }

        String serviceName = getSystemServiceName(context, serviceClass);
        return serviceName != null ? (T) context.getSystemService(serviceName) : null;
    }