Hey guys, I’ve added a number of features to my game lately that require internet connectivity: ads, cloud save, IAP, and google’s game network among them.
This means my game needs to intelligently handle situations like being opened with an internet connection, and then taken into the subway where there is no internet connection. Or the reverse: started offline, and taken out of the subway.
And as far as I can tell, I need to wrap each of those libraries in a network check, because if I don’t they can do stupid things like take 30 seconds to timeout from a blocking network call. Literally, my game takes 30 seconds to get past the splash screen right now if there’s no net connection, and it’s instantaneous with a connection. I’m still tracking down the culprit, and if you have any tips on tracking this sort of thing down please let me know. Maybe somewhere in Android Debug Monitor?
Anyway, because Android doesn’t support network.canDetectNetworkStatusChanges I’ve had to implement a sketchy version using sockets (calling home to google.com), which blocks execution of the program itself, but at least I can control the timeout. The alternative seems to be an endless loop of asynchronous network.request() calls every n seconds pinging for network connectivity.
How have you guys tackled this problem?