Hello everybody,
here's the problem description.
I'm working on an app that communicates over a network. Sometimes, connection disappears (to save battery power), or sometimes when on startup app tries to establish connection WLAN is down. At the moment of trying to make a tcp connection phone (P1i) tries to establish WLAN connection. Sometimes it takes too long and I get a error in the app saying that connection isn't available, but if it tries to make connection once again it already works (because WLAN is connected). There's an option somewhere in phone setting that disables powering off network connection to preserve battery power, but it doesn't work. Connection still goes down after a long time it isn't used (app uses mostly udp).
So, the question is... how can I programmatically initiate wlan connection on startup? What I did is on startup I put some code that uses dns resolver to make a dns querry, which in turn makes a wlan connection. This solution is good enough, but how do I preserve wlan connection if app isn't used for long time? I may do the same dns query method every few minutes, but I don't like this method. It would be better if I could get a notification that wlan was disconnected, also get notification that phone went to sleep mode (keypad locked), so that I wouldn't try to keep connection up while phone isn't used, but when user unlocks it (again notification to the app) then I reinitiate connection (using dns querying or any other method).