No Full screen video on Webview


  • QA Engineer

    MainActivity

    package ru.kinobe.kinobe;
    

    import android.app.Activity;
    import android.content.Intent;
    import android.content.pm.ActivityInfo;
    import android.content.res. Configuration;
    import android.graphics.Bitmap;
    import android.net.Uri;
    import android.os.Bundle;
    import android.view.KeyEvent;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.webkit.WebChromeClient;
    import android.webkit.WebSettings;
    import android.webkit.WebView;
    import android.webkit.WebViewClient;
    import android.widget.FrameLayout;
    import android.widget.ProgressBar;
    import android.widget.RelativeLayout;
    import android.widget. Toast;

    import. comgoogle.android.gms.appindexing.Action;
    import. comgoogle.android.gms.appindexing.AppIndex;
    import. comgoogle.android.gms.common.api.GoogleApiClient;

    public class MainActivity extends Activity {
    Private WebView webView;
    private FrameLayout customViewContainer;
    private WebChromeClient.CustomViewCallback customViewCallback;
    private View mCustomView;
    private myWebChromeClient mWebChromeClient;
    private myWebViewClient mWebViewClient;
    private FrameLayout mTargetView;
    private FrameLayout mContentView;
    private WebChromeClient.CustomViewCallback mCustomViewCallback;

    /**

    • ATTENTION: This was auto-generated to implement the App Indexing API.
    • See https://g.co/AppIndexing/AndroidStudio for more information.
      */
      private GoogleApiClient client;

    /**

    • Called when the activity is first created.
      */
      @Override
      public void onConfigurationChanged(Configuration newConfig) {
      super.onConfigurationChanged(newConfig);

    @Override
    protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putString("key, "value");

    @Override
    public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    If (savedInstanceState!= null) {
    String string = savedInstanceState.getString("key);

    setContentView(R.layout.activity_main);
    customViewContainer = (FrameLayout) findViewById(R.id.customViewContainer);
    webView = (WebView) findViewById(R.id.webView);

    mWebViewClient = new myWebViewClient();
    webView.setWebViewClient(mWebViewClient);

    mWebChromeClient = new myWebChromeClient();
    WebView.setWebChromeClient (mWebChromeClient);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setAppCacheEnabled(true);
    webView.getSettings().setBuiltInZoomControls(false);
    webView.getSettings().setSaveFormData(true);
    final WebView webView = (WebView) findViewById(R.id.webView);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setCacheMode(WebSettings. LOAD_CACHE_ELSE_NETWORK);

    final Activity activity = this;
    webView.setWebChromeClient(new WebChromeClient() {
    public void onProgressChanged(WebView view, int progress) {
    / Activities and WebViews measure progress with different scales.
    / The progress meter will automatically disappear when we reach 100%
    activity.setProgress(progress * 1000);

    _
    webView.setWebViewClient(new WebViewClient() {
    public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
    Toast.makeText. Reset the app. "Toast. LENGTH_LONG).show();
    webView.setVisibility(View.INVISIBLE);

    _
    webView.loadUrl( < http://kinobe.ru > );
    webView.setBackgroundColor(0x00000);

    // ATTENTION: This was auto-generated to implement the App Indexing API.
    / See https://g.co/AppIndexing/AndroidStudio for more information.
    client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();

    public boolean inCustomView() {
    return (mCustomView!= null);

    public hide voidCustomView() {
    mWebChromeClient.onHideCustomView();

    @Override
    protected void onPause() {
    super.onPause(); /To change body of overridden methods use File . Settings . File Templates.
    webView.onPause();

    @Override
    protected void onResume() {
    super.onResume(); /To change body of overridden methods use File . Settings . File Templates.
    webView.onResume();

    @Override
    protected void onStop() {
    super.onStop(); /To change body of overridden methods use File . Settings . File Templates.
    // ATTENTION: This was auto-generated to implement the App Indexing API.
    / See https://g.co/AppIndexing/AndroidStudio for more information.
    Action viewAction = Action.newAction(
    Action. TYPE_VIEW, // TODO: choose an action type.
    Main Page, / TODO: Define a title for the content shown.
    / TODO: If you have web page content that matches this app activity's content,
    / make sure this auto-generated web page URL is correct.
    // Otherwise, set the URL to null.
    Uri.parse(http://host/path)
    / TODO: Make sure this auto-generated app deep link URI is correct.
    Uri.parse('android-app://ru.kinobe.kinobe/http/host/path)
    );
    AppIndex.AppIndexApi.end(client, viewAction);
    if (inCustomView() {
    hideCustomView();

    // ATTENTION: This was auto-generated to implement the App Indexing API.
    / See https://g.co/AppIndexing/AndroidStudio for more information.
    client.disconnect();

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == sync, corrected by elderman == @elder_man

    if (inCustomView() {
    hideCustomView();
    return true;

    if (mCustomView null) " WebView.canGoBack() {
    webView.goBack();
    return true;


    return super.onKeyDown(keyCode, event);

    @Override
    public void onStart() {
    super.onStart();

    // ATTENTION: This was auto-generated to implement the App Indexing API.
    / See https://g.co/AppIndexing/AndroidStudio for more information.
    client.connect();
    Action viewAction = Action.newAction(
    Action. TYPE_VIEW, // TODO: choose an action type.
    Main Page, / TODO: Define a title for the content shown.
    / TODO: If you have web page content that matches this app activity's content,
    / make sure this auto-generated web page URL is correct.
    // Otherwise, set the URL to null.
    Uri.parse(http://host/path)
    / TODO: Make sure this auto-generated app deep link URI is correct.
    Uri.parse('android-app://ru.kinobe.kinobe/http/host/path)
    );
    AppIndex.AppIndexApi.start(client, viewAction);

    class myWebChromeClient extends WebChromeClient {
    private Bitmap mDefaultVideoPoster;
    private View mVideoProgressView;

    @Override
    public void onShowCustomView(View view, int requestedOrientation, CustomViewCallback callback) {
    onShowCustomView(view, callback); //To change body of overridden methods use File . Settings . File Templates.

    @Override
    public void onShowCustomView(View view, CustomViewCallbackback) {

    mCustomView = view;
    / if a view already exists then immediately terminate the new one
    If (mCustomView!= null) {
    callback.onCustomViewHidden();
    return;

    mCustomView = view;
    webView.setVisibility(View.GONE);
    customViewContainer.setVisibility(View.VISIBLE);
    customViewContainer.addView(view);
    customViewCallback = callback;

    @Override
    public View getVideoLoadingProgressView() {

    if (mVideoProgressView null) {
    LayoutInflater inflater = LayoutInflater.from(MainActivity.this);
    mVideoProgressView = inflater.inflate(R.layout.video_progress, null);

    return mVideoProgressView;

    @Override
    public void onHideCustomView() {
    super.onHideCustomView(); /To change body of overridden methods use File . Settings . File Templates.
    if (mCustomViewyn null)
    return;
    mCustomView.setVisibility(View.GONE);
    mCustomView = null;
    webView.setVisibility(View.VISIBLE);
    customViewContainer.setVisibility(View.GONE);

    / Hide the custom view.
    mCustomView.setVisibility(View.GONE);

    // Remove the custom view from its container.
    customViewContainer.removeView(mCustomView);
    customViewCallback.onCustomViewHidden();

    mCustomView = null;

    class myWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
    return super.shouldOverrideUrlLoading(view, url); //To change body of overridden methods use File . Settings . File Templates.



  •  setContentView(R.layout.activity_main);
            customViewContainer = (FrameLayout) findViewById(R.id.customViewContainer);
            webView = (WebView) findViewById(R.id.webView);
    
            mWebViewClient = new myWebViewClient();
            webView.setWebViewClient(mWebViewClient);
    
            mWebChromeClient = new myWebChromeClient();
            webView.setWebChromeClient(mWebChromeClient);
            webView.getSettings().setJavaScriptEnabled(true);
            webView.getSettings().setAppCacheEnabled(true);
            webView.getSettings().setBuiltInZoomControls(false);
            webView.getSettings().setSaveFormData(true);
            final WebView webView = (WebView) findViewById(R.id.webView);
            webView.getSettings().setJavaScriptEnabled(true);
            webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    

    You've got duplication.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2