gpt4 book ai didi

android - startUsingNetworkFeature 和 requestRouteToHost Depreciated 在 6.0 替代这个

转载 作者:行者123 更新时间:2023-11-30 01:26:51 26 4
gpt4 key购买 nike

用于发送彩信的就绪设备在 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com