Open next activity to current activity

Sudish Kumar
2 min readFeb 14, 2021

--

In this tutorial we will learn how to create a new activity and how to open it from the current activity may any activity or activity may be anything (MainActivity.kt, LoginActivity,…..)

There may be multiple activities in the App and for switching one to another activity we need Intent and we can also pass data from one to another activity. Many times we pass data from one to another activity.

There are two types of Intent

  1. implicit gives us information of available components given or provided by the system that is to be invoked or argue or pray. Like we parse a URI for the view web page. It doesn’t specify the component
  2. explicitly specifies components and in this tutorial, we will use it. For more intent, we will learn in another tutorial👨‍🏫📓👨‍🏫📓.

Let’s coding

Step 1

Create a New Project in android studio

Step 2

Creating New Activity

a. Right-click on MainActivity.kt > New > Activity > Empty Activity > right-click or enter

b. After Right-click or Enter

Enter Activity name and click on finish or enter after that wait few seconds you can able to your created activity

3. Use Intent for opening another Activity

//  Intent(this, activityName::class.java)
val intent = Intent(this, NextActivity::class.java)
//now start Activity
startActivity(intent)

That’s all about opening one Activity to another Activity

Open New activity from the fragment

//  Intent(this, activityName::class.java)
val intent = Intent(this, NextActivity::class.java)
//now start Activity
startActivity(intent)

Thank you for reading friends. I hope it’s helpful for you and you learn something new.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Sudish Kumar
Sudish Kumar

Written by Sudish Kumar

Flutter | Android | Node | Dart | Kotlin | Java | JavaScript | TypeScript | PHP | Short Story Teller | Tech Lead

No responses yet

Write a response