connectivityManager.startUsingNetworkFeature& connectivityManager.requestRouteToHost为Api Level 26提供错误

时间:2017-10-04 08:30:10

标签: android android-connectivitymanager

我正在使用以下两种api级别的方法< 26但是对于Api水平> 26它给出了错误,有人可以帮助如何修复下面的块。

提前致谢。

connectivityManager.startUsingNetworkFeature

//activate mobile connection in addition to other connection already activated
            try{
                int resultInt = connectivityManager.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, "enableHIPRI");
                Log.e(TAG, "startUsingNetworkFeature for enableHIPRI result: " + resultInt);
                if (-1 == resultInt) {
                    Log.e(TAG, "Wrong result of startUsingNetworkFeature, maybe problems");
                    return false;
                }
                if (0 == resultInt) {
                    Log.e(TAG, "No need to perform additional network settings");
                    return true;
                }
                if (2 == resultInt) {
                    Log.e(TAG, "Device specific state unknown.");
                    return false;
                }
            }catch (Exception e){
                e.printStackTrace();
                return false;
            }

connectivityManager.requestRouteToHost

boolean resultBool = connectivityManager.requestRouteToHost(ConnectivityManager.TYPE_MOBILE_HIPRI, hostAddress);
        Log.e(TAG, "************requestRouteToHost result***********" + resultBool);
        if (!resultBool)
            Log.e(TAG, "Wrong requestRouteToHost result: expected true, but was false");

        return resultBool;

0 个答案:

没有答案