Android SDK 2.28.2 error when using the application context Android SDK 2.28.2 error when using the application context

Android SDK 2.28.2 error when using the application context

Diksha Mishra

Symptom

Opentok Android SDK version 2.28.2 can generate the error below if you use an application context to initialize a publisher.

java.lang.UnsupportedOperationException: Tried to obtain display from a Context not associated with one. Only visual Contexts (such as Activity or one created with Context#createWindowContext) or ones created with Context#createDisplayContext are associated with displays. Other types of Contexts are typically related to background entities and may return an arbitrary display

In previous SDK versions, it was possible to build a new publisher using the application context.

Applies To

  • Video API
  • Android SDK

Resolution

In 2.28.2 it is necessary to pass the activity context and not the application context to the publisher builder.

Cause

This issue occurs because a function in the Android SDK was deprecated. Changes were made to remove dependency on the deprecated functions.  We are currently testing alternative options that would again allow usage of the application context and hope to get these included in the next release.

Additional Information

For more details, please visit to android SDK release notes: https://tokbox.com/developer/sdks/android/release-notes.html