Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can we destroy another activity

 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • 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.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • 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.
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • 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: 42969
73
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic