The issue isn't related to your Wifi connection, it's related to the battery usage setting for the particular app. If you go to the device settings App Info for the particular app you'll see the "Battery usage" item. Tap on that & you can set either Unrestricted, Optimized or Restricted. The problem is, you can't change this setting in code. The only thing you can do is check the current setting using ActivityManager.isBackgroundRestricted() & then pop up a dialog asking the user to change it if it's not already set.
It's all part of Android's attempts to prolong battery life on devices...
- Colin.