one activity to another activity in Kotlin

In this tutorial, we will learn how to jump from one activity to another activity in kotlin. This is the main activity we have made and there is three more activity we have created. We will use Intent().

It can be used with startActivity to launch an Activity. When you click on button or image it will jump to another activity. Below is an example of how to jump from one activity to another activity in kotlin.

Read More: Google Login And Registration For Android Using Firebase Authentication

Code:

import android.content.Intent
import android.media.Image
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.ImageView

class MainActivity : AppCompatActivity() {

    var photo: ImageView? = null;
    var eduButton: Button? = null;
    var wrkButton: Button? = null;


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)


        photo = findViewById(R.id.profile_pic_small)

        photo?.setOnClickListener({
            var clickintent = Intent([email protected], Profilephoto::class.java)
            startActivity(clickintent)
        })


        eduButton = findViewById(R.id.education_button)

        eduButton?.setOnClickListener({
            var clickedu = Intent([email protected], Education_Profile::class.java)
            startActivity(clickedu)
        })


        wrkButton = findViewById(R.id.work_experience_button)

        wrkButton?.setOnClickListener({
            var clickwrkexp = Intent([email protected], WorkExperience::class.java)
            startActivity(clickwrkexp)
        })

    }
}

If you have any confusion or need help then ask questions through comment section we will help you out.