Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Check if call forwarding is activated

Tags:

android

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 check whether Call forwarding is active or not.

Is there any solution to check from the android system if call forwarding is active or not?

like image 582
Varun Agarwal Avatar asked Dec 27 '22 07:12

Varun Agarwal


1 Answers

 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

like image 60
laiwenjie Avatar answered Jan 10 '23 13:01

laiwenjie