1

I was using below two methods for api level < 26 but for Api level > 26 it gives error can some one help how to fix below chunks.

Thanks In advance.

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;
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
user3256451
  • 475
  • 4
  • 14

0 Answers0