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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:04:55+00:00 2026-06-06T17:04:55+00:00

I have a VideoView inside a custom Dialog. The first time the Dialog is

  • 0

I have a VideoView inside a custom Dialog. The first time the Dialog is shown, the video is played correctly, but if the Dialog is dismissed and then loaded again, the video doesn’t play and the dialog is just a blackscreen.

Here is the code I use to create my Dialog :

Dialog d;

protected Dialog onCreateDialog(int id) {
    switch(id) {
    case DIALOG_VIDEO:
        AlertDialog.Builder builder;

        LayoutInflater inflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
        View layout = inflater.inflate(R.layout.video,null);

        final VideoView vv = (VideoView)layout.findViewById(R.id.vv);
        vv.setMediaController(new MediaController(this));

        vv.setVideoURI(path);

        vv.setZOrderOnTop(true);
        vv.requestFocus();
        vv.start();

        builder = new AlertDialog.Builder(this);
        builder.setView(layout);
        d = builder.create();
        d.setOnDismissListener(new DialogInterface.OnDismissListener() {
            public void onDismiss(DialogInterface dialog) {
                VideoView vv = (VideoView)d.findViewById(R.id.vv);

                vv.stopPlayback();
                vv.clearFocus();
            }
        });
        break;
    default:
        d = null;
    }

    return d;
}

What am I doing wrong ?

Thank you for your time and sorry for my bad english.

  • 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-06T17:04:56+00:00Added an answer on June 6, 2026 at 5:04 pm

    The method onCreateDialog(int id) is called only once when your dialog is created. So once you dialog is created and when you dismiss the dialog, now the method onCreateDialog(int id) is called not called again thats why you are unable to view the video for second time. As per your code ,the logic for playing for video is only for on creating the dialog.

    You can use onPrepareDialog(int id) which will be called every time you launches the dialog.

    Note:: You need to use both onCreateDialog(int id) as well as onPrepareDialog(int id).

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

Sidebar

Related Questions

n00b here (first Android project). I have been given a custom video codec that
I have an app that displays a video using VideoView. The layout consists of
As shown image in above I have four tabs below videoview Resume , Produits
I want to add video in my app . But i have a problem
I have a VideoView that is inside a scrollView. When I scroll the scrollView,
I have VideoView (with streaming online video) and I wanted it to continue playing
I have a VideoView that is inside a scrollView. When I scroll the scrollView,
I have VideoView instance. I need to know video source path from it. Is
I'm using VideoView for a web video, and I also have a bitmap object
I need show video into VideoView which locate inside of activity with style (extends

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.