2017-02-21 37 views

回答

2

可能的解決方案可能是檢查用戶是否在僅包(PS)載體上,並且如果連接了WIFI,則向用戶顯示警報以關閉WIFI。

您可以使用下面的代碼如下: -

private void check_wifi_for_volte(){ 
     TelephonyManager manager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); 
     String carrierName = manager.getNetworkOperatorName(); 
     Log.d(TAG,"carrierName:"+carrierName); 

     boolean isWifiActive =false; 
     ConnectivityManager cm = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE); 
     NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); 
     if (activeNetwork != null) { // connected to the internet 
      if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) { 
       // connected to wifi 
       isWifiActive=true; 
       //Toast.makeText(this, activeNetwork.getTypeName(), Toast.LENGTH_SHORT).show(); 
      } else if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) { 
       // connected to the mobile provider's data plan 
       //Toast.makeText(this, activeNetwork.getTypeName(), Toast.LENGTH_SHORT).show(); 
      } 
     } else { 
      // not connected to the internet 
      // can we show some toast not connected to internet 
     } 

     boolean isPSUser = carrierName.toLowerCase().contains(<PS-CARRIER>); 

     if(isPSUser && isWifiActive){ 
      Toast.makeText(this, "If you are using PS Network. Turn OFF WIFI to get OTP SMS.", Toast.LENGTH_LONG).show(); 
     } 

    }