@Dave: I have a serious issue with this nice feature. Though I thought I did enable automatic wifi at the ide, the ide-wifi is not enabled or, at least, has not enough time to initiate wifi. The app ("MyAppName") starts all over when I try to bring DS to foreground, so I am not able to connect to the ide and do anything with it.
The whole system is blocked by the "MyAppName" app and I can do nothing but use the app or perfom system settings. Thats pretty good for the fully tested end version, when development is done ... but thats not the case now. Stopping the app shows DS for a short time then immediately the app is restarted
( Android 5.1.1 on Samsung Note3 Neo used, DS version is 1.80X - X for testing SMS - due to problems with 2.06, I have premium account )
I got out of this unusable situation only by deinstalling/reinstalling DS.
Then again, after definitely having set the Auto-Wifi mode and tested its coming up on DS start - Wifi is set automatically after a few seconds - I reproduced the behavior written above by starting the app ('your' 3 lines coding implemented at the end of the OnStart function) out of the IDE (PC connected to DS via WiFi): Whenever I 'stop' the app by back-key (put it to background), DS pops up, showing WiFi as obviously off for about 1 second then the app comes to foreground again. Status of IDE (PC browser) shows "Disconnected", no chance to connect and do any development.
When I use the system task switcher machanism, the behavior is identic.
(It might be essential that the program I use has more than 1 program files, but I did not test the simple case.)
So, I can escape this situation by deinstalling/reinstalling DS as a workaround, but unfortunately, the mechanism itself can't be used as proposed by you, Dave. Or did I do something wrong?
Best regards
Jo