Splash Screen | Android App Development | Lecture#49 | Hive Learners

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
ยท@faisalaminยท
0.000 HBD
Splash Screen | Android App Development | Lecture#49 | Hive Learners
<center><h2>๐“–๐“ป๐“ฎ๐“ฎ๐“ฝ๐“ฒ๐“ท๐“ฐ๐“ผ</h2></center>
<div class="text-justify">

Hello dear Hive Learners, We cover the firebase data push, retrieve and remove the data. Today we will learn a new very useful feature in Android App that is a splash screen. You can call it a Welcome screen or first impression of an App. It shows the company information for 1 or more seconds when a user opens the app as new. When a user opens an app after installing then after the splash screen we can show the intro pages. But today we will learn how to implement the splash screen for two seconds.

![](https://images.ecency.com/DQmY2nEVMQJUME8hjkoiTmXB7BGT6ksGZxQJBzCmxYTpopL/multi_purpose_9_.png)


### [GitHub Link](https://github.com/faisalamin9696/HiveLearners2)

Use this GitHub project to clone into your directory. The following lecture will update it so you will never miss the latest code. Happy Coding!

### What Should I Learn

- How to add Splash screen

### Assignment

- Implement the Splash screen

### Procedure

First of all, we need a logo. I am adding a Hive Learners logo in the resource folder. The location will be ```res> drawable```. Copy the Hive Learners logo and press paste it into the drawable folder of our project. Make sure that the name is in lowercase and does not contain any special character of space than the underscore```_``` symbol. My logo name is ```hive_learners.png```. Follow these steps.

![](https://images.ecency.com/DQmaVzpTfdD2eyTsWyctpSypNBV78nzMAoTiBdvhtt4ubqQ/image.png)

Paste it into the simple drawable folder

![](https://images.ecency.com/DQmdPyffNG29xvB8yBYbchmtHSXkuZKpVAdiQPw3dmpH82x/image.png)

![](https://images.ecency.com/DQmdc5Vgai2DU8oQo92Ckt2uYuRG6w6kBDaLUd3XLeknyqC/image.png)

Now we need to create a new empty activity and name it as Splash_Activity. Now enter in its XML file. Change the parent layout to Linear Layout and add gravity to the center. Add an ImageView and set it's the source of our logo. Also, set the scale type to center inside.

```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical"
    tools:context=".Splash_Activity">

    <ImageView
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:scaleType="centerInside"
        android:src="@drawable/hive_logo" />


</LinearLayout>
```

![](https://images.ecency.com/DQmdtG7FiC7wtBNzDf65JXsufGdEScibiFQZhBK8UTq4MKC/image.png)

Now open Splash_Activity.java and write a code for a handler that will run for two seconds. After the 2 seconds, we will finish the Splash Activity and redirect the user to Login Page.

```
new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {

                // After two seconds 1000ms = 1 Second

            }
        }, 2000);
```

![](https://images.ecency.com/DQmch1Hea2kYUxeHGN1x7R1gnXa5vPiC5W9WrBYeSGRpqZU/image.png)


We need to redirect it to the Login Page after two seconds and finish this splash screen. So we will add these two lines in the run of the handler.

```
startActivity(new Intent(Splash_Activity.this, SignIn_Activity.class);
                finish();
```


![](https://images.ecency.com/DQmfN8nSrKFW4wTQBDrJST5fQo3reCCwNeGZ7bprShk3TP1/image.png)

The last thing we need to do is change the starting page in the manifest. Move the ```intent-filter``` code to the Splash Activity tag. Also, set exported to true.


![](https://images.ecency.com/DQmR1zHCZGdpQvifAS2VwcbMDBuYvVLB69YE73bqa68fyar/image.png)

Run the app and check the starting page of the app.</div>

![](https://images.ecency.com/DQmT3sZNJfucGDt6Wraq5WqRshzrcEEVXtsdLp4SEcNaGKq/image.png)

<center>
![hl_divider.png](https://images.ecency.com/DQmabQycJhW8DT8a634z3wQaVXvPZ5KMii2LYbaWZ3PsaRy/hl_divider.png)

<h2>Thank You</h2>

![hl_footer_banner.png](https://images.ecency.com/DQmZ4HF3hjV4HwJXuw8vRJ6B6CiMC3kUkkoihjtm7z2Gii7/hl_footer_banner.png)
<div class="pull-left"><a href="https://discord.gg/7Bzqv4qUMT">
<img src="https://cdn.steemitimages.com/DQmXd6PwGUHRgSDkWtwKfDvdFpaLHXvXBdK7wnYZeqe1GUa/discord_animation_logo.gif"/></a>
</center>
๐Ÿ‘ , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,