As far as I know, the hardware/os decides which network will execute my app's requests, if both MobileData and WiFi networks are on, judging by this answer here: In Android, if both mobile and wifi networks are available, which one is used?.
This comment here says the same: https://android.stackexchange.com/questions/57710/how-do-you-determine-if-youre-using-wi-fi-or-lte#comment79856_57919
Can I instruct my network requests to only use WiFi, even when both WiFi and Data networks are available?
I am trying to solve this problem: The user has a setting that says "Do NOT use mobile data" which should forbid the app from sending network requests if Mobile Data is on (which can be subject of charges).
However, if that answer to my linked question is really true, that means that if both Mobile and WiFi are on, WiFi is not guaranteed to take precedence over Mobile and Mobile will still perform requests and the user will be charged.
At the moment in my code I check what type of network connection is available, and if that setting is on ("Do NOT use mobile data") I only perform requests if WiFi is ON and MobileData is OFF. If both are ON, I do NOT perform requests in order to protect the user from being charged.
However, it is difficult explaining this to my colleagues, so I am thinking - is it possible to instruct my app's network requests to be only performed via WiFi, even if both WiFi and MobileData are ON simultaneously?
PS: I just found an exactly opposite opinion, stating that if both MobileData and WiFi are on, all requests will be performed via WiFi: https://android.stackexchange.com/questions/17774/how-can-i-tell-that-my-phone-uses-the-wi-fi-connection-for-data-traffic
I am not sure who to believe.
EDIT: I found some code snippets that are supposed to do this job: Send request over Mobile data when WIFI is ON.(Android L) but I don't know how to test them and if they really do what I want to do here.
How to use data connection instead of WIFI when both are enabled?