0

Question updated: the problem with return button solved mysteriously. now the it crashes when starting new activity (full screen player)

I tested my app under four conditions:
1. press the button before the appearing WebView : it works fine
2. press the button while YouTube video is playing in WebView : it works fine
3. press the button after WebView finished playing : it works fine
4. press the button after the appearing of WebView but before the play button is clicked: it crashes

My code is as follows:

@Override
public void onCreate(Bundle savedInstanceState) {
    // Remove notification bar
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    this.getWindow().setFlags(
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    super.onCreate(savedInstanceState); 
    webview = (WebView) findViewById(R.id.web_view_player_vertical);
    webview.clearCache(true);
    webview.clearHistory();
    webview.getSettings().setJavaScriptEnabled(true);
    webview.getSettings().setPluginState(PluginState.ON);
    webview.getSettings().setPluginsEnabled(true);
    webview.getSettings().setLoadWithOverviewMode(true);// completely zoomed out
    webview.getSettings().setUseWideViewPort(true);
    webview.getTouchables();
    webview.setBackgroundColor(Color.parseColor("#00000000"));
    webview.setWebChromeClient(new WebChromeClient());
    webview.setWebViewClient(new WebViewClient());
    webview.loadUrl(emdLink);
}

@Override
public void onPause() {
    super.onPause();
    try {
        Log.i("in onpause", "onpause try");
        Class.forName("android.webkit.WebView")
                .getMethod("onPause", (Class[]) null)
                .invoke(webview, (Object[]) null);
        Log.i("in onpause", "onpause tried");


    } catch (ClassNotFoundException cnfe) {
    } catch (NoSuchMethodException nsme) {
    } catch (InvocationTargetException ite) {
    } catch (IllegalAccessException iae) {
    } catch (Exception  all) {
        Log.i("Exception", "Exception : "+all );
    }

    webview.destroy();
}

public void FullScreenFunction(){
        Log.v("FullScreenFunction", "durationPass :: " + duration);
        Log.v("FullScreenFunction", SrcPath1);
        Bundle bundle = new Bundle();
        bundle.putString("duration", duration);
        bundle.putString("link", SrcPath1);
        bundle.putString("youtubeLink", youtubeLink);
        bundle.putString("thumbnailLink", thumbnailLink);
        bundle.putString("title", title);
        bundle.putString("id", VideoId);
        bundle.putString("view_count", viewCount);
        bundle.putString("uploaded_date", date);
        Log.v("FullScreenFunction", "start");

        Intent myIntent = new Intent(this, HdPlayerHorizontal.class);
        myIntent.putExtras(bundle);
        startActivity(myIntent);

}

@Override
protected void onDestroy() {
    // TODO Auto-generated method stub
    super.onDestroy();
    Toast.makeText(this, "onDestroy", Toast.LENGTH_LONG).show();
}

@Override
protected void onStop() {
    // TODO Auto-generated method stub
    super.onStop();
    Toast.makeText(this, "onStop", Toast.LENGTH_LONG).show();
}

@Override
public void onResume() {
    super.onResume();
    Log.v("onResume", "onResume");

}

Any kind of help would be appreciated. Thanks in advance!

Here are the messages from logcat:

I/ActivityManager(1872): START {HdPlayerHorizontal (has extras)} from pid 13552
I/onPuase(13552): onPuase
I/in onpause(13552): onpause try
I/in onpause(13552): onpause tried
D/webviewglue(13552): nativeDestroy view: 0xc7b8d0
A/libc(13552): Fatal signal 11 (SIGSEGV) at 0x00d84c18 (code=2)
Dipak Keshariya
  • 22,193
  • 18
  • 76
  • 128
crystalWing
  • 69
  • 1
  • 11
  • Please post `Logcat` of the crash to analyze this properly. – Gagan Oct 25 '12 at 03:51
  • can you post the functionality of the button u mentioned above.. – user936414 Oct 25 '12 at 04:39
  • I think your problem looks similar to what has been mentioned in a previous question [here](http://stackoverflow.com/questions/3431351/how-do-i-pause-flash-content-in-an-android-webview-when-my-activity-isnt-visibl) – Anuj Oct 25 '12 at 05:13
  • @user936414 i think they are in FullScreenFunction() – crystalWing Oct 25 '12 at 05:55
  • @Anuj Honestly, I am not 100% sure. But I don't think we have similar problem. The question you posted is asking about how to pause the Flash content. And I have implemented the code in onPause(), that's why I am able to switch while the Flash content is playing. Anyway, thanks for trying to help. – crystalWing Oct 25 '12 at 06:01

1 Answers1

2

Fatal signal 11 is because webview is still drawing after you destroyed it. Simply put the webView.destroy() in the onStop. I believe your app will work fine

user1659006
  • 373
  • 2
  • 13