Android Check if call forwarding is activated

后端 未结 4 1906
醉酒成梦
醉酒成梦 2021-01-13 21:19

I am building a call forwarding application and have used the **21*xxxxxx# ussd code to activate call fowarding using ACTION_CALL Intent. But I have not found a solution to

4条回答
  •  悲&欢浪女
    2021-01-13 22:12

     TelephonyManager manager = (TelephonyManager)    
     this.getSystemService(TELEPHONY_SERVICE);     
     manager.listen(new MyPhoneStateListener(), 
     PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR ); 
    
     class MyPhoneStateListener extends PhoneStateListener{  
    
      @Override
        public void onCallForwardingIndicatorChanged(boolean cfi) {
          Log.i(TAG,"onCallForwardingIndicatorChanged  CFI ="+cfi);
    
             preferences.edit().putBoolean("CALL_FORWARD_ACTIVE", cfi).commit();
            super.onCallForwardingIndicatorChanged(cfi);
        }
    
    }
    

    if cfi returns true that means set call forward success

提交回复
热议问题