android splash screen

Solutions on MaxInterview for android splash screen by the best coders in the world

showing results for - "android splash screen"
Martín
27 Nov 2019
1//MainActivity.java
2
3import androidx.appcompat.app.AppCompatActivity;
4import android.os.Bundle;
5
6public class MainActivity extends AppCompatActivity {
7
8    @Override
9    protected void onCreate(Bundle savedInstanceState) {
10        super.onCreate(savedInstanceState);
11        setContentView(R.layout.activity_main);
12    }
13}
14
15//splashscreen.java
16
17import android.app.Activity;
18import android.content.Intent;
19import android.os.Bundle;
20import android.os.Handler;
21
22public class splashscreen extends Activity {
23    @Override
24    public void onCreate(Bundle savedInstanceState) {
25        super.onCreate(savedInstanceState);
26        setContentView(R.layout.splashscreen);
27
28        //Splash Screen duration
29        int secondsDelayed = 1;
30        new Handler().postDelayed(new Runnable() {
31            public void run() {
32                startActivity(new Intent(splashscreen.this, MainActivity.class));
33                finish();
34            }
35        }, secondsDelayed * 3000);
36    }
37}
38
39//activity_main.xml
40
41<?xml version="1.0" encoding="utf-8"?>
42<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
43    xmlns:app="http://schemas.android.com/apk/res-auto"
44    xmlns:tools="http://schemas.android.com/tools"
45    android:layout_width="match_parent"
46    android:layout_height="match_parent"
47    tools:context=".MainActivity">
48
49    <TextView
50        android:layout_width="wrap_content"
51        android:layout_height="wrap_content"
52        android:text="Hello World!"
53        app:layout_constraintBottom_toBottomOf="parent"
54        app:layout_constraintLeft_toLeftOf="parent"
55        app:layout_constraintRight_toRightOf="parent"
56        app:layout_constraintTop_toTopOf="parent" />
57
58</androidx.constraintlayout.widget.ConstraintLayout>
59
60//splashscreen.xml
61
62<?xml version="1.0" encoding="utf-8"?>
63<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
64    android:orientation="vertical" android:layout_width="match_parent"
65    android:layout_height="match_parent"
66    android:background="@drawable/splashlogo"
67
68    />
69      
70Source: https://github.com/Lunox-Code/SplashScreen
Lennart
23 Aug 2016
1///*********************declarling time here********************
2    private static int SPLASH_TIME_OUT = 4000;
3
4    @Override
5    protected void onCreate(Bundle savedInstanceState) {
6        super.onCreate(savedInstanceState);
7
8        //This  code is used for hide the sheek bar of application************************************
9        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
10        //***********************************************************************************************
11
12        setContentView(R.layout.activity_main);
13
14// this code is for splash screen ************************************************
15        new Handler().postDelayed(new Runnable() {
16            @Override
17            public void run() {
18                Intent intent = new Intent(MainActivity.this,HomeActivity.class);
19                startActivity(intent);
20                finish();
21            }
22        },SPLASH_TIME_OUT);
23    }
Michelle
13 Oct 2018
1public class MainActivity extends AppCompatActivity{
2	private static int SPLASH_TIME_OUT = 5000;
3	@Override
4	protected void onCreate(Bundle savedInstanceState){
5		super.onCreate(savedInstanceState);
6		setContentView(R.layout.activity_main);
7		new Handler().postDelayed(new Runnable(){
8			@override
9			public void run(){
10				Intent homeIntent = new Intent(MainActivity.this, HomeActivity.class);
11				startActivity (homeIntent);
12				finish();
13			},SPLASH_TIME_OUT) ;
14	}
15}
similar questions
queries leading to this page
android splash screen