1. Are you ready for the Galaxy S20? Here is everything we know so far!

Android USB Communication

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

  1. aldocampos

    aldocampos Lurker
    Thread Starter

    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
     



    1. Download the Forums for Android™ app!


      Download

       
  2. myrecek

    myrecek Newbie

    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.
     
Loading...
Similar Threads - Android USB Communication
  1. xarzu
    Replies:
    0
    Views:
    690
  2. MrOldCrypto
    Replies:
    7
    Views:
    754
  3. hardik garg
    Replies:
    1
    Views:
    939
  4. medusa193
    Replies:
    10
    Views:
    1,997
  5. zBernie
    Replies:
    3
    Views:
    1,529
  6. David Labrecque
    Replies:
    3
    Views:
    3,500
  7. mortpiedra
    Replies:
    1
    Views:
    835
  8. Little_Ad 1059
    Replies:
    1
    Views:
    1,080
  9. AlexEv
    Replies:
    0
    Views:
    6,269
  10. Hajji Abdoullah
    Replies:
    5
    Views:
    973

Share This Page

Loading...