Detect incoming VoIP call Android

天涯浪子 提交于 2019-12-06 11:47:27

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!