requestRouteToHost(int networkType, int hostAddress)
此方法在 API 级别 21 中已弃用。已弃用以支持
请求网络(网络请求,网络回调)
bindProcessToNetwork(Network) 和getSocketFactory()
API。在M及以上版本中,此方法不受支持,如果调用,将抛出 UnsupportedOperationException。Android 文档参考
Android 官方网站没有任何替代requestRouteToHost(int networkType, int hostAddress)的实现
我谷歌发现了这个
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ConnectivityManager connMgr = (ConnectivityManager) this
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkRequest.Builder builder = new NetworkRequest.Builder();
//what Capability i have to add for
**requestRouteToHost(int networkType, int hostAddress)** implementation.
builder.addCapability(NetworkCapabilities.NET_CAPABILITY_MMS);
builder.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
NetworkRequest networkRequest = builder.build();
connMgr.requestNetwork(networkRequest, new ConnectivityManager.NetworkCallback() {
@Override
public void onAvailable(Network network) {
super.onAvailable(network);
// sendNormalMms();
try {
int y = Integer.parseInt(apns.get(0).MMSPort);
HttpUtils.httpConnection(mContext, 4444L,
apns.get(0).MMSCenterUrl, bytesToSend,
HttpUtils.HTTP_POST_METHOD,
!TextUtils.isEmpty(apns.get(0).MMSProxy),
apns.get(0).MMSProxy, y);
} catch (Exception e) {
}
}
});
问题:连接未准备好发送彩信光标未启动OnAvalabile();
这是准备发送彩信的权利吗?