Is there any way to find out what's blocking my app's internet access?

3.1k views Asked by At

I have several users reporting that the app can't get an internet connection, but they swear that they didn't enable any data restrictions for the app. This is only happening on Android 4.2.2, and I've had the users verify that they do have internet access on their phones, and they can manually connect to the URL in the browser.

Edit: The app has a regularly scheduled background internet download (an XML file), but also has a manual refresh button in the app. The background refresh is failing for all users, but the manual refresh button is working for at least one user. And the URL in the browser that I had them test is exactly what the app does in the background.

So, what could possibly be blocking my app's internet connection? And is there any way to determine at runtime if there are any data restrictions for my app (or globally on the device)?

1

There are 1 answers

4
CommonsWare On BEST ANSWER

So, what could possibly be blocking my app's internet connection?

Android has a "restrict background data" option in some versions. You can find it in Settings > Data Usage > ... (overflow) > "Restrict background data".

Some manufacturers go further and block apps from running in the background, such as with SONY's STAMINA mode. Other manufacturers could have similar tweaks.

And is there any way to determine at runtime if there are any data restrictions for my app (or globally on the device)?

For Android's "restrict background data" option, getActiveNetworkInfo() on ConnectivityManager is supposed to report null when you are not allowed to do work in the background.

SONY has decided that adding a couple of lines of code to allow developers to find out if STAMINA Mode is activated is just too much typing, apparently.