ArthurVasseur / USB-Midi-Android-Plugin

A USB MIDI plugin for Android 6.0 and above
MIT License
9 stars 2 forks source link

Usb-Midi when Target API level is 31 #1

Closed Jonathan10 closed 1 year ago

Jonathan10 commented 1 year ago

When switching to Target API level 31 it stops working.

It seems that there are no events at all.

With Api level 29 it works well.

any ideas how to fix it ?

Thanks.

ArthurVasseur commented 1 year ago

Could you give me more details please ?

Radomiej commented 1 year ago

Hi,

Setting FLAG_MUTABLE or rebuild the aar library resolved a compatibility issue with newest Android versions in my case, but there still issue that after NoteOff event also coming NoteOn in the next packet.

PendingIntent permissionIntent = PendingIntent.getBroadcast(_context, 0, new Intent(USB_PERMISSION_ACTION), FLAG_MUTABLE);

Tested on Unity and Java

Radomiej commented 1 year ago

About above issue with NoteOn/NoteOff, adding break fix this problem: switch (CIN) { case 0x8: _midiCallback.NoteOff(byte2); break; case 0x9: if(byte3 == 0x00) { _midiCallback.NoteOff(byte2); } else{ _midiCallback.NoteOn(byte2, byte3); } }

ArthurVasseur commented 1 year ago

Hello,

I have fix the issue with your code in the last commit. But I didn't test it because I don't have my piano, can you test it for me ?

Radomiej commented 1 year ago

yes, this issue is already resolved, thanks! but I still need to update PendingIntent.FLAG_MUTABLE to make it working on API 33. and there also issue with gradle, which I've resolved by replace task clean with following code:

clean.doFirst { delete rootProject.buildDir }

ArthurVasseur commented 1 year ago

Commited ! 7ea827662a9ebf16173dc57bb01622066bb47fb0