是否有可能以编程方式通过移动数据路由请求,即使wifi已打开并连接到互联网?
我的应用程序需要拨打运营商提供的服务,该服务仅通过移动数据提供,我认为要求关闭无线网络并不是用户友好的 .
看看https://developer.android.com/reference/android/net/ConnectivityManager.html
具体来说,它有一个功能,可以让你做你想要的 .
5 Provide an API that allows applications to request and select networks for their data traffic
您请求网络,然后setDefaultNetwork(23之前的API)或使用bindProcessToNetwork for API> = 23 .
你可能想要一个具有int TRANSPORT_CELLULAR功能的网络(https://developer.android.com/reference/android/net/NetworkCapabilities.html)
1 回答
看看https://developer.android.com/reference/android/net/ConnectivityManager.html
具体来说,它有一个功能,可以让你做你想要的 .
您请求网络,然后setDefaultNetwork(23之前的API)或使用bindProcessToNetwork for API> = 23 .
你可能想要一个具有int TRANSPORT_CELLULAR功能的网络(https://developer.android.com/reference/android/net/NetworkCapabilities.html)