Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to make spalsh screen in android

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 118
    Comment on it

    In the below code I have created splash screen. Here first I have added images in drawable folder, and then added in activity_splash_screen, In SplashScreenActivity I have also used Timer function. See the below code it will clerly describe you how to make spalsh screen.

    Step(1)-SplashScreenActivity -

    public class SplashScreenActivity extends Activity {
        private static final int SPLASH_TIME_OUT = 1000;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
            setContentView(R.layout.activity_splash_screen);
    
            Timer timer = new Timer();
            timer.schedule(new TimerTask() {
    
                public void run() {
                    SharedPreferenceManager preferenceManager = SharedPreferenceManager.getInstance();
    
                    if (preferenceManager.getUserToken(SplashScreenActivity.this)==null ) {
                        Intent intent = new Intent(SplashScreenActivity.this, LoginActivity.class);
                        preferenceManager.setLoginCheck(SplashScreenActivity.this, true);
                        startActivity(intent);
                        finish();
                    } else {
                        Intent intent = new Intent(SplashScreenActivity.this, HomeScreenActivity.class);
                        startActivity(intent);
                        finish();
                    }
                }
            }, SPLASH_TIME_OUT);
        }
    }
    

    Step(2)-activity_splash_screen -

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".SplashScreen"
        android:background="@color/white"
        android:orientation="vertical">
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">
    
                <ImageView
                    android:id="@+id/ivLoginHeader"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:adjustViewBounds="true"
                    android:scaleType="fitXY"
                    android:src="@drawable/top1" />
    
                <ImageView
                    android:id="@+id/ivLoginLogo"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/ivloginlogo_top_margin"
                    android:src="@drawable/logo"/>
    
            </LinearLayout>
    
    </LinearLayout>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: