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 1071309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:41:49+00:00 2026-05-16T20:41:49+00:00

In my android application i am playing videos using video view.While the video is

  • 0

In my android application i am playing videos using video view.While the video is getting downloaded i am showing a progress dialog.

At times when the streaming is not supported or when there is some error an error message is displayed onto the screen.After the ok click of the error message the progress dialogue again shows the message and tries to download.

But i would like to dismiss this dialogue if there is any error messgae and as soon as the user clicks Ok and return to the video player

so that the user can go through the next or previous video.

private ProgressDialog mProgressDialog;
Handler myUiHandler = new Handler();
         boolean m_prgisShowing = false;
         private static final int DIALOG_100 = 0;
        ProgressDialog mDialog2;

     mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                    public void onPrepared(MediaPlayer mp) {
                        Log.i("Manju", "OnPrepared");
                        myUiHandler.post(myDilgDismis);
                        mVideoView.start();



        protected Dialog onCreateDialog(int id) {
            switch (id) {
            case DIALOG_100: {
                mDialog2 = new ProgressDialog(this);
                mDialog2.setMessage("buffering...");
                mDialog2.setIndeterminate(true);
                mDialog2.setCancelable(true);

                return mDialog2;
            }
            }
            return null;
        }



        Runnable myDilgShow = new Runnable() {
            public void run() {
                show_My_Dialog();
            }
        };
        Runnable myDilgDismis = new Runnable() {
            public void run() {
                dismiss_My_Dialog();
            }
        };

        public void show_My_Dialog() {
            m_prgisShowing = true;
            showDialog(DIALOG_100);
        }

        public void dismiss_My_Dialog() {
            if (m_prgisShowing) {

                try {
                    if (null != mDialog2) {
                        mDialog2.dismiss();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    m_prgisShowing = false;
                }
            }
            m_prgisShowing = false;
        }

Please share your valuable suggestions.

Thanks in advance

  • 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-05-16T20:41:49+00:00Added an answer on May 16, 2026 at 8:41 pm

    I assume you use AsyncTask for threading, in this case for streaming or downloading. Then you have implemented the

    onProgressUpdate 
    

    function. In this function you update the progress dialog to show the current streaming status. To dismiss the progress dialog you have to set its visibility to false or remove it completely from the layout. In onProgressUpdate you need an if statement or something similar to catch the error and dismiss the dialog.

    EDIT:

    The code shows that you use runnable interface to implement threads, this is good for basic java development. But android sdk has a solution especially for android development called async task. It is recommended to use it.

    E.g. you can add a private class to your main java file where the oncreate method is located.

    private class MediaPlayer extends AsyncTask<Params, Progress, Result> {
    
    }
    

    a. Params: the type of the parameters sent to the task upon execution.

    b. Progress: the type of the progress units published during the background computation.

    c. Result: the type of the result of the background computation.

    Every async task implements the following methods. 4 steps an AsyncTask will go through:

    a. onPreExecute() – invoked on UI thread immediately

    -> Called before background computation starts

    -> Do some setup (such as, display a progress dialog)

    b. doInBackground(Params…) – invoked on the background thread

    -> Called immediately after onPreExecute()

    -> Perform computation in background thread that can take a long time.

    -> Use publishProgress(Progress…) to trigger UI update progress

    -> Progress will be passed to onProgressUpdate(Progress…)

    c. onProgressUpdate(Progress…) – invoked on UI thread

    -> Update progress

    d. onPostExecute(Result) – invoked on UI thread

    -> Called after the background computation finishes

    -> The result will be passed from doInBackground(Params…)

    How to start AsyncTask?

    new MyTask().execute(param1, param2, param3);
    

    This is a little overview. I strongly recommend you to read the doc.

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

Sidebar

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.