orkFeature和requestRouteToHost在此版

orkFeature和requestRouteToHost在此版

本文介绍了startUsingNetworkFeature和requestRouteToHost在此版本的6.0中已弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用于发送彩信的就绪设备在Kitkat中可以正常工作,但是Pro KitKat版本 startUsingNetworkFeature 已弃用.

Ready device for sending mms works fine in Kitkat but Pro KitKat version startUsingNetworkFeature is depreciated.

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

How can i achieve this feature in 6.0 i tried this.i got the mobile device mms feature on but how can i use this funtion 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?

requestRouteToHost implementation for 6.0 is needed ?

推荐答案

我发现以下问题运行正常,只是我忘记了turn on mobile data.

I got the issue below is working fine i just forget to 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();
                }
            });

这篇关于startUsingNetworkFeature和requestRouteToHost在此版本的6.0中已弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 06:40