1. Check out our companion app, Forums for Android! Download from Google Play

Android USB Communication

Discussion in 'Application Development' started by aldocampos, Dec 17, 2012.

  1. aldocampos

    aldocampos New Member
    Thread Starter
    5

    Dec 17, 2012
    1
    0
    5
    I am new to android programming and I am trying to set a connection with the android as a host. I have included the following imports:
    import android.content.Context;
    import android.hardware.usb.UsbDevice;
    import android.hardware.usb.UsbManager;
    import android.hardware.usb.UsbInterface;
    import android.hardware.usb.UsbEndpoint;
    import android.hardware.usb.UsbDeviceConnection;
    import android.content.Context;

    My problem is when I use this code :m_usbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
    The eclipse editor shows a message saying that getSystemService(String) is undefined for the type CPrinterCommands(The class that I am using). Quick fix gives as a solution to create a method called getSystemService, however I can
     

    Advertisement

  2. myrecek

    myrecek Active Member
    16

    May 10, 2012
    29
    2
    16
    getSystemService is a method in class Activity. Your CPrinterCommands class probably doesn't extend Activity so you have to pass an Activity object somehow into your class/method.
     

Share This Page

Loading...