Discussion:
How to destroy an Activity in android
Meryl Silverburgh
2009-04-08 00:01:44 UTC
Permalink
Hi,

how can I destroy an Activity in android?
e.g. if i launch the 'Calculator' Activity, how to destroy it so that
the onDestroy method will get called?

Thank you.
Mark Murphy
2009-04-08 00:02:35 UTC
Permalink
Post by Meryl Silverburgh
Hi,
how can I destroy an Activity in android?
e.g. if i launch the 'Calculator' Activity, how to destroy it so that
the onDestroy method will get called?
Call finish() from within the Activity.
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 2.0 Available!
Rohit Kundalkar
2009-04-08 03:39:24 UTC
Permalink
@Override
public void onDestroy() {
super.onDestroy();
try{

}
catch(Exception ex){}

}

write this in onCreate() method in calculator activity.
Do all the finishing stuff in try{}

On Wed, Apr 8, 2009 at 5:31 AM, Meryl Silverburgh <
Post by Meryl Silverburgh
Hi,
how can I destroy an Activity in android?
e.g. if i launch the 'Calculator' Activity, how to destroy it so that
the onDestroy method will get called?
Thank you.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---
raj.10788
2009-04-08 12:42:49 UTC
Permalink
hi,

as per mark told you use the finish() method to end the activity. when
you finish() the activity the onDestroy() will get called.

I hope your don the onCreat() and OnDestroy() methods well.
Post by Rohit Kundalkar
@Override
    public void onDestroy() {
        super.onDestroy();
        try{
        }
        catch(Exception ex){}
    }
write this in onCreate() method in calculator activity.
Do all the finishing stuff in try{}
On Wed, Apr 8, 2009 at 5:31 AM, Meryl Silverburgh <
Post by Meryl Silverburgh
Hi,
how can I destroy an Activity in android?
e.g. if i launch the 'Calculator' Activity, how to destroy it so that
the onDestroy method will get called?
Thank you.
Loading...