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
2
votes
2 answers

fragment disappear when came back from tab 3

I have an Activity with a ViewPager containing Fragments. the first fragment(book) create a nested fragment(singlebook) when click a button on it. Problem is that the first fragment and its component are gone when i came back from fragment3. I think…
Mraz Jason
  • 25
  • 4
2
votes
4 answers

Android use unique onDestroy for all activities

I have an app with several activities and the action to perform on destruction is actually the same, no matter what the Activity is at that moment (deleting some data and performing a HTTP call). Is there a way to have all activities share the…
gioaudino
  • 573
  • 8
  • 23
2
votes
1 answer

angular 2 - When i make a router navigate, the resolver react before the OnDestroy on the current page

I have two route: {path: 'route1',component: component1,resolve: {parameters: resolver1}} {path: 'route2',component: component2,resolve: {parameters: resolver2}} I navigate from route1 to route2 , the route2's resolver react before Ondestroy…
2
votes
4 answers

onDestroy() equivalent for IOS

I am looking for an swift method that acts like onDestroy() in android. I want it not to be called when the home button is pressed, it should only be called when the application is quit entirely. I tried using the deinit method but it was never…
cvrattos
  • 51
  • 1
  • 4
2
votes
3 answers

How can i do something before app is closed?

I have made an App in android in which i have a TCP Client but now i want to send a message to the server only when the app is going to be closed, i've trying to add the openConnection (opening connection with TCP Client) and sendMessage (Sending…
John K
  • 371
  • 5
  • 26
2
votes
1 answer

Removing Preference data when Application killed

In my application i am storing some SharedPreference data. I have to clear that all stored data when application killed. So, I have done it in my activity's onDestroy() as below : @Override protected void onDestroy() { if(isBackPressed==0){ …
Jaimin Modi
  • 1,530
  • 4
  • 20
  • 72
2
votes
1 answer

how to check broadcast unregister or not in android?

In my activity I try to unregister the Broadcast Receiver. I'm simply putting this line for unregister that. unregisterReceiver(myBroadcastReceiver); But the problem is that my Broadcast is unregister on two condition 1) One if I get the result in…
2
votes
0 answers

Angular Directive - replaceWith, ng-repeat and destroy

I have an array that is used for an ng-repeat. When this is updated, the directive is not currently not removed / destroyed from the DOM. The link function in the directive does a replaceWith replacing the element with a custom compiled element.…
Ewan
  • 378
  • 3
  • 14
2
votes
1 answer

Activity's local variable still valid after OnDestroy()

I have declared a class for doing work in the background: public class ReportLoadTask extends AsyncTask { public ReportLoadTask(Context context, String barcode, ReportLoadTaskListener l) { ... …
Janeks Bergs
  • 224
  • 3
  • 13
2
votes
0 answers

Android service onDestroy method runs on delay after stopService() called

I am using a service to run a timer that is controlled using the main activity. However, the lines of code that comes after calling stopService() seems to run before the onDestroy() method in the service. Here's the code in MainActivityClass that…
Tomu Ozawa
  • 39
  • 5
2
votes
2 answers

Why the lifecycle of an Asynctask or a Runnable is different from the Activity's lifecycle?

For example, if we consider the snippet code below: public class HandlerExample extends AppCompatActivity { private Handler mLeakyHandler = new Handler(); private TextView myTextBox; @Override protected void onCreate(@Nullable…
2
votes
3 answers

angular2 destroying subscriptions on view destroy

I have an "appService" which i Use to handle the interaction between all my components (forms, navigations, etc). My service has many event emitters to which the components subscribe (results showing, element selected, form posted, and so on). When…
2
votes
2 answers

how to clear status bar notification when onDestroy() not being called?

I recently made an online radio app. I implemented a status bar notification as music player notification. I clear the notification with onDestroy() but the problem is that sometimes onDestroy() is not being called. How to clear the status bar…
2
votes
0 answers

onDestroy() method is calling on call

In my application onDestroy() method is called while am getting call. How to avoid onDestroy() method is being called on call. Can someone help me out to get rid of this issue. Here is my code @Override protected void onDestroy() { …
Archana
  • 378
  • 3
  • 17
2
votes
1 answer

Android: onCreateView() runs from one tabs away

I am creating a tabbed app and I am running into a problem. onCreateView() runs when I click the tab next to where I am. What I mean is if I have three tabs (setup, maps, and motor) the onCreateView() view for maps and setup will run if I click…
user5016464