Questions tagged [android-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:

60 questions
0
votes
1 answer

How to update status in remote database if the activity's onDestroy() method is not called?

The goal is to update status in a remote database once the activity gets destroyed. The difficulty is that the activity's onDestroy() method call can be skipped if system kills the process. The methods onStop() and onPause() are of no interest,…
Michael Zur
  • 915
  • 1
  • 6
  • 14
0
votes
2 answers

How to detect when application is closed by a user in android?

I know that, unlike onCreate(), Application class does not have a onDestroy() method. But I wanted to know when my application is closed (or it is not visible on screen anymore). After all, whatsapp and many more similar chat applications can detect…
Sourav Kannantha B
  • 2,860
  • 1
  • 11
  • 35
0
votes
1 answer

How to completely destroy an activity from code?

I am building an medication reminder app in android using java. User can set one or more reminders and according to those will get notified to take the medicine. Problem is, whenever a notification is generated, and the user taps on it and the…
0
votes
0 answers

onDestroy() not called

I have a service that I start via and return START_REDELIVER_INTENT public int onStartCommand(Intent intent, int flags, int startId) { ... return START_REDELIVER_INTENT; } so it gets restarted after being killed by Android after a day or…
monok
  • 494
  • 5
  • 16
0
votes
2 answers

On read shared preferences , only one object received

I'm trying to save some Array of objects to SharedPreferences. How it's working on my app: I have RecyclerView that contains clickable items. On click on these items, they are added to a new Array. And the new array is shown in another view. I'm…
0
votes
2 answers

Why cache data is not deleting on app destroy

When I try using the code bellow in the onDestroy() method in MainActivity it seams it does not work. What I am doing wrong? Code: @Override protected void onDestroy() { super.onDestroy(); deleteCacheData(); } public void deleteCacheData()…
user2054516
0
votes
1 answer

How to finish an application when it goes to the background

I need to finish an application when it goes to the background, I'm using method finishAffinity() but it seems it does not work, someone can tell me another alternative @Override protected void onPause() { finishAffinity() …
0
votes
2 answers

Android app is being killed when it keeps in background for long time

My android app is being killed by the Android OS when it's keep in background for sometime.So when it launches back it's an empty screen since all the data has been wiped out at the time when OS killed the process.Unfortunately I'm not storing any…
Manu Ram V
  • 369
  • 1
  • 3
  • 23
0
votes
2 answers

Android activity loosing my input from UI when I press the back button

I am a newbie at Android programming. I created a simple Empty Activity app in Android Studio and it has a bunch of UI fields. After I type in those input fields if I press the back button, the activity gets destroyed loosing all my entered…
Mck
  • 129
  • 1
  • 10
0
votes
2 answers

Previous activity get destroyed on view-pager page change

My Previous Activity gets Destroyed on view-pager page changed(of running Activity). Thus onBackPressed() my App gets closed. I don't want to recall previous Activity explicitly. Assume FirstActivity then open SecondActivity which has one viewpager…
0
votes
1 answer

onDestroy with an update from the store or a reload from the studio

In my application I need to detect when the user ends the app. When I do a reload from Android Studio what I see is that the app does not go through onDestroy. I presume this is because the studio uses instant run? It's not an issue as long as it is…
narb
  • 958
  • 1
  • 13
  • 39
0
votes
0 answers

Swipe to kill app in activity B but Activity A called onDestroy

I have two activities: ActivityA and ActivityB. In each activity, I have create a button with onClick method to startActivity to another activity. ActivityA.java public void doNext(View view) { startActivity(new Intent(ActivityA.this,…
Call me K
  • 41
  • 4
0
votes
1 answer

Clearing all activities with intent filters is not calling any destroy methods

When a user logs out in my app I want to take them to the login screen and clear the current stack. To do this I call this code with my intent, and it…
Elforama
  • 512
  • 1
  • 4
  • 16
0
votes
2 answers

Android Request to server before application compeletly closed

I have just one Activity , when user close the application (from os clear list of recent apps) I want to send a request to my server api and change user status. so I make IntentService and call it in my onDestroy() method of activity, but it dosn't…
Mohad Hadi
  • 1,826
  • 3
  • 24
  • 39
0
votes
2 answers

AndroidStudio - Save EditText when activity change

Ok so, there's a list of editText that the user fill with all names of players, say it's activity 2. And then click on start and play the game on activity 3. When he comes back to activity 2, the names are still in the editTexts and he can just add…