Embedding Whereby in Android
Discover how to embed Whereby rooms into your native Android app using a WebView.
This guide offers a high-level overview of the implementation. For a complete working example (including media permission handling, shared file upload and download, for both Activity and Fragment-based setups) we recommend checking out public demo app.
In order to embed a room in an Android WebView, add these permissions to the Android Manifest:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
Configure the WebView settings to enable media functionality. Here is an example:
public class WebViewUtils {
@SuppressLint("SetJavaScriptEnabled")
public static void configureWebView(WebView webView) {
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
webSettings.setDatabaseEnabled(true);
webSettings.setMediaPlaybackRequiresUserGesture(false);
CookieManager.getInstance().setAcceptCookie(true);
CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);
}
}
Your app will need to handle media permissions, along with file upload and download functionality. Finally, set up your Activity or Fragment:
public class MainActivity extends AppCompatActivity {
private String roomUrlString = "https://yourWherebyRoomUrl"; // Replace by your own
private WebView webView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.webView = findViewById(R.id.webView);
WebViewUtils.configureWebView(this.webView);
// Add extra configuration and hanlders for media permissions and shared file here
}
@Override
protected void onResume() {
super.onResume();
this.webView.loadUrl(roomUrlString);
}
}
Last updated
Was this helpful?