Click here to Skip to main content
15,895,777 members

How to open fragement activity on after splash screen activity

Member 9983063 asked:

Open original thread
Hello Guys, I want to know how can I open my fragment activity after splash screen activity and in my splash screen I am using animation in my splash screen please help me how can I open it.
Thanks in Advance.

What I have tried:

Java
package com.complainprotectioncell;

import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
public class SplashScreen extends AppCompatActivity {
    public MediaPlayer mp;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       try {
//           getSupportActionBar().hide();
//           requestWindowFeature(Window.FEATURE_NO_TITLE);
//           getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
//                   WindowManager.LayoutParams.FLAG_FULLSCREEN);
           setContentView(R.layout.front_splash_screen);
           mp = MediaPlayer.create(this, R.raw.bgr_be_happy);
           mp.start();

           startAnimation();
       }catch(Exception ex)
       {
           Log.e("Exception" , "Found 1" + ex);
       }
    }

    public void startAnimation()
    {
try {
    final ImageView imageView = (ImageView) findViewById(R.id.imageView);
    final Animation animation_1 = AnimationUtils.loadAnimation(getBaseContext(), R.anim.rotate);
    final Animation animation_2 = AnimationUtils.loadAnimation(getBaseContext(), R.anim.antirotate);
    final Animation animation_3 = AnimationUtils.loadAnimation(getBaseContext(), R.anim.abc_fade_out);

    imageView.startAnimation(animation_2);
    animation_2.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            imageView.startAnimation(animation_1);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });

    animation_1.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            try {
                startActivity(new Intent(getApplicationContext(), Login.class));
                finish();
                //imageView.startAnimation(animation_3);
                //mp.release();
            } catch (Exception ex) {
                Log.e("Exception Splash", ex + "");
//                    Toast.makeText(SplashScreen.this, "Sorry, Something went Wrong", Toast.LENGTH_SHORT).show();
            }
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
}catch(Exception ex)
{
    Log.e("Exception" , "Found 2");
}
    }

    @Override
    protected void onStop() {
        super.onStop();
        try {
            if (mp != null && mp.isPlaying()) {
                mp.stop();
                mp.release();
                mp = null;
            }
        }catch(Exception ex)
        {
            Log.e("Exception Found", ex + "");
        }
    }
}
Tags: Java, Android, Screen, Splash

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900