ondestroy

How is my fragment's onCreateView called before it's onCreate when finishing the activity in onCreate?

∥☆過路亽.° 提交于 2019-12-13 14:22:34
问题 This is very odd. I have a simple app which once logged in shows a fragment in an activity. The app also has an inactivity "timeout" after which time it finishes the activity and shows the login screen -- if the app is in the background when the timeout occurs then when the next onCreate or onStart event occurs in the activity it is finished. However sometimes when returning to the logged in activity I get a NPE in the onActivityCreated method of my fragment. The fragment is very simple and

Android onDestroy and finish

為{幸葍}努か 提交于 2019-12-13 07:19:09
问题 I found some answer about the difference between onDestroy and finish. Finish will remove the activity from the stack, but will not free the memory and will not call onDestroy in every time. onDestroy will kill the activity and free the memory. In my situation: There are 2 activities. A is main activity and B is a activity with some EditText for sending data to server by using Volley. A -> B -> A When i sent the data successfully.It will run the finish() to kill B. B is destroyed. But i call

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

吃可爱长大的小学妹 提交于 2019-12-12 08:02:18
问题 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 回答1: When a

NullPointer at OnDestroy

喜欢而已 提交于 2019-12-12 00:42:42
问题 I'm having an issue that only Crashlytics shown me and my team, I can't reproduce it on my tests devices. It seens that the method onDestroy() is throwing a "NullPointerException". @Override protected void onDestroy() { UsersOnRoom.removeAll(); try { audioManager.removeAudioFiles(); } catch (Exception e) { super.onDestroy(); } super.onDestroy(); } RoomBaseActivity extends another Activity, that has no implementation of onDestroy(). I have no ideia what's is causing it. 来源: https:/

call method when program exits - onDestroy not reliable

丶灬走出姿态 提交于 2019-12-11 07:35:59
问题 I want to execute some functions when the program is exited by hitting the back button. This is now done by onDestroy() which works in every case but one. When coming back from another activity in some cases on exiting the program, onDestroy is not called. I know that in theory onDestroy should only be called when Android closes the app due to low memory, but for me, onDestroy works always and only in a very special case it does not. Using onPause or onStop does not work because I only want

onDestroy crash after closing app

岁酱吖の 提交于 2019-12-11 05:33:36
问题 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 trick I've both overrided the onKeyDown() and onDestroy() method: @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK)) { if(mp.isPlaying()) { //Genera la notifica generateNotificationSong(); //Muovi

Android- Resuming Service in Activity and destroying them on destroy

筅森魡賤 提交于 2019-12-11 01:05:11
问题 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 the service . So far I can get both the service to keep playing when activity is re-activated and the service to stop when a new activity is created but not both together. Any suggestions or ideas? Thanks. Code below: Activity class: public class

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

风流意气都作罢 提交于 2019-12-10 17:11:32
问题 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 below. Kindly help me out. PS: I call return; after the finish(); so that the rest of the onCreate() is not executed. 07-26 16:46:26.902 14569-14569/E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.RuntimeException: Unable to destroy activity

AsyncTask in onDestroy() not being executed

﹥>﹥吖頭↗ 提交于 2019-12-10 12:10:25
问题 I want to send logout information to server, when the app gets destroyed. Here's the code: @Override protected void onDestroy() { try { Log.i("myApp", "Activity destroyed"); SharedPreferences prefs1 = getSharedPreferences("com.my.app", Context.MODE_PRIVATE); Log.i("myApp", "step1"); String response; Log.i("myApp", "step2"); response = HttpPOSTer.logout(EventCodes.LOGOUT, LOGOUT_EVENTCODE, prefs.getString("sessionID", "null")); Log.i("myApp", "step3"); if (response.equals("logout")) { Log.i(

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

江枫思渺然 提交于 2019-12-09 09:44:37
问题 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