OnMidiDeviceDetachedListener method doesn't called at the screen rotation
kshoji opened this issue · comments
The execution of handler on MidiDeviceConnectionWatcher
is blocked while the screen rotating.
After the new Activity's onCreate
being called, the handler will be executed.
But the original Activity is already destroyed, so the original Activity can't receive detaching events.
Hi Kaoru
I’d recommend to put all the driver setup into some separate class, a singleton, or all ‘static’ is fine too.
Then initialize that class on startup and destroy everything inside when the app gets terminated.
Having the midi setup in an activity is, from the software design point of view, not a very good practice, since there’s no guarantee how long an activity will live. Screen rotation is just one example.
Von: Kaoru Shoji [mailto:notifications@github.com]
Gesendet: Freitag, 8. Mai 2015 05:24
An: kshoji/USB-MIDI-Driver
Betreff: [USB-MIDI-Driver] OnMidiDeviceDetachedListener method doesn't called at the screen rotation (#38)
The execution of handler on MidiDeviceConnectionWatcher is blocked while the screen rotating.
After the new Activity's onCreate being called, the handler will be executed.
But the original Activity is already destroyed, so the original Activity can't receive detaching events.
—
Reply to this email directly or view it on GitHub #38 . https://github.com/notifications/beacon/AF5BLIYAZZW8dxFolc9snBIQe6niLO8eks5oHCPegaJpZM4ETQts.gif
Hi,
I also think the Activity should not hold MIDI device instances.
Their instances should belong at Application, Service or something static object.
The sample code had written at long ago. It must be refined.
Ah, OK, didn’t know that.
Agree, storing it in a custom application class would be even better than using a regular singleton
Von: Kaoru Shoji [mailto:notifications@github.com]
Gesendet: Freitag, 8. Mai 2015 11:24
An: kshoji/USB-MIDI-Driver
Cc: planethcom
Betreff: Re: [USB-MIDI-Driver] OnMidiDeviceDetachedListener method doesn't called at the screen rotation (#38)
Hi,
I also think the Activity should not hold MIDI device instances.
Their instances should belong at Application, Service or something static object.
The sample code had written at long ago. It must be refined.
—
Reply to this email directly or view it on GitHub #38 (comment) . https://github.com/notifications/beacon/AF5BLAI93qe5ZgKzb_mFhSWmA9Zpzp0Jks5oHHg8gaJpZM4ETQts.gif