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
3
votes
1 answer

Where to call DestroyWindow() of an MFC dialog?

I'm curently working on dialogs in an MFC application and I'm – admittedly – quite new to MFC. Let's say I have class A (derived from CDialog) that uses class B (also derived from CDialog). Thus, A::OnInitDialog() calls the create(...) method of…
Baldewin
  • 1,613
  • 2
  • 16
  • 23
3
votes
2 answers

Old view data appears in activity briefly, before new data is put into activity using databinding and MVVM

I have two activities- A. Product List B. Product Detail Whenever user clicks on product item, he goes to the product detail activity where an API is called which shows detail of that product. Now the problem is, that for the first time, the views…
Kartik Saraf
  • 115
  • 1
  • 8
3
votes
4 answers

How to pass a parameter from an activity to a service...when the user stop the service

I have an activity with a checkbox: if the chekbox is unchecked then stop the service. this is a snippet of my activity code: Intent serviceIntent = new Intent(); serviceIntent.setAction("com.android.savebattery.SaveBatteryService"); if…
Simone
  • 795
  • 2
  • 7
  • 17
3
votes
3 answers

Unable to destroy activity: java.lang.IllegalArgumentException: No view found for id () for fragment

I have an activity YYYY (which inflates a fragment) that extends a base activity XXXX which in turn extends ActionBarActivity. I now call finish() in onCreate() method of XXXX (at the very top), based on some condition. But I get the exception…
Henry
  • 17,490
  • 7
  • 63
  • 98
3
votes
0 answers

onDestroy gets called whenever screen turns off

I am aware of the fact that this problem has been reported earlier and I have used all the recommended solutions but none has helped so far. As mentioned in the title, onDestroy() is called every time screen turns off. It doesn't happen if a…
mesibo
  • 3,970
  • 6
  • 25
  • 43
3
votes
0 answers

Alarm Manager firing on destroy

I am working on alarmmanager. Alarmmanager fires on time which i set.But the problem is when system or user destroy the application, alarmmanager fires again. It fires only if user once set-up the alarmmanager.I mean after reboot if user open…
Eren
  • 2,583
  • 2
  • 31
  • 36
3
votes
1 answer

Stop ListView scrolling in progress when fragment is going away

I have a fragment that displays a list of up to several hundred items using a ListView. When the user causes a long-lasting scroll of the list and, while things are in motion, presses Back, bad things happen (a crash on a null pointer in getView()…
3
votes
1 answer

Handle app closing event from Launcher's menu

What I want to do is to know when user closes the app from Android Launcher's menu, which gets opened on home button long click: I want to do some operations when user closes the app. Actually, I want user to logout each time he leaves the app, but…
azizbekian
  • 60,783
  • 13
  • 169
  • 249
3
votes
2 answers

Why override Activity.onDestroy() if it isn't reliably called?

I'm confused why anyone would ever override Activity.onDestroy() instead of onPause() if according to the documentation: There are situations where the system will simply kill the activity's hosting process without calling this method (or any…
Jeff Axelrod
  • 27,676
  • 31
  • 147
  • 246
3
votes
2 answers

implications of AsyncTask.execute in onDestroy

I have this code running in my onDestroy function: @Override protected void onDestroy() { if (!(null == theUser.glideId)) { JSONObject req = new JSONObject(); try { req.put("actionKey", "UserPresenceInactive"); …
thepoosh
  • 12,497
  • 15
  • 73
  • 132
3
votes
3 answers

Prevent an Android application from getting closed/stopped

Is there some way to prevent the application from closing? Can I do it in the OnDestroy?
Sebosin
  • 167
  • 6
  • 16
2
votes
3 answers

Android: screen rotation, on destroy and services connundrum

I've modified the bluetooth chat example from the SDK demos to be able to control an arduino powered bluetooth LED matrix. Using the chat program, I can send messages to the display via bluetooth. I have a problem though. I've done two screen…
Evan R.
  • 1,210
  • 1
  • 27
  • 42
2
votes
2 answers

CountDownTimer wont let me call onDestroy

I have made and simple countdown timer app, but when i try to make onDestroy to cancel countdown timer i get and error. My onDestroy codeblock: @Override public void onDestroy() { super.onDestroy(); countdowntimer.cancel(); …
v66dik
  • 247
  • 3
  • 11
2
votes
2 answers

How to properly implement onDestroy method?

I'm developing an android application and i'm almost done, and in order to have a good application i wanted to know how to properly implement the onDestroy method, i mean do i have to call the garbage collector or set everything to null? thanks in…
ColdFire
  • 6,764
  • 6
  • 35
  • 51
2
votes
1 answer

Android- Resuming Service in Activity and destroying them on destroy

I currently have an Activty that when created starts and binds with a service. This service has a mediaplayer. What I would like to do is if the activity is resumed then the service keeps playing, etc. When the activity is destroyed, it should stop…
Splitusa
  • 1,181
  • 7
  • 31
  • 51