Initial conditions: the phone is in Do Not Disturb mode. It is necessary that when calling from a certain number, the phone automatically switches to Normal mode. Actually the process of determining the number and switching mode is normal. The problem is that the phone is still silent. It seems to me that this is the same thing that when you call, press the volume button. Are there any other options for the inclusion of the normal mode to play the melody of the call?
Just in case my code is:
public class CallReceiver extends BroadcastReceiver { Boolean Ringing = false; String phoneNumber; final String LOG_TAG = "myLog"; public CallReceiver() { } @Override public void onReceive(Context context, Intent intent) { // TODO: This method is called when the BroadcastReceiver is receiving // an Intent broadcast. if (intent.getAction().equals("android.intent.action.PHONE_STATE")){ String phone_state = intent.getStringExtra(TelephonyManager.EXTRA_STATE); //Log.d(LOG_TAG,"phone_state " + phone_state); // состояние телефона (звонит / не звонит) if (phone_state.equals(TelephonyManager.EXTRA_STATE_RINGING)) { // телефон звонит, получаем входящий номер phoneNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER); //Log.d(LOG_TAG,"CALL_STATE_RINGING " + phoneNumber); // входящий номер Contacts contacts = new Contacts(); dbHelper = contacts.new DBHelper(context); Log.d(LOG_TAG,"Ringing " + Ringing); // входящий номер } else { Ringing = false; Log.d(LOG_TAG,"Ringing " + Ringing); // входящий номер } saveSett(context); } } I switch the mode in the service as follows:
myAM.setRingerMode(AudioManager.RINGER_MODE_SILENT); // включение режима только важные myAM.setRingerMode(AudioManager.RINGER_MODE_NORMAL); // включение нормального режима