Android USB Communication


Last Updated:

  1. aldocampos

    aldocampos New Member This Topic's Starter

    Joined:
    Dec 17, 2012
    Messages:
    1
    Likes Received:
    0
    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

    Joined:
    May 10, 2012
    Messages:
    29
    Likes Received:
    2
    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...