ondestroy


Save data in activity's onDestroy method

此生再无相见时 提交于 2020-01-11 01:48:08
问题 I'm writing a tasklist and have Project object, which holds all the tasks (and metadata). I use action log, so when tasks changes i do not save it immediately to database, just keep it in memory to dump in database on activity finish. Activity's onDestroy method is best place for this: if no onRetainNonConfigurationInstance method was called I start service to save project (one's instance is stored in Application). Saving is expensive: In DB project have revision, so I save new data, change

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

半腔热情 提交于 2020-01-04 04:15:33
问题 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 (*unchecked*){ serviceIntent.putExtra("user_stop", true); stopService(serviceIntent); when I stop the service I pass a parameter "user_stop" to say at the service that has been a user to stop it and not the system (for low memory). now I have to read the

Handle app closing event from Launcher's menu

纵然是瞬间 提交于 2020-01-02 07:49:48
问题 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 as long as he can close app in this was too, I have to handle this event and then make my operations. I've tried to google this one, but I couldn't find anything considering this. I don't want to override onStop() or onDestroy(), as long as the

How to destroy my application?

回眸只為那壹抹淺笑 提交于 2019-12-24 23:11:07
问题 My application is always showing in Task Manager when I exit from my application. How do I destroy it? I used the onDestroy() method, but still it is running. I am using alarm manager and some database operations; is that the problem? 回答1: Android does not destroy applications unless it needs to. See this answer for more details: Is quitting an application frowned upon? 回答2: System.exit(0) will do the job. However, it is not at all recommended. Android does some caching, and saving state, so

Storing variables through onDestroy() event

醉酒当歌 提交于 2019-12-24 21:22:00
问题 I'm looking for a way to store the state of my variables that may have been changed from there initiation variable (ever by user activating a function or other) through the onDestroy() event so that if i turn my phone on and off my app hasn't reset the variables. 回答1: First of all, this is from android reference: "Note: do not count on onDestroy method being called as a place for saving data! For example, if an activity is editing data in a content provider, those edits should be committed in

mdDialog: catch the onClose event

泄露秘密 提交于 2019-12-23 07:49:43
问题 I'm creating a mailbox in angular. And I would need to save the draft message when the popup to send a message closes. I know there are some alternatives: scope.$on("$destroy", function () { saveMessage() }); and: $mdDialog.show(...).finaly(function(){ saveMessage() }); But both are insufficient: The first is called when the Dialog is already closed. This is due to the requirements unacceptable (there is an iFrame that needs to be open) The second is outside the scope of the controller of the

Android Live wallpaper doesn't show

橙三吉。 提交于 2019-12-23 04:05:51
问题 i have just started learning live wallpapers and i made this little thing. the thing is my app compiles with out any problems. as i open it in the phone it shows the wallpaper in the preview but when i click "set as wallpaper" it somehow crashes, and returns the front screen, and my wallpaper turns black, but it doesn't run it. my guess is the problem is some where along the onDestory() .. public class Strips extends WallpaperService { private StripsEngine engine; @Override public void

onDestroy() not getting called while the activity is getting killed by the user?

心不动则不痛 提交于 2019-12-23 03:55:34
问题 I have an activity with two tabs. Clicking on two tabs will change the the fragments below the tabs. While that activity is in front I give out a notification, After that I minimize the app and kill that activity(not force stopping). My problem is that am not getting call back in onDestroy while the activity is been killed by the user. Now if I click the notification the app will force close and thats because the activity for pending intent is been missing. Why am not getting the call back in

Detect ActionMode nesting

那年仲夏 提交于 2019-12-23 02:53:11
问题 I use some custom ActionModes in my application. When an action mode is closed, I do some housekeeping, like closing related views, updating changes, etc.. I detect the action mode has been closed in OnDestroyActionMode. My problem is, when inside of some of my ActionModes, the user may trigger another system actionmode (The text copy/paste/select). In that case, onDestroyActionMode is called and I erroneously asume the user is done with the first actionmode, rather than implement a "stack"

Detect ActionMode nesting

不羁的心 提交于 2019-12-23 02:53:07
问题 I use some custom ActionModes in my application. When an action mode is closed, I do some housekeeping, like closing related views, updating changes, etc.. I detect the action mode has been closed in OnDestroyActionMode. My problem is, when inside of some of my ActionModes, the user may trigger another system actionmode (The text copy/paste/select). In that case, onDestroyActionMode is called and I erroneously asume the user is done with the first actionmode, rather than implement a "stack"

工具导航Map