Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8651129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:59:11+00:00 2026-06-12T13:59:11+00:00

In my webview I have loaded a URL which have an embeded video player

  • 0

In my webview I have loaded a URL which have an embeded video player of a tv channel live stream. It is working correctly in all the OS version of Android except ICS(4). First time It plays the video well, but when I go back and come again in that page containing the video then the video doesnt loads and shows a blank white page. If I force stop the app from the application setting and start the app again then It runs well then appears white screen again as usual, I have implemented a lot of tactics and this is the latest , I am totally stuck here:

public class Livetvwebview extends Activity {

    RelativeLayout a;
    WebView webtv;
    String url;
    VideoView video;
    WChromeClient chromeClient;
    WebViewClient wvClient;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        // requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().requestFeature(Window.FEATURE_PROGRESS);
        setContentView(R.layout.livewebview);
        Toast.makeText(getApplicationContext(),
                "Channel is loading..This may take upto a minute",
                Toast.LENGTH_LONG).show();
        url = getIntent().getStringExtra("tvchannel");
        Log.i("TVURL", url);
        webtv = (WebView) findViewById(R.id.webViewlive);
        webtv.clearCache(true);
        webtv.loadUrl(url);

        webtv.getSettings().setLoadWithOverviewMode(true);
        webtv.getSettings().setUseWideViewPort(true);

        webtv.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);

        webtv.setWebChromeClient(new WChromeClient());
        webtv.setWebViewClient(new myWebClient());
        webtv.getSettings().setJavaScriptEnabled(true);

        webtv.getSettings().setPluginState(PluginState.ON);

        webtv.getSettings().setDomStorageEnabled(true);
    }



    public class myWebClient extends WebViewClient {
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            // TODO Auto-generated method stub

            super.onPageStarted(view, url, favicon);

        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            // TODO Auto-generated method stub

            view.loadUrl(url);

            return true;
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            // TODO Auto-generated method stub
            super.onPageFinished(view, url);

        }
    }

    @SuppressLint("NewApi")
    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        WebSettings webSettings = webtv.getSettings();
        webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
        webtv.onPause();
        this.finish();
        super.onPause();

    }

    @SuppressLint("NewApi")
    @Override
    protected void onResume() {



        webtv.onResume();
        super.onResume();

    }






    @Override
    protected void onDestroy() {
        // TODO Auto-generated method stub
        // android.os.Process.killProcess(android.os.Process.myPid());
        Editor editor = getSharedPreferences("clear_cache",
                Context.MODE_PRIVATE).edit();
        editor.clear();
        editor.commit();
        trimCache(this);

        super.onDestroy();
    }

    class WChromeClient extends WebChromeClient {
        @Override
        public void onProgressChanged(WebView view, int progress) {
            Log.i("Method", "Onrogresschanged");

            Livetvwebview.this.setTitle("Loading...");
            Livetvwebview.this.setProgress(progress * 100);
            if (progress == 100)
                Livetvwebview.this.setTitle("LiveTv");

        }

        @Override
        public void onShowCustomView(View view, CustomViewCallback callback) {
            // TODO Auto-generated method stub
            super.onShowCustomView(view, callback);
            if (view instanceof FrameLayout) {
                FrameLayout frame = (FrameLayout) view;
                if (frame.getFocusedChild() instanceof VideoView) {
                    webtv.setVisibility(View.GONE);
                    video = (VideoView) frame.getFocusedChild();
                    FrameLayout.LayoutParams par = new FrameLayout.LayoutParams(
                            LayoutParams.MATCH_PARENT,
                            LayoutParams.MATCH_PARENT);
                    par.gravity = Gravity.CENTER_HORIZONTAL;
                    video.setLayoutParams(par);
                    frame.removeView(video);
                    a.addView(video);
                    video.setOnCompletionListener(new OnCompletionListener() {

                        @Override
                        public void onCompletion(MediaPlayer mp) {
                            Toast.makeText(Livetvwebview.this,
                                    "Video completed", Toast.LENGTH_LONG)
                                    .show();

                        }
                    });

                    video.setOnErrorListener(new OnErrorListener() {

                        @Override
                        public boolean onError(MediaPlayer mp, int what,
                                int extra) {
                            Toast.makeText(Livetvwebview.this,
                                    "Encountered some error", Toast.LENGTH_LONG)
                                    .show();
                            return true;
                        }
                    });
                    video.start();
                }

            }

        }
    }

    public static void trimCache(Context context) {
        try {
            File dir = context.getCacheDir();
            if (dir != null && dir.isDirectory()) {
                deleteDir(dir);

            }
        } catch (Exception e) {
            // TODO: handle exception
        }
    }

    public static boolean deleteDir(File dir) {
        if (dir != null && dir.isDirectory()) {
            String[] children = dir.list();
            for (int i = 0; i < children.length; i++) {
                boolean success = deleteDir(new File(dir, children[i]));
                if (!success) {
                    return false;
                }
            }
        }


        return dir.delete();
    }
}

Can anyone help me please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:59:12+00:00Added an answer on June 12, 2026 at 1:59 pm

    After researching for a long long time I myself figured out that when I write in the onPause()

    webtv.destroy();
    

    instead of

    webtv.onPause();
    

    solves the problem 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have loaded an external URL in my WebView . Now what I need
I have a webView which displays a local html file loaded with jQuery etc.
In my application, I have a WebView which loads any URL from the internet.
I have a webview which will load from file or from the web. I
I have a webview which shows lines when scrolling up and down. I load
I have a webview which I would like to remove the elasticity from. As
I have an webView in a Cocoa application which I edit the contents programatically.
I have a webview, which shows the pages of a ebook. I want to
I have a webview that has some custom HTML loaded into it. In this
I have a Web View Which loaded as a modal view. I am having

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.