protected override void OnCreate(Bundle savedInstanceState) { Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); base.OnCreate(savedInstanceState); _webView = FindViewById <WebView>(Resource.Id.webView1); _browserView = FindViewById <WebView>(Resource.Id.webView2); _toastInjector = new ToastInjectorWebViewClient(_browserView); _browserView.SetWebViewClient(_toastInjector); // _browserView.Settings.UserAgentString += " BeatOn_Quest/" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); _browserView.Settings.UserAgentString = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36" + " BeatOn_Quest /" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); _browserView.SetWebChromeClient(new WebChromeClient()); _browserView.Settings.JavaScriptEnabled = true; _browserView.Settings.AllowContentAccess = true; _browserView.Settings.CacheMode = CacheModes.Default; _browserView.Focusable = true; _browserView.Settings.MediaPlaybackRequiresUserGesture = false; _browserView.Settings.DomStorageEnabled = true; _browserView.Settings.DatabaseEnabled = true; _browserView.Settings.DatabasePath = "/data/data/" + _browserView.Context.PackageName + "/databases/"; _browserView.Download += _webView_Download; _toastInjector.Download += _toastInjector_Download; _webViewClient = new BeatOnWebViewClient(this, _webView); _webViewClient.JSInterface.OnBrowserGoBack += JSInterface_OnBrowserGoBack; _webViewClient.JSInterface.OnHideBrowser += JSInterface_OnHideBrowser; _webViewClient.JSInterface.OnNavigateBrowser += JSInterface_OnNavigateBrowser; _webViewClient.JSInterface.OnRefreshBrowser += JSInterface_OnRefreshBrowser; _webViewClient.JSInterface.OnShowBrowser += JSInterface_OnShowBrowser; _webViewClient.JSInterface.OnToast += JSInterface_OnToast; _webView.Settings.UserAgentString += " BeatOn_Quest/" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); if (CheckSelfPermission(Android.Manifest.Permission.WriteExternalStorage) != Android.Content.PM.Permission.Granted) { ActivityCompat.RequestPermissions(this, new String[] { Android.Manifest.Permission.WriteExternalStorage }, 1); } else { ContinueLoad(); } }
protected override void OnCreate(Bundle savedInstanceState) { Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); base.OnCreate(savedInstanceState); _webView = FindViewById <WebView>(Resource.Id.webView1); _browserView = FindViewById <WebView>(Resource.Id.webView2); _toastInjector = new ToastInjectorWebViewClient(_browserView); _browserView.SetWebViewClient(_toastInjector); _browserView.SetWebChromeClient(new WebChromeClient()); _browserView.Settings.JavaScriptEnabled = true; _browserView.Settings.AllowContentAccess = true; _browserView.Settings.CacheMode = CacheModes.Default; _browserView.Focusable = true; _browserView.Settings.MediaPlaybackRequiresUserGesture = false; _browserView.Download += _webView_Download; _toastInjector.Download += _toastInjector_Download; _webViewClient = new BeatOnWebViewClient(this, _webView); _webViewClient.JSInterface.OnBrowserGoBack += JSInterface_OnBrowserGoBack; _webViewClient.JSInterface.OnHideBrowser += JSInterface_OnHideBrowser; _webViewClient.JSInterface.OnNavigateBrowser += JSInterface_OnNavigateBrowser; _webViewClient.JSInterface.OnRefreshBrowser += JSInterface_OnRefreshBrowser; _webViewClient.JSInterface.OnShowBrowser += JSInterface_OnShowBrowser; _webViewClient.JSInterface.OnToast += JSInterface_OnToast; if (CheckSelfPermission(Android.Manifest.Permission.WriteExternalStorage) != Android.Content.PM.Permission.Granted) { ActivityCompat.RequestPermissions(this, new String[] { Android.Manifest.Permission.WriteExternalStorage }, 1); } else { ContinueLoad(); } }