Android App Development | Lecture#26 | Hive Learners
hive-153850ยท@faisalaminยท
0.000 HBDAndroid App Development | Lecture#26 | Hive Learners
<center><h2>๐๐ป๐ฎ๐ฎ๐ฝ๐ฒ๐ท๐ฐ๐ผ</h2></center> <div class="text-justify"> Greeting dear members of Hive Learners, I hope you all are doing well. A warm welcome to you in the 26th chapter on Android App Development. In the previous lecture, we complete the Sign in and Sign-up coding and successfully tested the app. In today's Lecture, we will design the Welcome screen with some buttons and we will open this screen on successful; login. We also need to store another value in shared preference to save the session for later use. So let's get started.  ### [GitHub Link](https://github.com/faisalamin9696/HiveLearners2) Use this GitHub project to clone into your directory. It will constantly get updated in the following lecture so you will never miss the latest code. Happy Coding!. ### What Should I Learn - Design a welcome screen - Store the session ### Assignment - Design a welcome screen and store the login session ### Procedure First of all, we need a new Empty Activity, ```Welcome_Activity``` and add some required widgets in the design layout of this welcome activity.   Hhave ere I two textview a Welcome text and a textview to show the username of a login user. ``` <?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" tools:context=".Welcome_Activity" android:orientation="vertical" android:padding="8dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Welcome" android:textSize="28sp" android:textStyle="bold" android:layout_gravity="center" /> <TextView android:id="@+id/welcome_username_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" android:textSize="14sp" android:textStyle="bold" android:layout_gravity="center" android:layout_marginTop="4dp"/> </LinearLayout> ```  Now we add two card views wrapped in the 2 Liearlayouts. The first linear orientation is verticle and in it another linear layout with horizontal orientation. In this Linearlayuout e add two card views with weight=1 and in the card,,, view add the TextView. Here is the code. ``` <?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:orientation="vertical" android:padding="8dp" tools:context=".Welcome_Activity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Welcome" android:textSize="28sp" android:textStyle="bold" /> <TextView android:id="@+id/welcome_username_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginTop="4dp" android:text="" android:textSize="14sp" android:textStyle="bold" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="2"> <androidx.cardview.widget.CardView android:layout_width="match_parent" android:layout_height="100dp" android:layout_weight="1" app:cardBackgroundColor="@color/purple_200" app:cardCornerRadius="10dp" app:cardElevation="4dp" app:cardUseCompatPadding="true"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Deposit" android:textColor="@color/white" /> </androidx.cardview.widget.CardView> <androidx.cardview.widget.CardView android:layout_width="match_parent" android:layout_height="100dp" android:layout_weight="1" app:cardBackgroundColor="@color/teal_700" app:cardCornerRadius="10dp" app:cardElevation="4dp" app:cardUseCompatPadding="true"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Transfer" android:textColor="@color/white" /> </androidx.cardview.widget.CardView> </LinearLayout> </LinearLayout> </LinearLayout> ```  Now we are ready with the design declare and initialize the username in the ```WelcomeActivity.java``` file. Also, declare and initialize the sharedPreferences.  Now we need to add a value in sharedPreference that will tell us which account is login currently. We also use a logic in ```Main_Activity.java``` that check is this value is empty or not. If not empty then it will redirect the user to welcome screen without login again. ``` sharedPreferences.edit().putString("login_account",email_et.getText().toString()).apply(); ```  Here is the logic that we use in the Main_Activity.java on app start to check the session.  Now on welcome screen we need to set the user name in welcome_username_tv, we get it from the sharedPreferences. First we need to get the login user email by using login_account key from sharedPreferences then we use this email_name to get the username.  Let's run and check if the app is working or not.</div>  <center>  <h2>Thank You</h2>  <div class="pull-left"><a href="https://discord.gg/7Bzqv4qUMT"> <img src="https://cdn.steemitimages.com/DQmXd6PwGUHRgSDkWtwKfDvdFpaLHXvXBdK7wnYZeqe1GUa/discord_animation_logo.gif"/></a> </center>
๐ isnochys, curx, pi-trader, crokkon, apx, eturnerx, funnyman, eliel, improv, alphacore, codingdefined, stinawog, ernick, sustainablelivin, steem.services, ordinaryamerican, tinyvoter, optimizer, infinite-love, ebargains, estream.studios, jacuzzi, voter, xves, bergelmirsenpai, stem-curator, lemouth, steemstem-trig, steemstem, dna-replication, minnowbooster, howo, aboutcoolscience, robotics101, stemsocial, oluwatobiloba, r00sj3, geopolis, charitybot, melvin7, deholt, onewolfe, curie, roguewriter, walterjay, dhimmel, alexander.alexis, abigail-dantes, kenadis, fragmentarion, francostem, gadrian, de-stem, gerdtrudroepke, pboulet, zeruxanime, lamouthe, metabs, techslut, mobbs, jga, mahdiyari, ludmila.kyriakou, bhoa, postpromoter, charitymemes, temitayo-pelumi, motherofalegend, stem.witness, crowdwitness, laruche, prosocialise, valth, tsoldovieri, zonguin, enzor, sco, intrepidphotos, alexdory, croctopus, nbs.gmbh, bflanagin, precarious, txracer, hijosdelhombre, orlandumike, maitt87, hive-143869, nanggroe1, gingerninja, thelordsharvest, doctor-cog-diss, aaronleang, lilacse, aabcent, seinkalar, rencongland, limeric19, cleanplanet, rubencress, marivic10, aicu, revo, fatman, dauerossi, bscrypto, marcocasario, cassioandro, gunthertopp, cakemonster, punchline, rtron86, aries90, migka, val.halla, therising, steemwizards, utube, silentscreamer, brianoflondon, holoferncro, simonpeter35, brotherhood, takowi, zirky, rynos-6, kingz1338, conocorp, edencourage, limeric01, gogreenbuddy, eman13088, armandosodano, theskmeister, fsm-core, federacion45, florian-glechner, fineartnow, achimmertens, eirth, extravagante, jayna, kiaazad, entrepreneur.one, investingpennies, eliana-art, kingz1339, b8l, jerrybanfield, mulletwang, sportscontest, irgendwo, superlotto, milagrosmhbl, lavista, barizon, cnfund, rt395, jaro-art, soufiani, photohunt, steemstorage, prize.hoard, mayberlys, gmzorn, raph1, dreamm, movingman, axelx12, zirkonov, tanray, dekeragoo, cloh76, dandesign86, double-negative, yourmind, steemean, justyy, neneandy, devann, bitrocker2020, stayoutoftherz, diabonua, epicdice, jessicaossom, laviesm, detlev, laxam, ozmash, shtup, iradeorum, sam99, maverickfoo, alexxxdada, meritocracy, stevieboyes, dmoonfire, dcrops, pogier, netvalar, anneporter, deriyon, windail1, neumannsalva, drawmeaship, cliffagreen, bit4bit, jennyferandtony, pateldhawal4, roomservice, zyx066, qberry, kylealex, manic.calm, taniagonzalez, goldrooster, appics.tutorial, lexansky, tfeldman, thelittlebank, thecryptodrive, ew-and-patterns, kgakakillerg, peterale, veeart, meno, raynen, strosalia, princessmewmew, joeyarnoldvn, lorenzopistolesi, goodcontentbot, kephler, nateaguila, steemcryptosicko, monsterjamgold, steveconnor, michelmake, swayzilla, lazy-panda, prayzz, goblinknackers, kronias, bruno-kema, mahirabdullah, ziabutt3836, offia66, chincoculbert, estherscott, gi-de-on, lawrence27, queenpriscilla, gone-hive, olivemarcel, hive-learners, auto-moderation, prechidi, niglys, sayu907, emmanuel222, rmach, mcsvi, firstamendment, meanbees, ibt-survival, inthenow, travoved, sanderjansenart, comidinhas, primersion, minnowspeed, hiddendragon, keco, mr-rent, ykretz, lordvader, pladozero, atheistrepublic, dondido, duke77, mayorkeys, juecoree, stem-espanol, iamphysical, carloserp-2000, miguelangel2801, elvigia, andrick, giulyfarci52, wilmer14molina, aqua.nano, yehey, lorenzor, ufv, analealsuarez, azulear, delpilar, tomastonyperez, josedelacruz, erickyoussif, uche-nna, reinaseq, fran.frey, aleestra, psicoluigi, robmojo, mammasitta, neddykelly, aotearoa, sincensura, aaronkroeblinger, roozeec, brwhale, medro-martin, danyst1ne, realblockchain, acousticguitar, fengchao, sardrt, vaultec, eric-boucher, gaming.grants, robertbira, eliaschess333, nicole-st, esthersanchez, ajfernandez, amansharma555, flatman, orlandogonzalez, cyprianj, gifty-e, ennyta, gaming.yer, endopediatria, anaestrada12, yggdrasil.laguna, stemgeeks, stemcuration, abh12345.stem, adamada.stem, solominer.stem, stuntman.mike, stemcur, stemline, ruari, star.stem, slider2990, cd-stem, dorkpower, babytarazkp, saboin.stem, scooter77.stem, stem.alfa, sillybilly, emrysjobber, holovision.stem, steemitboard, he-index, blainjones, elianaicgomes, cbridges573, hivebuzz, lizanomadsoul, manncpt, krishu.stem, pfwaus, meestemboom, untzuntzuntz, gaottantacinque, gasaeightyfive, labanez, chapmain,