ytai / ioio

Software, firmware and hardware of the IOIO - I/O for Android
Apache License 2.0
747 stars 355 forks source link

Android targetSdkVersion 13 doesn't connect to IOIO after display is rotated #146

Open jmkristian opened 5 years ago

jmkristian commented 5 years ago

For example, if IOIOSimpleApp is built with targetSdkVersion 13, it starts and displays changing input values, but after the display is rotated it displays only 0.0. When built with targetSdkVersion 12, it continues to display input values after the display is rotated.

To reproduce the problem, apply the attached patch and build with Android Studio. patch.txt

Here's an excerpt from logcat. logcat.txt

jmkristian commented 5 years ago

To work around the problem, I don't disconnect and reconnect when the display is rotated. That is, I wait until the app terminates before calling IOIOAndroidApplicationHelper.stop. Specifically, I made the IOIOAndroidApplicationHelper a member of a retained fragment, constructed it with wrapper = ContextWrapper(applicationContext) and call stop and destroy from that fragment's onDestroy method. For complete code, see https://github.com/jmkristian/IOIO-Scope version 1.4.

techboycr commented 3 years ago

Have you consider using IOIOActivity instead of IOIOLooperProvider?

The complexity of you app does not seams to grab any benefit from the architecture that you are using. The other solution, that I use for a project not long ago es to create a service and have it communicate with the mainActivity.

Hope this is useful.