Send request over Mobile data when WIFI is ON.(Android L)

后端 未结 2 1566
渐次进展
渐次进展 2020-12-04 10:33

SDK: Android 5.0.1.

Android build: LRX22C.

Device : Nexus 5.

Problem: KITKAT(4.4.4) and below API\'s

1) startUsingNetworkFeature(int n

2条回答
  •  鱼传尺愫
    2020-12-04 11:11

    Well finally found solution for this. Trick was to use capability as NET_CAPABILITY_INTERNET. Which is same as startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, FEATURE_ENABLE_HIPRI);

    See the Firmware design here

    builder.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
    builder.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
    

    After this I am able to get onAvailable callback from system and later I set my process default network as mobile data.

    Hence all the request goes over mobile data even if wifi is on. WOW!

    Note: This was not working in initial releases of Preview L.

    Edit 19-10-2015: setProcessDefaultNetwork is now depcreated use bindProcessToNetwork

提交回复
热议问题