My app sometimes needs to connect via mobile data in order to work. I know there are apps that can make a certain app use only mobile data and I know how I can turn off and on the wifi with my app. But is there a way to tell my app to use mobile connection from now on and at another point remove this restriction?
Asked
Active
Viewed 1,300 times
1 Answers
0
You can't explicitly force the communications channel on a per-app basis (you can request to use a preferred mode via ConnectivityManager.setNetworkPreference(...)
, but that's not "forcing").
// and to be sure:
ConnectivityManager.setNetworkPreference(ConnectivityManager.TYPE_MOBILE);

Pitty
- 1,907
- 5
- 16
- 34
-
what do u need manager for? your first line doesn't do anything, does it? – Ginso Apr 12 '16 at 13:09
-
Yes I edited code but at that time you have to turn off wifi – Pitty Apr 12 '16 at 13:12