المشاركات

[ JAVA ] VIDEO IN SPLASH SCREEN ANDROID STUDIO



   Watch Video tutorial

                                    
Step 1 :
  • Create New Project With EmptyActivity
Step 2 :
  • Create New Folder in "res"  Name it "raw" 
  • paste your video in "raw" folder 
Step 3 : 
  • Add following code to MainActivity.java OR your splash screen activity ( for hide status bar)

requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

And for hide titlebar , Change  AppCompatActivity into Activity  

  • code Add following code in your  MainActivity.java OR your splash screen java activity :
     try {
            VideoView videoHolder = new VideoView(this);
            setContentView(videoHolder);
            Uri video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.splash);
            videoHolder.setVideoURI(video);

            videoHolder.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
                public void onCompletion(MediaPlayer mp) {
                    jump();
                }
            });
            videoHolder.start();
        } catch (Exception ex) {
            jump();
        }
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        jump();
        return true;
    }

    private void jump() {
        if (isFinishing())
            return;
        startActivity(new Intent(this, Main2Activity.class));
        finish();

Step 4 : 
  • Create new activity for your home screen, give name  "Main2Activity"
  • Run Your App
Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.