# APDE USB / OTG communication

**URL:** <https://discourse.processing.org/t/apde-usb-otg-communication/30114>\
**Category:** Processing for Android\
**Created:** [May 16, 2021, 12:13am UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114 "2021-05-16T00:13:07Z")\
**Posts on this page:** 20\
**Page:** 5

<div class="post-metadata">

**Author:** ![ZENAR57](https://avatars.discourse-cdn.com/v4/letter/z/a698b9/32.png) [@ZENAR57](https://discourse.processing.org/u/ZENAR57)\
**Post date:** [May 21, 2021, 10:57pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/81 "2021-05-21T22:57:06Z")

</div>

> [@jafal](#):
>
> what run with me using Android mode

Do you use a computer?

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [May 21, 2021, 10:58pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/82 "2021-05-21T22:58:06Z")

</div>

Android mode means yes

---

<div class="post-metadata">

**Author:** ![ZENAR57](https://avatars.discourse-cdn.com/v4/letter/z/a698b9/32.png) [@ZENAR57](https://discourse.processing.org/u/ZENAR57)\
**Post date:** [May 21, 2021, 11:00pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/83 "2021-05-21T23:00:43Z")

</div>

But that’s not how we agreed! We agreed not to touch the computer! And you advised me libraries that I can never install, because they are only for the computer.

---

<div class="post-metadata">

**Author:** ![ZENAR57](https://avatars.discourse-cdn.com/v4/letter/z/a698b9/32.png) [@ZENAR57](https://discourse.processing.org/u/ZENAR57)\
**Post date:** [May 21, 2021, 11:07pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/84 "2021-05-21T23:07:14Z")

</div>

the archive must have a “libraries” directory, which must contain the core library files with the .jar extension.

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [May 21, 2021, 11:08pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/85 "2021-05-21T23:08:00Z")

</div>

> [@ZENAR57](#):
>
> But that’s not how we agreed! We agreed not to touch the computer! And you advise me libraries that I can never install, because they are only for the computer.

i said that i am going to try APDE after i run on pc did not have chance yet to try

now you reached compiled sketch what you did ?

---

<div class="post-metadata">

**Author:** ![ZENAR57](https://avatars.discourse-cdn.com/v4/letter/z/a698b9/32.png) [@ZENAR57](https://discourse.processing.org/u/ZENAR57)\
**Post date:** [May 21, 2021, 11:14pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/86 "2021-05-21T23:14:21Z")

</div>

I used  
1)APDE 5.1alpha  
2)write programs and copy to scethbook folde  
3)res/xml/device\_filter.xml (in users folde)  
4) compiled program.  
5) extracted apk, decompile apk  
6) change manifest  
7) compiled apk  
8)install modified apk

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [May 21, 2021, 11:17pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/87 "2021-05-21T23:17:32Z")

</div>

post this file

1. change manifest

---

<div class="post-metadata">

