# How to connect a USB CDC device

**URL:** https://forum.magicleap.cloud/t/how-to-connect-a-usb-cdc-device/3486
**Category:** Native Development
**Tags:** peripherals
**Created:** [May 1, 2024, 3:47pm UTC](https://forum.magicleap.cloud/t/how-to-connect-a-usb-cdc-device/3486 "2024-05-01T15:47:37Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![dhedin](https://avatars.discourse-cdn.com/v4/letter/d/d07c76/32.png) [@dhedin](https://forum.magicleap.cloud/u/dhedin)
#### Post date: [May 1, 2024, 3:47pm UTC](https://forum.magicleap.cloud/t/how-to-connect-a-usb-cdc-device/3486/1 "2024-05-01T15:47:37Z")

</div>

Give us as much detail as possible regarding the issue you're experiencing.

**ML2 OS version** : 1.5  
**MLSDK version** : 1.5  
**Host OS** : Windows

I need to connect a USB CDC device that streams data to the Magic Leap 2. I know this can be done using Android in Java but I need to integrate it with a Native C++ application. Can this be written in Java and then integrated using the JNI interface?

---

<div class="post-metadata">

### Author: ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)
#### Post date: [May 1, 2024, 4:39pm UTC](https://forum.magicleap.cloud/t/how-to-connect-a-usb-cdc-device/3486/2 "2024-05-01T16:39:40Z")

</div>

To connect your USB CDC device to a C++ Android app, you'll need a two-pronged approach. First, use Java and the Android USB API to manage device detection, permissions, and the raw data exchange. Define native methods in Java that will "bridge" the connection to your C++ code. This is where you'll implement data processing and the integration with your core C++ application logic.

- **Android USB API:** Familiarize yourself with the Android USB API: [USB host overview &nbsp;|&nbsp; Connectivity &nbsp;|&nbsp; Android Developers](https://developer.android.com/guide/topics/connectivity/usb/host)
- **JNI Resources:** Refer to the JNI documentation for detailed guidance: [JNI APIs and Developer Guides](https://docs.oracle.com/javase/8/docs/technotes/guides/jni/)
