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

How to call webservice (Http Request) when app is killed by swiping in android?

Question/Requirement How to call Web-Service (HTTP Request) when app is killed by swiping in android? When I kill application by swiping from recent application list at that time I want to call Web-Service (or AsyncTask). What I used? I am trying to…
Darshak
  • 2,298
  • 4
  • 23
  • 45
2
votes
1 answer

Registering "onDestroy event handler" with Android Activity

Let's say I have a library object which needs to be notified of an Activity.onDestroy() event if it happens. Is there a way that I can register some sort of handler with the Activity from inside the library or will I need to require anyone using the…
Markus A.
  • 12,349
  • 8
  • 52
  • 116
2
votes
2 answers

Android - How to destroy a BroadcastReceiver?

I have implemented a BroadcastReceiver (called ProximityIntentReceiver) in my Android app, but i have some annoying problems. In the onCreate() method of my MainActivity I call this function: addProximityAlert(): private ProximityIntentReceiver…
Francesco Lombardo
  • 335
  • 1
  • 4
  • 15
2
votes
2 answers

onDestroy from activity not executing right after Activity.finish()

So here is the scenario where my doubt dwells: i have a Stack object of Activity in my Application class that will hold reference to all Activities that are currently alive in my App. All activity pushes itself into the Stack at its onCreate(), and…
Dragons_Lair5
  • 715
  • 1
  • 5
  • 16
2
votes
2 answers

stopService() Method Not Stopping The Service

I called the stopService() method from the calling class when the calling activity exits, and the service does not stop. It keeps on running in the background and can thus be a hastle to the end user. Any help would be greatly…
epiclapser
  • 271
  • 4
  • 12
2
votes
4 answers

Is onDestroy called in an application when the phone runs out of battery?

Would the onDestroy method be called when the phone runs out of battery? I would imagine that it doesn't. Unfortunately, I don't have a phone to test this on right now, otherwise I would just check for myself.
2
votes
1 answer

service destroys when clear multitasking stack android

I am working with services in my android application but i have little problem using services that when i am closing my application from Multitasking then suddenly background service from that application stopped and even i don't get log from…
WonderSoftwares
  • 2,800
  • 1
  • 15
  • 21
2
votes
1 answer

Android onStop onDestroy called after onCreate

I hope you can help me. I don't understand why this is happening to me. My app is calling onPause(), onStop(), onDestroy() immediately after calling onCreate(). The screen is black. When I press the home button, onPause(), onStop(), onRestart(),…
user3612455
  • 23
  • 1
  • 4
2
votes
3 answers

onDestroy() Doesn't get called all the time

I'm creating a temp file in the application. And when the app is destroyed I need to delete that file. Currently I'm calling this deleteTempFile() method in the onDestroy() method. But as I found out in the developers guide its not guaranteed to be…
Shashika
  • 1,151
  • 1
  • 9
  • 21
2
votes
3 answers

unable to destroy activity IllegalStateException

I have created a media player in android where the MediaPlayer is on a service. my main activity has an option menu with single item "exit" onOptionsItemSelected calls another method (mp is and instance of MediaPlayer in service) private void…
2
votes
0 answers

Stop services on app update

I am developping an Android application that has an activity and several services. My activity can be killed with no problem, but my services must not be killed for the app to work as intended. For this reason, I do not stop my running services in…
Raphael Royer-Rivard
  • 2,252
  • 1
  • 30
  • 53
2
votes
3 answers

Will activity run onDestroy when system kill it?

I am wondering that will activity run the method "onDestroy" when killed by system? for example, when the state of "activity A" is onStop ( user may press the Home button directly ), at the same time, system find out that the memory is not enough…
s011208
  • 305
  • 4
  • 12
2
votes
2 answers

onDestroy crash after closing app

I'm having some problems after making an override of the method onDestroy. My app is a music player, using the instance of mediaplayer I need at some point to force the release of it if no music is playing. This is my code so far, for making the…
Pievis
  • 1,954
  • 1
  • 22
  • 42
2
votes
3 answers

How to avoid Service to be stopped on configuration change?

Hi and thanks for your help. I have the following situation. My Activity is bound to a Service that performs heavy data retrival from internet via an AsyncTask. Since the Service is heavy I need to make make sure it is stopped when the user…
Lisa Anne
  • 4,482
  • 17
  • 83
  • 157
2
votes
3 answers

Android: How to backup a database when the application gets closed?

I am needing help to determine the right approach. I want to make a backup of an internal database to a location in the external storage every time the whole application gets interrupted or terminated/destroyed. I want to call this method from a…
Elementary
  • 2,153
  • 2
  • 24
  • 35