voice-quickstart-android: INCOMING_CALL_INVITE extra is null when Incoming call notification in clicked.

Description

If the notification for the incoming call is clicked, it takes you to the VoiceActivity Screen where the intent.getParcelableExtra(Constants.INCOMING_CALL_INVITE) is turning out to be null, and the callInvite object is lost.

Steps to Reproduce

  1. Call to the device, while the screen in unlocked and the App is in background.
  2. Click on the incoming notification.
  3. It takes you the VoiceActivity Screen where the callInvite extra on the pending intent is null. .

Code

 private void handleIncomingCall(CallInvite callInvite, int notificationId) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            setCallInProgressNotification(callInvite, notificationId);
        }
        sendCallInviteToActivity(callInvite, notificationId);
    }
 @TargetApi(Build.VERSION_CODES.O)
    private void setCallInProgressNotification(CallInvite callInvite, int notificationId) {
        if (isAppVisible()) {
            Log.i(TAG, "setCallInProgressNotification - app is visible.");
            startForeground(notificationId, createNotification(callInvite, notificationId, NotificationManager.IMPORTANCE_LOW));
        } else {
            Log.i(TAG, "setCallInProgressNotification - app is NOT visible.");
            startForeground(notificationId, createNotification(callInvite, notificationId, NotificationManager.IMPORTANCE_HIGH));
        }
    }
    private Notification createNotification(CallInvite callInvite, int notificationId, int channelImportance) {
        Intent intent = new Intent(this, VoiceActivity.class);
        intent.setAction(Constants.ACTION_INCOMING_CALL_NOTIFICATION);
        intent.putExtra(Constants.INCOMING_CALL_NOTIFICATION_ID, notificationId);
        intent.putExtra(Constants.INCOMING_CALL_INVITE, callInvite);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
        /*
         * Pass the notification id and call sid to use as an identifier to cancel the
         * notification later
         */
        Bundle extras = new Bundle();
        extras.putString(Constants.CALL_SID_KEY, callInvite.getCallSid());

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            return buildNotification(callInvite.getFrom() + " is calling.",
                    pendingIntent,
                    extras,
                    callInvite,
                    notificationId,
                    createChannel(channelImportance));
        } else {
            //noinspection deprecation
            return new NotificationCompat.Builder(this)
                    .setSmallIcon(R.drawable.ic_call_end_white_24dp)
                    .setContentTitle(getString(R.string.app_name))
                    .setContentText(callInvite.getFrom() + " is calling.")
                    .setAutoCancel(true)
                    .setExtras(extras)
                    .setContentIntent(pendingIntent)
                    .setGroup("test_app_notification")
                    .setColor(Color.rgb(214, 10, 37)).build();
        }
    }

In VoiceActivity

private void handleIncomingCallIntent(Intent intent) {
        if (intent != null && intent.getAction() != null) {
            //Action is Successfully received
            String action = intent.getAction();
           // The below parcelable extra is null
            activeCallInvite = intent.getParcelableExtra(Constants.INCOMING_CALL_INVITE);
            activeCallNotificationId = intent.getIntExtra(Constants.INCOMING_CALL_NOTIFICATION_ID, 0);

            switch (action) {
                case Constants.ACTION_INCOMING_CALL:
                    handleIncomingCall();
                    break;
                case Constants.ACTION_INCOMING_CALL_NOTIFICATION:
                    showIncomingCallDialog();``

Expected Behavior

The Extra shouldn’t be null and incoming call dialog should be shown.

Actual Behavior

Nothing Happens when you reach the Voice Activity screen after clicking the Notification

Reproduces How Often

100%

Voice Android SDK

[5.4.0]

OS Version

[Android 10]

Device Model

[All Samsung phones and I guess all other phones too (haven’t confirmed)]

Note

The Reject and Accept button from the notifications work all the time, and even if I pass more string extras in the pending intent , I am unable to retrieve them in the activity as well. However intent.getData() in the activity works fine along with intent.getAction.

Additional Information

If I do NOT do pass this in pending intent intent.putExtra(Constants.INCOMING_CALL_INVITE, callInvite); while passing any other extras, they are received properly in the activity.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (7 by maintainers)

Most upvoted comments

@kbagchiGWC ,will start working on it next week.

  • I will set up a local server and clone this QS code and check
  • Convert the QS code to Kotlin as @MihailovDev suggested and check again

This should probably rule out if possibility of a bug in this code.

Let me know you you have any more suggestions.