How do I stop Flash after leaving a WebView?

后端 未结 6 1851
忘掉有多难
忘掉有多难 2020-12-30 08:11

I have an app that I\'ve put together to stream flash video in a webview when a user clicks a button.

It does this fine, but after backing out or losing focus, it lo

6条回答
  •  情书的邮戳
    2020-12-30 08:37

    If you are as lucky as I am, even this won't be enough to end a youtube streaming! The sound is still playing no matter what!

    @Override
    protected void onDestroy() {
        super.onDestroy();
    
        // Stopping a webview and all of the background processes (flash,
        // javascript, etc) is a very big mess.
        // The following steps are to counter most of the issues seen on
        // internals still going on after the webview is destroyed.
    
        mWebView.stopLoading();
        mWebView.loadData("", "text/html", "utf-8");
        mWebView.reload();
    
        mWebView.setWebChromeClient(null);
        mWebView.setWebViewClient(null);
    
        RelativeLayout layout = (RelativeLayout) findViewById(R.id.webviewRelativeLayout);
        layout.removeView(mWebView);
        mWebView.removeAllViews();
        mWebView.clearHistory();
        mWebView.destroy();
        mWebView = null;
    }
    

提交回复
热议问题