I'm developing an Android application which is checking handoff performance. It should be playing sound/notification during call (when handoff has performed), but only audible for me. I know that it's impossible to play sound for both sides, but my case is different. Sometimes during call we can hear incoming sms notification or something like that. So it can be done.
I have created testing infinite loop which is playing sound during call, but it's not working. Sound is playing only after call. There is some piece of my code below:
private PhoneStateListener callListener = new PhoneStateListener() {
public void onCallStateChanged(int state, String incomingNumber) {
try {
switch (state) {
case TelephonyManager.CALL_STATE_RINGING:
System.out.println("Polaczenie przychodzace");
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
System.out.println("Polaczenie wychodzace");
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);
while(true)
{
r.play();
}
case TelephonyManager.CALL_STATE_IDLE:
break;
default:
}
} catch (Exception e) {
}
}
};
What should I change?