Add New Activity and Activity Life Cycle in Android using Kotlin:

Part 1
1 create new activity in Android in different ways
2 understand the cycle of an activity
Part 2
3 navigation between activities back and fourth
4 passing data between activity
Part 3
5 formatting activity
a apply custom toolbar
b change the title of activity
c create menu item add menu items in activity and work on menu item event
d enable back navigation button on second activity
e get data from activity to activity
f apply theme on activity
Part 4
6 permission handling in Activity

Steps to add new activity
First step is to add new activity
Project ->app-> Java ->com. package-> new->empty activity
And give name it to second activity

Add this activity to the manifest file
create new layout for third activity
Layout -> new -> layout resource file -> give name it to activity third

In activity main xml- 
Add text view in all three activities
For first  one I am first activity
For second I am second activity
For third i am third activity
Add third activity> new->kotlin class -> name give it as third activity
Write code given below
In Android manifest xml
Write code given below
<activity andriod : name ” third activity>
</activity> same as second activity
In main activity
 life cycle
As a user navigates through the app, Activity instances in your app transition through different stages in their life-cycle. The Activity class provides a number of callbacks that allow the activity to know that a state has changed: that the system is creating, stopping, or resuming an activity, or destroying the process in which the activity resides. Write code given below
class main activity: appcompatactivity()
Val TAG =”main activity”
override fun on create(saved instance state :bundle?){
super on create(create saved instance state}
set content view(R.layout.activity_main)
Log.d(TAG msg ” I am on create”}
textview _first.setonclicklistener
Val intent=intent(package content this second;
Start activity content
Override fun on start(){
Super.on start ()
Log.d(TAG,msg ” I am on start”)
Override fun on Restart(){
Super. On Restart()
Log.d(TAG msg “I am in Restart”)
Override fun on resume(){
Log.d(TAG msg.”I am is resume”}
Override fun on pause(){
super.on pause()
Log.d(TAG msg “I am in onpause”)
Override fun on stop(){
Log.d(TAG msg “I am in on stop”
Override fun on destroy(){
Super.ondestroy ()
Log.d(TAG msg”I am in destroy”)

Copy this code in mainkt file for activity second and third
Replace the textviewid with ids of these activities
Replace Val TAG also
In activity main xml- give I’d to each textview for all activities

8 thoughts on “Add New Activity and Activity Life Cycle in Android using Kotlin:”

  1. yabanci

    December 19, 2020

    Loaded with detail, Joe. I look forward to your posts. Rafaelia Jordan Zoba

  2. turkce

    December 20, 2020

    I was able to finhd good info from your blog articles. Martguerita Henderson Tennies

  3. 720p

    December 20, 2020

    I love the efforts you have put in this, appreciate it for all the great content. Merrily Bordy Lynn

  4. bluray

    December 23, 2020

    You made some nice points there. I looked on the internet for the subject and found most guys will go along with with your blog. Merilee Walther Carolyne

  5. ucretsiz

    December 23, 2020

    Hi there, I wish for to subscribe for this blog to take hottest updates, thus where can i do it please help. Janot Ulick Atwekk

  6. yify

    December 23, 2020

    It is not my first time to visit this web page, i am browsing this site dailly and get nice information from here everyday. Norine Wilhelm Neilla

  7. torrent

    December 24, 2020

    I regard something really interesting about your website so I saved to fav. Sasha Kirby Herrmann

  8. online

    February 10, 2021

    I value the article post. Thanks Again. Really Great. Arlinda Eliot Spratt Dian Kent Dianna


Want to say something? Post a comment

Your email address will not be published. Required fields are marked *