List of usage examples for android.content Context USB_SERVICE
String USB_SERVICE
To view the source code for android.content Context USB_SERVICE.
Click Source Link
From source file:org.chromium.latency.walt.Connection.java
public Connection(Context context) { mContext = context;/*from w ww .ja va 2 s. c o m*/ mUsbManager = (UsbManager) mContext.getSystemService(Context.USB_SERVICE); mLogger = SimpleLogger.getInstance(context); mBroadcastManager = LocalBroadcastManager.getInstance(context); }
From source file:org.chromium.latency.walt.BaseUsbConnection.java
public BaseUsbConnection(Context context) { this.context = context; usbManager = (UsbManager) this.context.getSystemService(Context.USB_SERVICE); logger = SimpleLogger.getInstance(context); broadcastManager = LocalBroadcastManager.getInstance(context); }
From source file:com.swiftnav.piksidroid.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this.setupUI(); UsbManager mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE); PendingIntent mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0); IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION); registerReceiver(mUsbReceiver, filter); filter = new IntentFilter(UsbManager.ACTION_USB_DEVICE_DETACHED); registerReceiver(mUsbReceiverDisconnect, filter); HashMap<String, UsbDevice> deviceList = mUsbManager.getDeviceList(); for (UsbDevice device : deviceList.values()) { if ((device.getVendorId() == Utils.PIKSI_VID) && (device.getProductId() == Utils.PIKSI_PID)) if (!mUsbManager.hasPermission(device)) { mUsbManager.requestPermission(device, mPermissionIntent); } else { ((EditText) findViewById(R.id.console)).setText(""); piksiConnected(device);/*from w w w . jav a 2s.co m*/ } } }
From source file:com.egoclean.arm.ui.ArmActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE); mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0); IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION); filter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED); registerReceiver(mUsbReceiver, filter); outputController = new OutputController(this); setContentView(R.layout.main);//w w w .java 2s. c om ArmView armView = (ArmView) findViewById(R.id.arm_view); armView.setAngleListener(outputController); mNotConnected = findViewById(R.id.lnl_not_connected); if (mAccessory != null) { showControls(); } else { hideControls(); } }
From source file:com.android.settings.applications.ClearDefaultsPreference.java
public ClearDefaultsPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); setLayoutResource(R.layout.app_preferred_settings); mAppWidgetManager = AppWidgetManager.getInstance(context); mPm = context.getPackageManager();/* ww w . j ava 2s . c o m*/ IBinder b = ServiceManager.getService(Context.USB_SERVICE); mUsbManager = IUsbManager.Stub.asInterface(b); }
From source file:aws.apps.usbDeviceEnumerator.ui.usbinfo.AndroidUsbInfoFragment.java
@Override public void onAttach(final Context context) { super.onAttach(context); usbMan = (UsbManager) getContext().getSystemService(Context.USB_SERVICE); dataFetcher = new DataFetcher(new DataProviderCompanyInfo(context), new DataProviderUsbInfo(context), new DataProviderCompanyLogo(context)); }
From source file:com.googlecode.android_scripting.facade.USBHostSerialFacade.java
/** * constructor: {{{1// w ww . java 2s . c o m */ public USBHostSerialFacade(FacadeManager manager) { super(manager); mAndroidFacade = manager.getReceiver(AndroidFacade.class); mService = manager.getService(); mUsbManager = (UsbManager) mService.getSystemService(Context.USB_SERVICE); mReceiver = null; }
From source file:com.grupohqh.carservices.operator.ReadTagActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_read_tag); URL = getString(R.string.base_url) + getString(R.string.findcarid_url); if (getIntent().getExtras().containsKey("userId")) userId = getIntent().getExtras().getInt("userId"); rgSearchBy = (RadioGroup) findViewById(R.id.rgSearchBy); etTag = (EditText) findViewById(R.id.etTag); etLicensePlate = (EditText) findViewById(R.id.etLicensePlate); etSerialNumber = (EditText) findViewById(R.id.etSerialNumber); btnSearch = (Button) findViewById(R.id.btnSearch); viewTag = findViewById(R.id.viewTag); viewPlate = findViewById(R.id.viewPlate); viewSerial = findViewById(R.id.viewSerial); changeVisibility(rgSearchBy.getCheckedRadioButtonId()); rgSearchBy.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override/*w w w.j av a2s .com*/ public void onCheckedChanged(RadioGroup group, int checkedId) { changeVisibility(checkedId); } }); btnSearch.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (validate()) { new HttpAsyncTask().execute(URL); } } }); if (useMiniMe) { manager = (UsbManager) getSystemService(Context.USB_SERVICE); usbCommunication = UsbCommunication.newInstance(); IntentFilter filter = new IntentFilter(); filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED); // will intercept by system filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED); filter.addAction(ACTION_USB_PERMISSION); registerReceiver(usbReceiver, filter); etEpc = (EditText) findViewById(R.id.etEPC); btnRead = (Button) findViewById(R.id.btnReadTAG); txtStatus = (TextView) findViewById(R.id.txtStatus); btnRead.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { etEpc.setText(""); if (txtStatus.getText().toString().equals("conectado")) { readTag(); } else { Toast.makeText(getBaseContext(), "dispositivo " + txtStatus.getText(), Toast.LENGTH_LONG) .show(); } } }); } }
From source file:aws.apps.usbDeviceEnumerator.ui.main.MainActivity.java
/** * Called when the activity is first created. *///from w w w .j av a2s .c o m @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.act_main); mTabController = new TabController(this); mNavigation = new Navigation(this); mUsbManAndroid = (UsbManager) getSystemService(Context.USB_SERVICE); mUsbManagerLinux = new SysBusUsbManager(); mDbUsb = new DataProviderUsbInfo(this); mDbComp = new DataProviderCompanyInfo(this); mZipComp = new DataProviderCompanyLogo(this); mTabController.setup(new TabController.OnTabChangeListener() { @Override public void onTabChangeListener(String tag, TabViewHolder holder) { onTabChanged(tag, holder); } }); // Setup android list - tab1; mTabController.getHolderForTag(TabController.TAB_ANDROID_INFO).getList() .setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ((ListView) parent).setItemChecked(position, true); mNavigation.showAndroidUsbDeviceInfo(((TextView) view).getText().toString()); } }); // Setup linux list - tab2 mTabController.getHolderForTag(TabController.TAB_LINUX_INFO).getList() .setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ((ListView) parent).setItemChecked(position, true); mNavigation.showLinuxUsbDeviceInfo( mLinuxDeviceMap.get(((TextView) view).getText().toString())); } }); checkIfDbPresent(); refreshUsbDevices(); }
From source file:es.udc.robotcontrol.testapp.comunication.ConectorPlaca.java
@Override public void conectar(Context ctx, Intent intent) throws TransmisionErrorException { Log.i(Constantes.TAG_CONECTOR, "Conectando a [ " + intent.getAction() + " ]. modo - Host"); device = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); Log.i(Constantes.TAG_CONECTOR, "Conectando a [ " + device.getDeviceName() + " ]. modo - Host"); /* Get the USB manager from the requesting context */ this.manager = (UsbManager) ctx.getSystemService(Context.USB_SERVICE); conectar();/*from ww w . j a va 2 s .c o m*/ }