作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
用于发送彩信的就绪设备在 Kitkat 中运行良好,但 Pro KitKat 版本 startUsingNetworkFeature 已弃用。
final int result = mConnMgr.startUsingNetworkFeature(
ConnectivityManager.TYPE_MOBILE, "enableMMS");
final ProgressDialog dialog =
ProgressDialog.show(mContext, "", getString(R.string.compose_thread_dailog_converting_multi));
if (result != 0) {
IntentFilter filter = new IntentFilter();
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.i("recived", "action");
if (!action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
return;
}
NetworkInfo mNetworkInfo = (NetworkInfo) intent
.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
if ((mNetworkInfo == null)
|| (mNetworkInfo.getType() != ConnectivityManager.TYPE_MOBILE_MMS)) {
return;
}
if (!mNetworkInfo.isConnected()) {
return;
} else {
Log.i("recived", "OK mms features");
context.unregisterReceiver(receiver);
dialog.dismiss();
sendNormalMms();
}
}
};
context.registerReceiver(receiver, filter);
} else {
// sendData(recipient, SentMMS);
Log.i("recived", "OK mms features");
// context.unregisterReceiver(receiver);
dialog.dismiss();
sendNormalMms();
}
}
如何在 6.0 中实现此功能我试过了。我打开了移动设备的彩信功能,但如何使用此功能 requestRouteToHost
NetworkRequest.Builder builder = new NetworkRequest.Builder();
// builder.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
builder.addCapability(NetworkCapabilities.NET_CAPABILITY_MMS);
builder.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
NetworkRequest networkRequest = builder.build();
mConnMgr.requestNetwork(networkRequest, new ConnectivityManager.NetworkCallback() {
@Override
public void onAvailable(Network network) {
super.onAvailable(network);
dialog.dismiss();
sendNormalMms();
}
});
requestRouteToHost 需要 6.0 实现吗?
最佳答案
我发现以下问题工作正常,我只是忘记打开移动数据。
NetworkRequest.Builder builder = new NetworkRequest.Builder();
builder.addCapability(NetworkCapabilities.NET_CAPABILITY_MMS);
builder.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
NetworkRequest networkRequest = builder.build();
mConnMgr.requestNetwork(networkRequest, new ConnectivityManager.NetworkCallback() {
@Override
public void onAvailable(Network network) {
super.onAvailable(network);
dialog.dismiss();
sendNormalMms();
}
});
关于android - startUsingNetworkFeature 和 requestRouteToHost Depreciated 在 6.0 替代这个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36327120/
在 ConnectivityManager 类中,我看到如下方法: public int startUsingNetworkFeature(int networkType, String featur
用于发送彩信的就绪设备在 Kitkat 中运行良好,但 Pro KitKat 版本 startUsingNetworkFeature 已弃用。 final int result = mConnMgr.
我是一名优秀的程序员,十分优秀!