问题
I want to close my app, when user get Viber/Skype/WhatsApp call. I am tried to use AudioFocus listener and Notification parsing, both of them not really good. May be there is other method that can help me?
回答1:
Checking for MODE_IN_COMMUNICATION in audio manager should achieve this. https://developer.android.com/reference/android/media/AudioManager.html#MODE_IN_COMMUNICATION
public static boolean isVoip(Context context){
AudioManager manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
if(manager.getMode()==AudioManager.MODE_IN_COMMUNICATION){
return true;
}
else{
return false;
}
}
来源:https://stackoverflow.com/questions/34566879/detect-incoming-voip-call-android