ondestroy

Can I detect when my service is killed by “Advanced Task Killer”

核能气质少年 提交于 2019-12-03 13:56:05
My app runs a geolocalisation service that the user can active or disactive by a toggleButton. To check the status of the service, I write a boolean in the Shared Preferences. I listen the beginning of the service and the end of it thanks to the onDestroy() of my service. My problem is that: When the user kill the service with the "advanced task killer", I can't know that the service is killed, the onDestroy is not called ! How can I deal with that? Thanks for your help. Florent When a process is killed (using ATK or android's own force stop button, or the function here ), it is immediately

Angular2 ngOnDestroy, emit event

我的梦境 提交于 2019-12-03 13:27:03
问题 is it possible to emit a custom event on ngOnDestroy ? I tried, but it seems like it does not work... I basically need to know when a Directive is removed from the UI. @Output() rowInit = new EventEmitter(); @Output() rowDestroy = new EventEmitter(); ngAfterViewInit() { this.rowInit.emit(this); } ngOnDestroy() { console.log("I get called, but not emit :(, ngAfterViewInit works :)"); this.rowDestroy.emit(this); } 回答1: I think that you could use an EventEmitter defined in a service instead of

Android - is onDestroy supposed to destroy the activity, its variables and free up memory

风格不统一 提交于 2019-12-03 12:20:29
I have a bug in my code that made me think I don't fully understand the Android Lifecycle. Yes, I have read all the docs and looked at the diagrams, but they seem to talk only about when to save data, when the activity may loose focus or get killed. However, my question is if I don't need to save state, what happens to the variables & their stored values? I expected them to be destroyed to, but a bug in my code seems to indicate otherwise. In my case here is what happened. I have an activity that launches a custom view (no xml, I just draw bitmaps on the screen in my custom view). The only

How to distinguish whether onDestroy() is called as part of configuration change sequence?

女生的网名这么多〃 提交于 2019-12-02 19:11:31
In my Activity some external thing (service) need to be destroyed in onDestroy(). But I do not want this when configuration change happens (e.g. keyboard flips out) because it will be restored right away. So the question is: how to distinguish whether onDestroy() is caused by say Back-key press or part of config change process? after @CommonsWare's answer it would be pretty simple) something like: @Override onDestroy() { if (mIsChangeConfig == true) { mIsChangeConfig = false: } else { stopService(); } } @Override onRetainNonConfigurationInstance() { mIsChangeConfig = true; } In Android 3.x

Android: screen rotation, on destroy and services connundrum

让人想犯罪 __ 提交于 2019-12-02 01:01:22
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 layouts, a portrait and a landscape. This way I can have the interface occupy the most space on the phone, regardless of orientation. The problem is that if the phone is rotated, OnDestroy() is called, to reload the new layout (landscape, or portrait). In the OnDestroy() routine I also destroy the bluetooth link, if it is established: public void

Does onDestroy() or finish() actually kill the activity?

限于喜欢 提交于 2019-11-30 14:32:29
Actually I know i am asking about the simple and basic concept of Android. But I am a little bit confused about these finish() and onDestroy() methods. Whether this will kill the activity and free the resources associated with these activity? I tried with a simple application which contains only one activity. I thought the concept is like When the application runs, the activity will start. and when we click on back button, it will finish. And I gave some toast message inside each life cycle methods for knowing the memory usage . And when I clicked on the back button it executed onPause() ,

Does onDestroy() or finish() actually kill the activity?

孤者浪人 提交于 2019-11-29 20:42:52
问题 Actually I know i am asking about the simple and basic concept of Android. But I am a little bit confused about these finish() and onDestroy() methods. Whether this will kill the activity and free the resources associated with these activity? I tried with a simple application which contains only one activity. I thought the concept is like When the application runs, the activity will start. and when we click on back button, it will finish. And I gave some toast message inside each life cycle

Acivity is getting destroyed while pressing the home button.

自闭症网瘾萝莉.ら 提交于 2019-11-29 09:59:35
In my application, when i press the home button the activity is going to onDestroy() . It suppose to be called onPause() method only right? Why it is happening so? It depends on how much memory your phone has, if your phone does not have very much memory, then it will destroy the activity to free up resources immediately. On new phones, this will not happen because they have plenty of spare memory. also check that you don't use the android:noHistory flag in your manifest for the Activity documentation: android:noHistory Whether or not the activity should be removed from the activity stack and

Situations when a Service's onDestroy() method doesn't get called?

会有一股神秘感。 提交于 2019-11-29 07:46:44
I'm aware that a Service's onDestroy() method may never be called but can someone tell me when such a scenario might occur? I'm especially interested in whether it's possible for a Service to be killed, yet its VM would continue to run. I ask because I have a service that registers ContentObservers in the service's onStartCommand() method and unregisters them onDestroy(). If the service's onDestroy() method was never called because the whole VM was killed (along with the observers it created,) that would be fine. But I'm wondering if it's possible for a service to "go away" without onDestroy()

How to make notification resume and not recreate activity?

我的未来我决定 提交于 2019-11-28 23:04:32
I thought I had this figured out, but after some debugging on this question: How to make notification uncancellable/unremovable I just realized my activity is still getting onCreated() and onDestroyed(), in random order. My manifest for the activity: <activity android:name="***.***.***.*****" android:configChanges="orientation|keyboardHidden" android:label="@string/app_name" android:screenOrientation="portrait" android:launchMode="singleTop" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <