开发者

Android - native sockets not removing 3G-sleep-mode on first attempt

开发者 https://www.devze.com 2023-04-12 14:21 出处:网络
I have a really annoying problem. What happens is I have an application which is using native sockets to send data over TCP.

I have a really annoying problem. What happens is I have an application which is using native sockets to send data over TCP. When I first launch my application and send data over the sockets, no开发者_如何学JAVAthing gets through. However if I then quit the process and restart it and then send again, it works. Same thing if I open the browser or something before starting my app for the first time after sleep mode.

How do I 'force' 3G to go out of sleep mode before I make the call to the native code?

EDIT: I have already tried with PowerManager.


Try calling startUsingNetworkFeature (int networkType, String feature) On a ConnectivityManager and wait for it to be available before you bind your sockets ect......

Android Documentation


I'd give the ConnectivityManager API requestRouteToHost(int networkType, int hostAddress) a try.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号