List of usage examples for android.webkit WebSettings setMediaPlaybackRequiresUserGesture
public abstract void setMediaPlaybackRequiresUserGesture(boolean require);
From source file:com.nbplus.hybrid.BasicWebViewClient.java
/** * ??.//w w w . j av a 2 s. c o m * @param activity : context * @param view : ?? */ public BasicWebViewClient(Activity activity, WebView view, String alertTitleString, String confirmTitleString) { mWebView = view; mContext = activity; // This will handle downloading. It requires Gingerbread, though mDownloadManager = (DownloadManager) mContext.getSystemService(mContext.DOWNLOAD_SERVICE); mWebChromeClient = new BroadcastWebChromeClient(); // Enable remote debugging via chrome://inspect if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { mWebView.setWebContentsDebuggingEnabled(true); } mWebView.setWebChromeClient(mWebChromeClient); WebSettings webSettings = mWebView.getSettings(); webSettings.setGeolocationEnabled(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setJavaScriptEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setDatabaseEnabled(true); // Use WideViewport and Zoom out if there is no viewport defined webSettings.setUseWideViewPort(true); webSettings.setLoadWithOverviewMode(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { webSettings.setMediaPlaybackRequiresUserGesture(false); } // Enable pinch to zoom without the zoom buttons webSettings.setBuiltInZoomControls(true); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) { // Hide the zoom controls for HONEYCOMB+ webSettings.setDisplayZoomControls(false); } webSettings.setAppCacheEnabled(true); mWebView.clearCache(true); webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // Sets whether the WebView should allow third party cookies to be set. // Allowing third party cookies is a per WebView policy and can be set differently on different WebView instances. // Apps that target KITKAT or below default to allowing third party cookies. // Apps targeting LOLLIPOP or later default to disallowing third party cookies. CookieManager cookieManager = CookieManager.getInstance(); cookieManager.setAcceptCookie(true); cookieManager.setAcceptThirdPartyCookies(mWebView, true); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { mWebView.getSettings().setTextZoom(100); } if (StringUtils.isEmptyString(alertTitleString)) { mAlertTitleString = activity.getString(R.string.default_webview_alert_title); } else { mAlertTitleString = alertTitleString; } if (StringUtils.isEmptyString(confirmTitleString)) { mConfirmTitleString = activity.getString(R.string.default_webview_confirm_title); } else { mConfirmTitleString = confirmTitleString; } mWebView.setDownloadListener(new DownloadListener() { public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); mContext.startActivity(intent); } }); Log.d(TAG, ">> user agent = " + mWebView.getSettings().getUserAgentString()); }