Accessing meeting within Android app

46 views
Skip to first unread message

Swati Sisodia

unread,
Sep 12, 2019, 11:38:05 AM9/12/19
to BigBlueButton-dev
Hello Team BBB,

I am working on developing a audio/video conferencing solution using BigBlueButton. We have an android app (along with a web solution) which lets user connect to a BigBlueButton meeting.
Here are the developer details:
BBB Server: 2.2 - Beta
Android application version: Android 10 (latest) 

The problem I am having is, the BBB meeting won't start in Android app. When a user clicks to join a BBB Meeting (in my Android app) and I open Chrome or Firefox browser from the app, it works and I see meeting is live and microphone and camera are in use. But I want to start the meeting within the Android app itself, in WebView object. I can open other URLs in this WebView just fine - URLs that don't use WebRTC. I am not sure if it is WebRTC that is not supported even by latest versions of Android or if there are other permissions or settings that need to be setup properly before I open BBB meeting URL in WebView of Android app. Below is my code:
webView.getSettings().getUserAgentString() returns this as output:
Mozilla/5.0 (Linux; Android 9; Android SDK built for x86 Build/PSR1.180720.075; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/69.0.3497.100 Mobile Safari/537.36

I see that versions of Mozilla and Chrome listed above support WebRTC. Here's my code to open BBB meeting URL in WebView: 
public class MyFragment extends Fragment {
    String url;
    private WebView webView;
    private ProgressDialog progressDialog;
    final String CUSTOM_TAB_PACKAGE_NAME = "com.android.chrome";
    CustomTabsClient mCustomTabsClient;
    CustomTabsSession mCustomTabsSession;
    CustomTabsServiceConnection mCustomTabsServiceConnection;
    CustomTabsIntent mCustomTabsIntent;


    public static MyFragment newInstance(String url) {
        BBBFragment fragment = new BBBFragment();
        Bundle args = new Bundle();
        args.putString("URL", url);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            url = getArguments().getString("URL");
        }
    }

    @RequiresApi(api = Build.VERSION_CODES.O)
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_myfragment, container, false);
        webView = view.findViewById(R.id.webviewBBB);
        try {
            Log.d("BBB URL is ", url);

            Log.d("WebView Version", "=======>" + webView.getSettings().getUserAgentString());
            //   webView = (WebView) view.findViewById(R.id.webviewBBB);
            //setUpWebViewDefaults(webView);
            webView.setWebChromeClient(new MyWebClient());
            webView.setWebViewClient(new WebViewClient());
            webView.getSettings().setJavaScriptEnabled(true);
            webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
            webView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; Android 5.1.1; Nexus 5 Build/LMY48B; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/43.0.2357.65 Mobile Safari/537.36");

            // AppRTC requires third party cookies to work
            CookieManager cookieManager = CookieManager.getInstance();
            cookieManager.setAcceptThirdPartyCookies(webView, true);
            webView.loadUrl(url);
            //webView.setWebViewClient(new MyBrowser());
            //webView.loadUrl("https://www.youtube.com/watch?v=3dXnrvvCFG4");

         /*   CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
            CustomTabsIntent customTabsIntent = builder.build();
            customTabsIntent.launchUrl(getActivity(), Uri.parse(url));*/

        } catch (Exception e) {
            e.printStackTrace();
        }
        return view;
    }

    private class MyBrowser extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }

        @Override
        public void onPageStarted(
                WebView view, String url, Bitmap favicon) {
            Log.i("Tag", "page started:" + url);
            super.onPageStarted(view, url, favicon);
        }

        @Override
        public void onPageFinished(WebView view, final String url) {
            Log.i("Tag", "page finished:" + url);
        }

        //Show loader on url load
        public void onLoadResource(final WebView view, String url) {
            Uri uri = Uri.parse(url);
            CustomTabsIntent.Builder intentBuilder = new CustomTabsIntent.Builder();
            //Open the Custom Tab
            intentBuilder.build().launchUrl(getContext(), uri);
        }

        @Override
        public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError er) {
            handler.proceed();
        }

    }

    private class MyWebClient extends WebChromeClient {

        @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
        @Override
        public void onPermissionRequest(PermissionRequest request) {
            super.onPermissionRequest(request);
            request.grant(request.getResources());
        }


    }


    /**
     * Convenience method to set some generic defaults for a
     * given WebView
     *
     * @param webView
     */
    @TargetApi(Build.VERSION_CODES.O)
    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    private void setUpWebViewDefaults(WebView webView) {
        WebSettings settings = webView.getSettings();

        // Enable Javascript
        settings.setJavaScriptEnabled(true);

        // Use WideViewport and Zoom out if there is no viewport defined
        settings.setUseWideViewPort(true);
        settings.setLoadWithOverviewMode(true);

        // Enable pinch to zoom without the zoom buttons
        settings.setBuiltInZoomControls(true);

        // Allow use of Local Storage
        settings.setDomStorageEnabled(true);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            // Hide the zoom controls for HONEYCOMB+
            settings.setDisplayZoomControls(false);
        }

        // Enable remote debugging via chrome://inspect
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            WebView.setWebContentsDebuggingEnabled(true);
        }

        webView.setWebViewClient(new WebViewClient());

        webView.canGoBack();
        webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
        webView.getSettings().setSafeBrowsingEnabled(true);
        webView.getSettings().setLoadsImagesAutomatically(true);
        webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.getSettings().setDomStorageEnabled(true);
        webView.getSettings().setDatabaseEnabled(true);
        webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
        webView.getSettings().setLoadWithOverviewMode(true);
        webView.getSettings().setUseWideViewPort(true);
        webView.getSettings().setAppCacheEnabled(true);
        webView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; Android 5.1.1; Nexus 5 Build/LMY48B; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/43.0.2357.65 Mobile Safari/537.36");

        // AppRTC requires third party cookies to work
        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.setAcceptThirdPartyCookies(webView, true);
    }
}

Attaching the screenshot of error I get on my mobile screen.

I have been playing with Android app version to make it work. It would be great if I can spot the lowest version of Android application that supports BBB meetings within the Android app.

Thanks for the awesome work you guys do on a daily basis!

Cheers,
Swati
zzl8L.png

Chad Pilkey

unread,
Sep 12, 2019, 1:36:03 PM9/12/19
to BigBlueButton-dev
You are manually overriding the UserAgent for some reason and making the WebView appear to be Chrome 43. I'm not quite sure why you would do that.

By default the minimum Chrome version is 59 because of some of the WebRTC stuff that we use.
Reply all
Reply to author
Forward
0 new messages