Last active
September 16, 2021 19:47
-
-
Save darianmh/4da2d78b0fdf3b5c5f47f182f0beca62 to your computer and use it in GitHub Desktop.
splash screen runner code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<activity | |
android:name=".SplashScreen"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
</intent-filter> | |
</activity> | |
<activity android:name=".MainActivity" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_splash_screen) | |
loadSplashScreen() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//runs timeout to remove screen | |
Handler().postDelayed({ | |
// You can declare your desire activity here to open after finishing splash screen. Like MainActivity | |
val intent = Intent(this, MainActivity::class.java) | |
startActivity(intent) | |
finish() | |
}, TIME_OUT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//remove screen after time out to show main app activity | |
private var TIME_OUT: Long = 1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.darian.ls1 | |
import android.content.Intent | |
import android.os.Bundle | |
import android.os.Handler | |
import androidx.appcompat.app.AppCompatActivity | |
class SplashScreen : AppCompatActivity() { | |
//remove screen after time out to show main app activity | |
private var TIME_OUT: Long = 1000 | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_splash_screen) | |
loadSplashScreen() | |
} | |
private fun loadSplashScreen() { | |
//runs timeout to remove screen | |
Handler().postDelayed({ | |
// You can declare your desire activity here to open after finishing splash screen. Like MainActivity | |
val intent = Intent(this, MainActivity::class.java) | |
startActivity(intent) | |
finish() | |
}, TIME_OUT) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment