Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

New Forums: Nexus Player | Nexus 9
test: Reply
 
LinkBack Thread Tools
Old December 17th, 2012, 06:55 AM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Dec 2012
Posts: 1
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default Android USB Communication

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īt find why I would need to create a method, all the examples I found, none of them had a method getSystemService. Does anybody have a glue of what is wrong with my code??? Thanks

Advertisements
aldocampos is offline  
Reply With Quote
sponsored links
Old December 17th, 2012, 10:36 AM   #2 (permalink)
Junior Member
 
Join Date: May 2012
Posts: 27
 
Device(s): Nexus 7 (Android 4.2.1), Samsung Galaxy Mini (Android 2.3.6)
Carrier: Not Provided

Thanks: 1
Thanked 2 Times in 2 Posts
Default

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.
myrecek is offline  
Reply With Quote
Reply


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 04:55 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.