I'm trying to figure out a strategy for my application, where I need to perform different network operations. My question is, whether calling ConnectivityManager.getActiveNetworkInfo() is considered a long-running and battery-draining operation and whether it's all right to call it often, or should I optimize my application's performance by applying another strategy? Thanks in advance.
I have used ConnectivityManager.getActiveNetworkInfo() in three apps so far. You might use a checkNetwork() method and call it to ensure you are in the correct state each time the user starts something that needs the network so that he or she can correct the situation. Beyond that, your error-handling might combine sleep() calls with network checks and connection management. This means using about 30-gazillion permissions. But it would be a reasonable way to do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With