• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

can we destroy another activity

 
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 can we destroy another activity whithing activity ?
i have two activities.Main Activity and child Activity.when the my application loads it's run the main activity.Withing main activity it's call the child activity.So when we go to child activity i need to destry the main activity.The reason is i need to destroy it is when i try to close the programm i need to main activity too.It's extra work and not good practise.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have an incorrect understanding of how Android apps work, and what the best practices are. Generally, you should not kill activities when you start new ones. Users expect to be able to go back by pressing the back button - that's no longer possible if you kill activities. And there's no concept such as "closing apps" - you shouldn't do that; Android will do that for you if necessary due to memory constraints.
 
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
tnx Dittmer.anyway my application behavior is somewhat different.there is a common class.so when the app start common class work as a starting activity.withing that activity i choose which activity to go next.withing the common activity there is no any graphical thing to show.actually when app starts user unable to see the common activity graphical behavior.because i use intent to call second activity.so when app starts it shows user to 2nd activity screens.please see the my common activity.when it runs it check the network provider name and goes to 2nd activity.so there is no time to see ist activity.that's why i finished 1st activity.unless when user close the 2nd activity it shows the 1st activity to the user.anyway can you please give me some tips to improve my code performance or anything?


 
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 see. You're already calling finish() after launching the Intent to start the 2nd activity, so I'm not sure what else you're looking for to kill the 1st activity.

You may wish to show a Toast in case there is an exception, or if the TelephonyManager cannot be obtained, so that the user knows what's going on, and then finish the activity.

My name is Ulf, by the way. If you prefer to call me by my last name, then the polite way to do so is to call me "Mr. Dittmer". First name is fine, though.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic