Questions tagged [ondestroy]

Tag for questions related to Android's onDestroy() method of Activities and Services.

The onDestroy() method is one of the lifecycle methods for Activities and Services on the Android platform. This method is the last method to be called before an Activity or a Service is killed. More information about this method can be found at the links below:

340 questions
9
votes
2 answers

Situations when a Service's onDestroy() method doesn't get called?

I'm aware that a Service's onDestroy() method may never be called but can someone tell me when such a scenario might occur? I'm especially interested in whether it's possible for a Service to be killed, yet its VM would continue to run. I ask…
spaaarky21
  • 6,524
  • 7
  • 52
  • 65
8
votes
2 answers

Should Angular component variables be set to null in ngOnDestroy()?

The Angular documentation says ngOnDestroy(): Cleanup just before Angular destroys the directive/component. Unsubscribe Observables and detach event handlers to avoid memory leaks. Called just before Angular destroys the…
Kumanan
  • 81
  • 1
  • 4
8
votes
3 answers

How to restart a killed service automatically?

When a service has been killed, how to restart it automatically? sometimes without even calling onDestroy()
SEed
  • 81
  • 1
  • 1
  • 3
8
votes
1 answer

Is CountDownTimer cancelled automatically on Activity destroy()?

A question, maybe a little naive... If I start a 2 minute CountDownTimer in Activity onCreate() and close it with finish() when user clicks a button, does Android cancel it automatically? Or do I need to explicitly call cancel() in onDestroy()?
Seraphim's
  • 12,559
  • 20
  • 88
  • 129
7
votes
1 answer

Is it okay if we override OnDestroy() method in every activity of Android Application?

Is it okay if we override OnDestroy() method in every activity of Android Application? @Override public void onDestroy() { super.onDestroy(); } Just by calling super.onDestroy() in onDestroy() Method, will it cleanup the memory…
Girish
  • 123
  • 1
  • 4
  • 14
7
votes
2 answers

Can I detect when my service is killed by "Advanced Task Killer"

My app runs a geolocalisation service that the user can active or disactive by a toggleButton. To check the status of the service, I write a boolean in the Shared Preferences. I listen the beginning of the service and the end of it thanks to the…
user420574
  • 1,437
  • 5
  • 21
  • 33
6
votes
4 answers

Does the Back button trigger a call to "onDestroy"?

When the back button is being pressed and the current activity is being popped, will onDestroy be called? It seems that it's not called for me
ericlee
  • 2,703
  • 11
  • 43
  • 68
6
votes
1 answer

Is there anyway to detect app closed on flutter?

I trying to detect the app close on flutter. Is there any way possible on dart? I try using WidgetsBindingObserver but flutter can only detect AppLifecycleState of paused, inactive (I believe that on IOS), resumed, and detached. class…
Purinut
  • 213
  • 4
  • 9
6
votes
3 answers

Does onDestroy() or finish() actually kill the activity?

Actually I know i am asking about the simple and basic concept of Android. But I am a little bit confused about these finish() and onDestroy() methods. Whether this will kill the activity and free the resources associated with these activity? I…
Jomia
  • 3,414
  • 10
  • 46
  • 63
6
votes
3 answers

Angular2 detach view before onDestroy?

Is it somehow possible in Angular2 to get notified BEFORE the component is already destroyed!? i.e. When it is ABOUT TO be destroyed. I have a container component which holds a ViewContainerRef on one of its children which will be used to…
seraph
  • 351
  • 1
  • 3
  • 12
6
votes
1 answer

what is the impact of code if we write before or after super() function in override function

I am confused about super() function call in overriden functions. @Override protected void onDestroy() { // TODO Auto-generated method stub super.onDestroy(); } @Override protected void onPause() { // TODO Auto-generated method stub …
6
votes
1 answer

Android Fragment onCreateView after onDestroy not called again

According to the Android fragment lifecycle i would expect that after onDestroy the fragment will be recreated, or at least onCreateView is called again. I have an Activity A starting another Activity B for result and Activity B creating a fragment…
Dokumans
  • 359
  • 1
  • 3
  • 14
6
votes
1 answer

How to properly unbind services

I have a Service that is binded with BIND_AUTO_CREATE to my Activity and is started with START_STICKY. I do not explicitly call startService(). Since the onDestroy() method is not always called when my Activity get killed and the onStop() method is…
Raphael Royer-Rivard
  • 2,252
  • 1
  • 30
  • 53
5
votes
3 answers

Why is onDestroy() method called?

My app has 3 classes. First class is a splash screen, second class contains a list of playlists and third class that playlist's content. When a playlist is selected that third class get started to show the playlist content. On second class I have…
Gabrielle
  • 4,933
  • 13
  • 62
  • 122
5
votes
3 answers

Android: service destroyed when display is rotated

I've got a service that is running in a separate process. I'm finding that after the main process UI thread exits from onDestroy() that my service is being destroyed even though I've provided the application context with the binding and specified…
Syrinx
  • 51
  • 1
  • 3
1 2
3
22 23