将YouTube播放器插入WebView按钮不起作用(全屏模式)。当您按下按钮时,什么也不会发生。我该如何使用示例代码来做到这一点?
public class MainActivity extends AppCompatActivity {
private WebView view;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.view = (WebView) findViewById(R.id.webView);
view = findViewById(R.id.webView);
WebSettings webSettings = view.getSettings();
webSettings.setJavaScriptEnabled(true);
view.getSettings().setJavaScriptEnabled(true);
view.setWebViewClient(new WebViewClient());
view.setWebChromeClient(new WebChromeClient(){} );
view.loadUrl("https://www.youtube.com/");
}
//method to handle pressing the BACK button
@Override
public void onBackPressed() {
if (view.canGoBack()) {
view.goBack();
} else {
super.onBackPressed();
}
}
// method disables reboot when screen is rotated
@Override
public void onConfigurationChanged(Configuration newConfig){
super.onConfigurationChanged(newConfig);
}
}