3

I checked my emulator (Genymotion) and it has internet. But, when I try to get location based on network, I get this exception: java.lang.IllegalArgumentException: provider doesn't exist: network

I also checked the connectivity in my code and it returns true:

private boolean isNetworkAvailable() {
    ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
    return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}

This question is not a duplicate of this because I know I can avoid the exception with a simple if. But, my question is why provider is not available while I have internet?

Community
  • 1
  • 1
Maedeh HM
  • 478
  • 7
  • 14

0 Answers0