android WebView stop Flash plugin onPause
Asked Answered
C

2

3

I have a WebView that contains a html file that contains a Flash plugin (a video).

When the user presses play on the Flash plugin, the video plays fine.

However when the user closes the app or moves to a new Activity, the Flash is still playing in the background. Going back to the view appears to create a new thread with the Flash plugin running on it.

How can we stop the Flash plugin running onPause?

Thanks

Chemarin answered 23/4, 2011 at 3:4 Comment(0)
A
3

I ran into the same issue. The following worked for me:

@Override
protected void onDestroy() {
    super.onDestroy();
    final WebView webview = (WebView)findViewById(R.id.webPlayer);
    // Calling .clearView does not stop the flash player must load new data
    webview.loadData("", "text/html", "utf-8");
}
Adames answered 8/9, 2011 at 17:42 Comment(1)
You should call super.onDestroy() as last method in your onDestroy() (it's opposite in "building" calls like onCreate() etc where you have to call super class as soon as possible. Not to mention I would rather call that earlier, in onPause() or onStop()Apprehension
S
-1

try this.

 public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && webview.canGoBack()) {
        webview.goBack();
       return true;
    }
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        //webview=null;
        webview.reload();
    }
    return super.onKeyDown(keyCode, event);
   }  

Pavan

Salad answered 30/4, 2011 at 2:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.