android kotlin start activity code example

Example 1: start new activity kotlin

val intent = Intent(this, NextActivity::class.java)
// To pass any data to next activity
intent.putExtra("keyIdentifier", value)
// start your next activity
startActivity(intent)

Example 2: intent android open activity

Intent intent = new Intent(this, DisplayMessageActivity.class);
        intent.putExtra(key:,value:);
        startActivity(intent);

Example 3: navigate to another activity in android

OnClickListener onClickListener = new OnClickListener() {
    @Override
    public void onClick(View v) {
        startActivity(new Intent(action));
    }
};

Button button = (Button) findViewById(id);
button.setOnClickListener(onClickListener);

Tags:

Java Example