【发布时间】:2012-10-25 03:49:59
【问题描述】:
问题更新:返回按钮的问题神秘地解决了。 现在它在开始新活动时崩溃(全屏播放器)
我在四种情况下测试了我的应用程序:
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)
【问题讨论】:
-
请发布崩溃的
Logcat以正确分析此问题。 -
你能把上面提到的按钮的功能贴出来吗..
-
我认为您的问题与上一个问题here 中提到的问题相似
-
@user936414 我认为他们在 FullScreenFunction()
-
@Anuj 老实说,我不是 100% 确定。但我不认为我们有类似的问题。您发布的问题是询问如何暂停 Flash 内容。我已经在 onPause() 中实现了代码,这就是为什么我能够在播放 Flash 内容时进行切换。无论如何,感谢您的帮助。
标签: java android webview youtube