activity-state

onSaveInstanceState is not getting called

社会主义新天地 提交于 2019-12-30 11:04:27
问题 I have an activity which starts various activities for result codes and on getting results in onActivityResult method it starts appropriate activity based on result code. onSaveInstanceState is not getting called in Activity which started for result. For example Navigation Activity starts Activity A as : Intent intent = new Intent(this, A.class); startActivityForResult(intent, Constants.REQUEST_CODE); Then A finishes by setting result code so App will redirect to Navigation activity again and

When to use saveInstanceState() method?

久未见 提交于 2019-12-11 19:25:06
问题 I know saveInstanceState() is used to store activity variables, text in EditText, etc. But I have a doubt that should I save state of view? Let me give you a scenario. My view has 3 buttons. On clicking one of them, a WebView is displayed to user (in same activity). Now if app gets killed, should I save state that user was displayed WebView when app got killed and when activity gets recreated display WebView instead of buttons? Other scenario is, I have 3 tabs in view. Selecting each tab

onActivityResult no longer being called after onDestroy

懵懂的女人 提交于 2019-12-11 01:18:52
问题 onActivityResult is giving me major headaches. My little game has a title / menu screen. Upon clicking "new game" an Activity is launched which creates a SurfaceView for my game world. When playing, the player can enter buildings in the game world. Upon entering a building I launch the activity for that particular building from my SurfaveView. Here is an example: Intent storeIntent = new Intent(mMinerClass, GeneralStore.class); storeIntent.putExtra("player", mPlayer.save()); ((Activity)

Detecting android application going to background

血红的双手。 提交于 2019-12-03 12:53:24
问题 I need to turn off Bluetooth when my app "goes to background"/"becomes inactive". I tried to do it in onPause() of my MainActivity but that doesn't work since now BT goes off (onPause() of the Mainactivity is fired) even when I start a new activity showing an entity detail of chosen item from the Mainactivity. What I need is some kind of "onPause()" of my App not of a single activity. I think nothing like this exists so is there any preferable solution? 回答1: UPDATE : Beware, according to

onSaveInstanceState is not getting called

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 09:18:33
I have an activity which starts various activities for result codes and on getting results in onActivityResult method it starts appropriate activity based on result code. onSaveInstanceState is not getting called in Activity which started for result. For example Navigation Activity starts Activity A as : Intent intent = new Intent(this, A.class); startActivityForResult(intent, Constants.REQUEST_CODE); Then A finishes by setting result code so App will redirect to Navigation activity again and onActivityResult method will called. So my question is: Why Activity A's onSaveInstanceState is not