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:

326 questions
8
votes
1 answer

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
3 answers

Is ondestroy not always called?

I have put some cache cleaning code in onDestroy of my activity but most of the time the code is not executed unless I explicitly finish the activity via finish(). Edit: Just read onDestroy is called only with finish() or if the system is low on…
yeahman
  • 2,478
  • 4
  • 16
  • 22
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,407
  • 4
  • 20
  • 32
7
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
  • 11,736
  • 17
  • 80
  • 126
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,416
  • 10
  • 44
  • 63
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
  • 2
  • 13
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
5
votes
1 answer

Angular 2 ngOnDestroy is not triggering

Good morning fellows I've developed a small angular2-client-app which got routes. The routes are created like this: app.routes.ts import { provideRouter, RouterConfig } from '@angular/router'; import { ContactComponent } from…
Enis B
  • 134
  • 1
  • 7
5
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,160
  • 1
  • 27
  • 51
5
votes
4 answers

How to automatically test onResume behaviour by calling onDestroy using Robotium?

I am using Robotium to functionally test an Android app. I'd like to test the onResume behaviour after onDestroy has been called. This post hints on using Instrumentation, but i can't get it to work. I have included the following, but this fails…
Bram
  • 101
  • 1
  • 6
4
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,663
  • 12
  • 56
  • 119
4
votes
1 answer

Dynamically registering a broadcast receiver

I registered my broadcast receiver like this(given below) in the manifest file. its working fine.
prijin
  • 1,789
  • 3
  • 13
  • 17
1 2
3
21 22