import android.content.Intent import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.os.Handler import android.widget.Toast class SplashActivity : AppCompatActivity() { private lateinit var runnable:Runnable private val handler = Handler() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_splash) runnable = Runnable { val intent = Intent(this,SignUpActivity::class.java) startActivity(intent) finish() } handler.postDelayed(runnable,3000) } override fun onDestroy() { handler.removeCallbacks(runnable) super.onDestroy() //Toast.makeText(this,"onDestroy called",Toast.LENGTH_SHORT).show() } } //XML <?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=".SplashActivity" android:gravity="center"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/tx_splash" android:textSize="30dp" android:textColor="@color/red"/> </LinearLayout>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter