安卓:强制要发送的数据通过无线电VS无线网络 [英] Android: Force data to be sent over radio vs WiFi

查看:123
本文介绍了安卓:强制要发送的数据通过无线电VS无线网络的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能迫使一个Android应用程序只使用移动无线连接(3G / 4G /等),禁止使用的WiFi?

Is it possible to force an Android application to use only the mobile radio connection (3g/4g/etc), disallowing the use of WiFi?

我想,我想用一个HIPRI连接:(例如:WIFI打开,使用HIPRI 3G): 的http://groups.google.com/group/android-developers/browse_thread/thread/d41f85505484d29b

I think I want to use a HIPRI connection: (ex: WIFI turned on, use HIPRI 3G): http://groups.google.com/group/android-developers/browse_thread/thread/d41f85505484d29b

推荐答案

我不相信你可以逼没有明确关闭Wi-Fi无线电暂时连接路径(不推荐)。但是,你可以尝试在你希望这种情况发生期间设置网络preference:

I don't believe you can "force" the connection path without explicitly turning off the Wi-Fi radio temporarily (not recommended). However, you could try setting the network preference during the period you want this to occur:

ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
//Prefer mobile over wifi
cm.setNetworkPreference(ConnectivityManager.TYPE_MOBILE);

//Do your work

//Remove your preference
cm.setNetworkPreference(ConnectivityManager.DEFAULT_NETWORK_PREFERENCE);

希望帮助!

这篇关于安卓:强制要发送的数据通过无线电VS无线网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