Back to project page bard-droid.
The source code is released under:
GNU General Public License
If you think the Android project bard-droid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package in.co.praveenkumar.bard.activities; /*from w w w . jav a2 s . c om*/ import com.android.future.usb.UsbAccessory; import com.android.future.usb.UsbManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log; import android.widget.Toast; public class BardReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (UsbManager.ACTION_USB_ACCESSORY_ATTACHED.equals(action)) { UsbAccessory accessory = UsbManager.getAccessory(intent); Log.d("USB", "Attached!"); Toast.makeText(context, "Attached", Toast.LENGTH_LONG).show(); if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) { // openAccessory(accessory); Log.d("TestUSB", "Open Accessory"); Toast.makeText(context, "Open Accessory", Toast.LENGTH_LONG) .show(); } else { Log.d("USB", "permission denied for accessory " + accessory); } } else if (UsbManager.ACTION_USB_ACCESSORY_DETACHED.equals(action)) { //UsbAccessory accessory = UsbManager.getAccessory(intent); Toast.makeText(context, "Detached", Toast.LENGTH_LONG).show(); } } }