I wanted to detect incoming video calls as I am working on auto-pickup calls, so currently my app auto-picked up video calls, so I do want to pick up video calls automatically. I have used the below code function for detection, but it does not detect video calls.
private boolean isVoLTEVideoCall(Context context, Intent intent) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
if (telecomManager != null) {
// Log all extras to debug video call detection
Bundle extras = intent.getExtras();
if (extras != null) {
for (String key : extras.keySet()) {
Object value = extras.get(key);
Log.d("IntentExtra", key + ": " + value);
}
// Attempt to get the video state
int videoState = extras.getInt(TelecomManager.EXTRA_INCOMING_VIDEO_STATE, VideoProfile.STATE_AUDIO_ONLY);
// Check if the video state is not audio-only
return videoState != VideoProfile.STATE_AUDIO_ONLY;
}
}
}
return false; // Not a video call or older Android version
}