create account

Intro Screen | Android App Development | Lecture#52 | Hive Learners by faisalamin

View this thread on: hive.blogpeakd.comecency.com
· @faisalamin ·
$20.27
Intro Screen | Android App Development | Lecture#52 | Hive Learners
<center><h2>𝓖𝓻𝓮𝓮𝓽𝓲𝓷𝓰𝓼</h2></center>
<div class="text-justify">

Hi dear Hive Learners, I hope you all are well. In this lecture, we will add some more things to the Intro activity. We will change the design of the Intro Activity and add some colors and the most important thing we will check whether the intro is already displayed or not so that users will not see the intro again and again. We will use the sharedPreferences to store a variable and update this variable when a user go through the intro for the first time. Let's jump into it.

![](https://images.ecency.com/DQmPVgoSN1DJGPRyY39qPumpSvie8Tpwg5xaCMdcCyVxAur/multi_purpose_1_.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 save the state of Intro Class

## Assignment

- Show intro only for the first time

## Procedure

First, we need to set the colors for the pages. We will add two pages. I also add a new logo of lazy-panda to use on the second page. Also, declare and initialize the SharedPreferences. I also set the Icon Layout Params and I use the height and width of 500. You can always change these parameters.

```
// First Page
        page1.setBackgroundColor(R.color.red);
        page1.setIconLayoutParams(500, 500, 0, 0, 0, 0);
        page1.setDisplaySkip(true);
        page1.setTitleColor(R.color.black);
        page1.setDescriptionColor(R.color.black);

        // Second Page
        page2.setBackgroundColor(R.color.black);
        page2.setIconLayoutParams(500, 500, 0, 0, 0, 0);
        page2.setDisplaySkip(true);
        page1.setTitleColor(R.color.black);
        page1.setDescriptionColor(R.color.black);
```

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

Now we need to create a list and add these pages to the list and set it in the library method setOnboardPages. We also override the on finish button click and we will use it to save the state of into class and also redirect the user to the Sign in screen.

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

I add a boolean value ```is_intro_done``` in the SharedPreference when the user clicks on the finish button. Also, open the Sign in screen, show a welcome message, and finish the intro screen.

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

Now we need to check for the ```is_intro_done``` in the Splash activity. Declare and initialize the SharedPreference and set a check for the intro. If the intro the save boolean is false then we will open the Intro screen after the Splash screen else we will open the Login screen.

```
 sharedPreferences = getSharedPreferences("sharedPreferences", Context.MODE_PRIVATE);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                // After two seconds 1000ms = 1 Second
                if (!sharedPreferences.getBoolean("is_intro_done", false))
                    startActivity(new Intent(Splash_Activity.this, App_Intro.class));
                else startActivity(new Intent(Splash_Activity.this, SignIn_Activity.class));
                
                finish();

            }
        }, 2000);
```

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

Let's run the app and if it is working or not.</div>

![](https://images.ecency.com/DQmbMLYopVVpTWQ5aVwfdRZAfYfUG3ZBGbhvHZLRf8FcbNA/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>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 297 others
properties (23)
authorfaisalamin
permlinkintro-screen-or-android-app
categoryhive-153850
json_metadata"{"links": ["https://github.com/faisalamin9696/HiveLearners2", "https://discord.gg/7Bzqv4qUMT"], "image": ["https://images.ecency.com/DQmPVgoSN1DJGPRyY39qPumpSvie8Tpwg5xaCMdcCyVxAur/multi_purpose_1_.png", "https://images.ecency.com/DQmdruaf7jQc2zsrSLTWvwinG63cALSZGVNC1Tsoeo87uNT/image.png", "https://images.ecency.com/DQmcx5jadoZvA3MmwMBbChh76ZnnTsCvnq4ErSBBxZmCaer/image.png", "https://images.ecency.com/DQmbQz7NksPSQt3296Jsm5jBbg4LNqkET23XtErZZXuqLUW/image.png", "https://images.ecency.com/DQmRJsjQB4FogDSCcD1bDptmgvGzEVTSr1QzFNaWYC4ggta/image.png", "https://images.ecency.com/DQmbMLYopVVpTWQ5aVwfdRZAfYfUG3ZBGbhvHZLRf8FcbNA/image.png", "https://images.ecency.com/DQmabQycJhW8DT8a634z3wQaVXvPZ5KMii2LYbaWZ3PsaRy/hl_divider.png", "https://images.ecency.com/DQmZ4HF3hjV4HwJXuw8vRJ6B6CiMC3kUkkoihjtm7z2Gii7/hl_footer_banner.png", "https://cdn.steemitimages.com/DQmXd6PwGUHRgSDkWtwKfDvdFpaLHXvXBdK7wnYZeqe1GUa/discord_animation_logo.gif"], "thumbnails": ["https://images.ecency.com/DQmPVgoSN1DJGPRyY39qPumpSvie8Tpwg5xaCMdcCyVxAur/multi_purpose_1_.png", "https://images.ecency.com/DQmdruaf7jQc2zsrSLTWvwinG63cALSZGVNC1Tsoeo87uNT/image.png", "https://images.ecency.com/DQmcx5jadoZvA3MmwMBbChh76ZnnTsCvnq4ErSBBxZmCaer/image.png", "https://images.ecency.com/DQmbQz7NksPSQt3296Jsm5jBbg4LNqkET23XtErZZXuqLUW/image.png", "https://images.ecency.com/DQmRJsjQB4FogDSCcD1bDptmgvGzEVTSr1QzFNaWYC4ggta/image.png", "https://images.ecency.com/DQmbMLYopVVpTWQ5aVwfdRZAfYfUG3ZBGbhvHZLRf8FcbNA/image.png", "https://images.ecency.com/DQmabQycJhW8DT8a634z3wQaVXvPZ5KMii2LYbaWZ3PsaRy/hl_divider.png", "https://images.ecency.com/DQmZ4HF3hjV4HwJXuw8vRJ6B6CiMC3kUkkoihjtm7z2Gii7/hl_footer_banner.png", "https://cdn.steemitimages.com/DQmXd6PwGUHRgSDkWtwKfDvdFpaLHXvXBdK7wnYZeqe1GUa/discord_animation_logo.gif"], "users": ["Override"], "tags": ["hive-153850", "stem", "education", "ocd", "neoxian", "development", "programming", "android", "firebase"], "description": "", "app": "ecency/3.0.25-vision", "format": "markdown+html"}"
created2022-08-22 14:10:27
last_update2022-08-22 14:10:27
depth0
children2
last_payout2022-08-29 14:10:27
cashout_time1969-12-31 23:59:59
total_payout_value10.182 HBD
curator_payout_value10.084 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,085
author_reputation104,701,778,605,493
root_title"Intro Screen | Android App Development | Lecture#52 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id115,934,238
net_rshares29,381,025,396,595
author_curate_reward""
vote details (361)
@hivebuzz ·
Congratulations @faisalamin! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s):

<table><tr><td><img src="https://images.hive.blog/60x70/http://hivebuzz.me/@faisalamin/upvoted.png?202208230033"></td><td>You received more than 30000 upvotes.<br>Your next target is to reach 35000 upvotes.</td></tr>
</table>

<sub>_You can view your badges on [your board](https://hivebuzz.me/@faisalamin) and compare yourself to others in the [Ranking](https://hivebuzz.me/ranking)_</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>



**Check out the last post from @hivebuzz:**
<table><tr><td><a href="/hive-188409/@hivebuzz/farewell-erikasue"><img src="https://images.hive.blog/64x128/https://i.imgur.com/LdjPLQF.png"></a></td><td><a href="/hive-188409/@hivebuzz/farewell-erikasue">The Hive community is in mourning. Farewell @erikasue!</a></td></tr></table>
properties (22)
authorhivebuzz
permlinknotify-faisalamin-20220823t004530
categoryhive-153850
json_metadata{"image":["http://hivebuzz.me/notify.t6.png"]}
created2022-08-23 00:45:18
last_update2022-08-23 00:45:18
depth1
children0
last_payout2022-08-30 00:45:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length963
author_reputation370,822,829,145,755
root_title"Intro Screen | Android App Development | Lecture#52 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id115,948,284
net_rshares0
@stemsocial ·
re-faisalamin-intro-screen-or-android-app-20220823t000019440z
<div class='text-justify'> <div class='pull-left'>
 <img src='https://stem.openhive.network/images/stemsocialsupport7.png'> </div>

Thanks for your contribution to the <a href='/trending/hive-196387'>STEMsocial community</a>. Feel free to join us on <a href='https://discord.gg/9c7pKVD'>discord</a> to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support.&nbsp;<br />&nbsp;<br />
</div>
properties (22)
authorstemsocial
permlinkre-faisalamin-intro-screen-or-android-app-20220823t000019440z
categoryhive-153850
json_metadata{"app":"STEMsocial"}
created2022-08-23 00:00:18
last_update2022-08-23 00:00:18
depth1
children0
last_payout2022-08-30 00:00:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length565
author_reputation22,928,211,284,618
root_title"Intro Screen | Android App Development | Lecture#52 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id115,947,309
net_rshares0