I have an application that I compiled for streaming flash video in a web browser when a user clicks a button.
It does it well, but after maintaining or losing focus, it looks like it continues to use the data for a while, until I assume that the system turns off activity. If I manually turn off the activity screen, data usage will stop almost immediately. Just retreat, and this may go on for some time.
Can someone help me with my code, I would really appreciate it!
import java.lang.reflect.Method; import android.app.Activity; import android.os.Bundle; import android.webkit.WebSettings; import android.webkit.WebView; public class Video extends Activity { private WebView webview; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.video); webview = (WebView) findViewById(R.id.webview); // resumeTimers() to account for the webview refcount bug (hopefully) webview.resumeTimers(); WebSettings webSettings = webview.getSettings(); webview.getSettings().setJavaScriptEnabled(true); webSettings.setPluginsEnabled(true); webview.setVerticalScrollBarEnabled (false); webview.setHorizontalScrollBarEnabled (false); webview.loadUrl("http://www.nasa.gov/multimedia/nasatv/nasatv_android_flash.html"); } @Override protected void onPause() { pauseBrowser(); super.onPause(); } @Override protected void onResume() { resumeBrowser(); super.onResume(); } private void pauseBrowser() { // pause flash and javascript etc callHiddenWebViewMethod(webview, "onPause"); webview.pauseTimers(); } private void resumeBrowser() { // resume flash and javascript etc callHiddenWebViewMethod(webview, "onResume"); webview.resumeTimers(); } private void callHiddenWebViewMethod(final WebView wv, final String name){ if( webview != null ){ try { Method method = WebView.class.getMethod(name); method.invoke(webview); } catch (final Exception e) { } } } }
android flash webview android-webview
Fenderf4i Jun 01 2018-11-11T00: 00Z
source share