Search code examples
javaandroiduber-api

Unable to see country code in Uber API


I am trying to integrate Uber API into my app. For the authentication purpose, I am using the authorization URL provided by Uber API. I load the authorization URL into a web view whenever the user clicks the login with Uber button. After the web view is loaded, I start typing the contact no. required to log in but the country code is not loaded when I start typing the contact no.

enter image description here

This is how it should be when a user starts typing his/her contact no. enter image description here

This is how I am loading the authorization URL:

AlertDialog.Builder alert = new android.support.v7.app.AlertDialog.Builder(mContext);
            alert.setTitle("Login");

            WebView wv = new WebView(mContext){
                @Override
                public boolean onCheckIsTextEditor() {
                    return true;
                }
            };

            wv.setWebViewClient(new WebViewClient() {

                @Override
                public void onPageStarted(WebView view, String url, Bitmap favicon) {
                    super.onPageStarted(view, url, favicon);
                    Log.d(TAG, "onPageStarted: Loading...");
                }

                @Override
                public boolean shouldOverrideUrlLoading(WebView view, String url) {
                    view.loadUrl(url);
                    return true;
                }

                @Override
                public void onPageFinished(WebView view, String url) {
                    super.onPageFinished(view, url);
                    Log.d(TAG, "onPageFinished: Url Loaded");
                }

                @Override
                public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
                    super.onReceivedError(view, request, error);
                }
            });
            wv.loadUrl(finalAuthorizationUrl);

            alert.setView(wv);
            alert.show();

Solution

  • I fixed this by adding the below code:

     wv.getSettings().setJavaScriptEnabled(true);
     wv.getSettings().setLoadWithOverviewMode(true);
     wv.getSettings().setUseWideViewPort(true);
    

    It now works fine.