Conversation Activity on messaging Android SDK | Community
Skip to main content

Conversation Activity on messaging Android SDK

  • July 20, 2021
  • 5 replies
  • 0 views

We have integrated the Android messaging SDK in our app.

We have added the Clickable Links delegate to customize handling of URLs in the chat.

When user clicks on a link in the chat, we want to close the chat activity (ConversationActivity). We have achieved this on iOS. But, unable to do that on Android.

getCurrentActivity() on Android returns the parent activity, and not the ConversationActivity.

5 replies

Hey Vishakha,

Can you provide some more context around what custom action you intend to perform before closing the activity? Sample code to the demonstrate the desired custom action would be helpful as well.

Thanks,


  • Author
  • July 29, 2021

We need to invoke a React Native function - that function determines where the URL should redirect to (within our app). That function is being called correctly, and the redirection occurs in the background. On redirection, we want to close the chat activity.

The following is the function we need to call before closing the activity.

onUrlPressed.invoke(url);

The entire code block :

Messaging.instance().showMessaging(getCurrentActivity());
Messaging.setDelegate(newMessagingDelegate() {
@Override
public boolean shouldHandleUrl(@NotNullStringurl, @NotNullUrlSourceurlSource) {

// Your custom action...
// Return false to prevent the SDK from handling the URL automatically
// Return true to allow the SDK to handle the URL automatically, even
// if you have done something custom

onUrlPressed.invoke(url);
// Need to close the activity now
return false;

}

});

 


Hi Vishakha,

Would it be possible for you to share a simplified sample app (with navigation steps to reproduce) demonstrating what undesired behavior happens when simply finishing the current activity?

Thanks,


Alexandru13

Vishakha Damle have you found a solution? Facing the same problem


  • August 13, 2024
Hi Alexandru, 
 
Are you still having this issue as well? If so, I can go ahead and pull you into a ticket to get a better look. 
 
All the best!