Day 1: Creating SplashScreen Using Kotlin with MVVM Pattern(SHouse)
Thursday, July 16, 2020
1 Comment
In this article, We are going to create the very first activity of our project
which is Splash Screen Activity. The basic use of splash Screen is for
branding and load or check network connections. But in this example, we are
only focusing to create a very simple splash screen in Android studio using
Kotlin.
Step 1: Create New Project In Your android studio with an empty
activity. Don't forget to select Kotlin as language and AndroidX support
library.
Step 2: In this entire project we are going to use MVVM pattern so
before starting any work just create some common folder architecture like
below
- Data - Here we will create classes of entire backend logic like the connection to the database, API calls etc.
- UI - It will contain all activity and classes which mostly communicate with our User Interface
- Utils - Most of the time we need to use repeated some utility methods like Toast, Progress bars or other.
Step 4: Create a new empty activity with name of SplashScreen in UI
directory
Step 5: Open activity_splash_screen.xml layout file and type below code
Step 6: Open SplashScreen.kt class file and type below code
In the above code, we used Handler for executing inside code after a specific time. We need to provide time in a millisecond to the handler. To learn more about handler visit android official documentation for the handler
Step 7: Add intent filter for SplashScreen activity in
AndroidManifest.xml File. Your manifest file looks like below:
We used <intent-filter> to define what is the exact role and type of the Intent defined in manifest file.
Step 8: Almost done here. Connect your android device or use AVD
and run your application.
osmaniye
ReplyDeleterize
sakarya
samsun
sivas
5WY