**Author:** ![ZENAR57](https://avatars.discourse-cdn.com/v4/letter/z/a698b9/32.png) [@ZENAR57](https://discourse.processing.org/u/ZENAR57)\
**Post date:** [May 21, 2021, 11:20pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/88 "2021-05-21T23:20:28Z")

</div>

Yes.  
ask.  
.  
.  
. I can make a video.

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [May 21, 2021, 11:21pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/89 "2021-05-21T23:21:57Z")

</div>

> [@ZENAR57](#):
>
> I can make a video.

just post it to see the file

---

<div class="post-metadata">

**Author:** ![ZENAR57](https://avatars.discourse-cdn.com/v4/letter/z/a698b9/32.png) [@ZENAR57](https://discourse.processing.org/u/ZENAR57)\
**Post date:** [May 21, 2021, 11:24pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/90 "2021-05-21T23:24:18Z")

</div>

![Screenshot_20210522_022314_com.gmail.heagoo.apkeditor.pro](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/d1bb0a46b54da47b16645a937e467f147c2ba0b7.jpeg)

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [May 21, 2021, 11:29pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/91 "2021-05-21T23:29:59Z")

</div>

can you post it as code using \</\>

---

<div class="post-metadata">

**Author:** ![ZENAR57](https://avatars.discourse-cdn.com/v4/letter/z/a698b9/32.png) [@ZENAR57](https://discourse.processing.org/u/ZENAR57)\
**Post date:** [May 21, 2021, 11:32pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/92 "2021-05-21T23:32:43Z")

</div>

Please

```auto
<?xml version="1.0" encoding="utf-8" ?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="processing.test.serial4" platformBuildVersionCode="27" platformBuildVersionName="8.1.0">
	<uses-sdk xmlns:android="http://schemas.android.com/apk/res/android" android:minSdkVersion="17" android:targetSdkVersion="17" />
	<application xmlns:android="http://schemas.android.com/apk/res/android" android:icon="@drawable/icon" android:label="serial4">
		<activity android:name=".MainActivity" android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
			<intent-filter>
				<action android:name="android.intent.action.MAIN" />
				<category android:name="android.intent.category.LAUNCHER" />
				<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
			</intent-filter>
			<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" android:resource="@xml/device_filter" />
		</activity>
	</application>
</manifest>

```

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [May 21, 2021, 11:36pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/93 "2021-05-21T23:36:16Z")

</div>

is the file in root sketch folder ?

---

<div class="post-metadata">

**Author:** ![ZENAR57](https://avatars.discourse-cdn.com/v4/letter/z/a698b9/32.png) [@ZENAR57](https://discourse.processing.org/u/ZENAR57)\
**Post date:** [May 21, 2021, 11:41pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/94 "2021-05-21T23:41:44Z")

</div>

???  
Manifest file?  
why are you asking? there are already two of them alike in one folder. but i modified and installed scetch from somewhere else!

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [May 21, 2021, 11:45pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/95 "2021-05-21T23:45:13Z")

</div>

see if this compile with you

or try to compile it same way you did

```auto
//////////////////////////////////////////////////////////
//
// supersimple application which sends 1 0 1 0 (toggle)
// after each mouse click to the serial
//
//
// basic infos
// ===========
// https://github.com/mik3y/usb-serial-for-android
// Lib for android > 3.1 to use the USB interface in host mode (OTG)
// https://github.com/inventit/processing-android-serial
// Processing wrapper for the usb-serial-for-android lib
//
import com.yourinventit.processing.android.serial.*;

Serial SerialPort;
boolean Toggle;

void setup()    
{
  println(Serial.list(this));
  
  // this simple initialisation works only when one Serial consumer (e.g. an Arduino)
  // is connected. Serial.list provides a list with all Usb Serial devices attached
  // to this machine.
  SerialPort = new Serial(this, Serial.list(this)[0], 9600);
}

void draw()
{

}

void mousePressed() {
  Toggle = !Toggle;
  SerialPort.write( Toggle?"1":"0");
}

```

---

<div class="post-metadata">

**Author:** ![ZENAR57](https://avatars.discourse-cdn.com/v4/letter/z/a698b9/32.png) [@ZENAR57](https://discourse.processing.org/u/ZENAR57)\
**Post date:** [May 21, 2021, 11:48pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/96 "2021-05-21T23:48:38Z")

</div>

And which library to use? My? Others libraries of the comments are not installed, they are for computers!

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [May 21, 2021, 11:49pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/97 "2021-05-21T23:49:44Z")

</div>

the same one gives you this

 ![Screenshot_20210521_191432](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/ac5d194bc059990e28eb360781efecb10da3c8f4.jpeg)

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [May 21, 2021, 11:52pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/98 "2021-05-21T23:52:41Z")

</div>

this is working sketch

 ![Untitled](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/1/17976f0ea1c65b784674a5fc5d8718f9ecf95b65.jpeg)

---

<div class="post-metadata">

**Author:** ![ZENAR57](https://avatars.discourse-cdn.com/v4/letter/z/a698b9/32.png) [@ZENAR57](https://discourse.processing.org/u/ZENAR57)\
**Post date:** [May 21, 2021, 11:54pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/99 "2021-05-21T23:54:14Z")

</div>

Yes.  
I going.  
xxxxxxxxxxxxxxxxxxxxxxxxx

---

<div class="post-metadata">

**Author:** ![ZENAR57](https://avatars.discourse-cdn.com/v4/letter/z/a698b9/32.png) [@ZENAR57](https://discourse.processing.org/u/ZENAR57)\
**Post date:** [May 22, 2021, 12:01am UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/100 "2021-05-22T00:01:44Z")

</div>

inserted in one line, had to separate.  
Compiled the axis with no errors.  
but I not runing. it needs to be edited manifest! Continue?

[Previous page](https://discourse.processing.org/t/apde-usb-otg-communication/30114.md?page=4)

[Next page](https://discourse.processing.org/t/apde-usb-otg-communication/30114.md?page=6)
