List of usage examples for android.hardware.usb UsbManager ACTION_USB_ACCESSORY_ATTACHED
String ACTION_USB_ACCESSORY_ATTACHED
To view the source code for android.hardware.usb UsbManager ACTION_USB_ACCESSORY_ATTACHED.
Click Source Link
From source file:me.spadival.podmode.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { String action = this.getIntent().getAction(); if (action == null) action = ""; if (!action.equals(UsbManager.ACTION_USB_DEVICE_ATTACHED) && !action.equals(UsbManager.ACTION_USB_ACCESSORY_ATTACHED)) { this.setTheme(android.R.style.Theme_Holo); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); IntentFilter usbFilter = new IntentFilter(); usbFilter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED); usbFilter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED); registerReceiver(mUsbReceiver, usbFilter); LocalBroadcastManager bManager = LocalBroadcastManager.getInstance(this); IntentFilter playFilter = new IntentFilter(); playFilter.addAction(BANNER);//from ww w .ja va 2s .c om playFilter.addAction(CLOSE); bManager.registerReceiver(mPlayReceiver, playFilter); mSongText = (TextView) findViewById(R.id.tvPodSongName); mProcessText = (TextView) findViewById(R.id.tvPodProcess); mAppIcon = (ImageView) findViewById(R.id.ivAppIcon); Intent serviceIntent = new Intent(this, PodModeService.class); startService(serviceIntent); } else { super.onCreate(savedInstanceState); mStartViaUSB = true; Intent serviceIntent = new Intent("me.spadival.podmode.PodModeService"); startService(serviceIntent); finish(); // If started via USB insert, this activity is done // here - // don't want the view coming in the way.. } }
From source file:com.google.android.DemoKit.DemoKitActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); String action = intent.getAction(); if (action.equals(UsbManager.ACTION_USB_ACCESSORY_ATTACHED)) { try {//from w w w .ja v a2 s . c o m mAccessoryController.send(Message.obtain(null, UsbMessages.ACCESSORY_ATTACHED, 0, 0)); } catch (RemoteException e) { } ; } }