• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

if i used intent to go another activity does first activity killed?

 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to know ,if i used intent to go another activity, does first activity killed?

this is my main activity.



this is my second activity



this is my activity_main.xml



this is my print.xml



when i click MainActivity button it goes to second activity(PrintValue)

it prints below
INSIDE MainActivity onClick
INSIDE PrintValue onCreate

then when i click PrintValue button again it should not prtint the "INSIDE MainActivity onCreate".But it prints the "INSIDE MainActivity onCreate" again.why ?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the javadocs of the Activity class; it includes a lengthy treatise of the Activity life cycle. Bottom line : Android is in charge of terminating Activities, not you.
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i need to know when we use Intent to call activity does it create new instance for each time,because when i click button each time it runs first the Oncreate methods,not the Onresume methods.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The javadocs of the startActivity method talk about that.
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
normally i am using Intent to start activity.So in my app there is a home page.Inside home page there are several links .So i used Intent to call those activities.So when i go to sub activity,each one has home button.So when click home button i used Intent to call Home calss.Is it good method as it always called OnCreate method.Actually i don't need to call onCreate when i call home activity when i am inside sub activity?its just ok to call OnResume.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems that you have not read about the Activity life cycle like I suggested. There is no such thing as a subactivity.
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually i mean subactivity activity after which called main activity in my app.I know there is no activity called subactivity in Android.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So everything is clear now? If not, please do not post again about this before you have read the javadocs of the Activity class. ALL of it. You simply can not develop for Android without a deep understanding of that.
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anywya i found that if i click back button of my phone it doesn't call the OnCreate method.It only calls the OnResume method.can you explain why it doesn't call OnCreate method ULF?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do YOU think the back button does? (The Activity javadocs explain that behavior as well, so I suspect you have not read them.)
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can we get Back button behavior in programatically?is there any way?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm done with this topic. You don't want to learn about the Activity lifecycle - fine, suit yourself.
 
ab singh
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please go through this link
webpage
webpage
i think this can help to understand activity life cycle well
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic