• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

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

 
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The javadocs of the startActivity method talk about that.
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.)
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how can we get Back button behavior in programatically?is there any way?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm done with this topic. You don't want to learn about the Activity lifecycle - fine, suit yourself.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please go through this link
webpage
webpage
i think this can help to understand activity life cycle well
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic