问题更新:返回按钮的问题神秘地解决了。现在开始新活动时它会崩溃(全屏播放器)
我在四种情况下测试了我的应用程序:
1. 在出现 WebView 之前按下按钮:它工作正常
2. 在 WebView 中播放 YouTube 视频时按下按钮:它工作正常
3. 在 WebView 播放完毕后按下按钮:它工作正常
4.在出现WebView之后点击播放按钮之前按下按钮:它崩溃了
我的代码如下:
@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");
}
任何形式的帮助将不胜感激。提前致谢!
以下是来自 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)