Difference between NetworkInfo.isRoaming() and TelephonyManager.isNetworkRoaming()
Asked Answered
G

1

6

I'm trying to detect wether the device is roaming or not in my app and I've found these two methods:

Is there an essential difference between them or can I just choose one?

Godown answered 30/8, 2011 at 14:9 Comment(0)
Y
4

I think TelephonyManager.isNetworkRoaming()is 2G-related, whether NetworkInfo.isRoaming() is 3G-related - setting data-roaming on/off is a distinct option in the android-settings, so if it's off you still may get truefor GSM (TelephonyManager.isNetworkRoaming())

Yahairayahata answered 30/8, 2011 at 14:24 Comment(4)
I'm not sure to get your answer. In my settings, I have only one check field ro allow on not Data Roaming. I've seen the field 'Use only 2G networks' but I don't really see the link with my question.Godown
Sorry my answer might be a bit confusing. If the user is data roaming, that only mean he's using a service different from the one he applied to, right? 2G or 3G wouldn't make any difference then.Godown
well, if you're outside your home country and you turn on the phone it will automatically establish a GSM connection to the roaming partner network -> TelephonyManager.isNetworkRoaming() will return true. If data roaming is disabled or 'use only 2g' is enabled NetworkInfo.isRoaming() will return false, because no data connection is established. If you switch data services on NetworkInfo.isRoaming() will return true as well, since now both (GSM and data connection) are established and in roaming modeYahairayahata
Ok I see now. That makes sense. Since I have no way to test that, I'm going to wait for a couple of hours to validate that answer. If someone could confirm this explanation, that would be great. Thanks!Godown

© 2022 - 2024 — McMap. All rights reserved.