6

I have a web app that includes a google calendar embedded in it. I now would like to load this web app in a WebView in the WebView in my Android app. In order to show the calendar, the user has to press a button that opens the Google Auth popup to authorize access for me to pull the persons Google Calendar. This works great on desktop, iOS (browser and WebView), and Android (browser but not WebView), but the Google Calendar Login / Auth Screen won't show in an Android WebView.

My Activity (in Android):

public class WebView extends AppCompatActivity {

    android.webkit.WebView myWebView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_web_view);

        myWebView = (android.webkit.WebView) findViewById(R.id.webview);
        WebSettings webSettings = myWebView.getSettings();
        ////
        // ISSUE: I expected one of these to allow the popup screen to show
        webSettings.setJavaScriptEnabled(true);
        webSettings.setDomStorageEnabled(true);
        webSettings.setUserAgentString("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36");
        webSettings.setAllowFileAccess(true);
        webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
        webSettings.setSupportMultipleWindows(true);
        // ISSUE^
        ////
        myWebView.loadUrl("https://mywebsite.com/");
    }

    @Override
    protected void onSaveInstanceState(Bundle outState ) {
        super.onSaveInstanceState(outState);
        myWebView.saveState(outState);
    }

    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        myWebView.restoreState(savedInstanceState);
    }

}

Attempted solutions:

Does anyone understand why the Google Auth screen does not display in my WebView on Android?

Really jammed up and stuck on this one so thanks in advance :)

Rbar
  • 3,740
  • 9
  • 39
  • 69

0 Answers0