用于发送mms的就绪设备在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中实现此功能我试过这个。 我有移动设备mms功能,但我怎样才能使用这个功能 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的实现?
答案 0 :(得分:1)
我在下面的问题工作正常,我忘了turn on mobile data.
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();
}
});