¡@

Home 

2014/10/16 ¤W¤È 08:20:49

android Programming Glossary: onretainnonconfigurationinstance

AsyncTask won't stop even when the activity has destroyed

http://stackoverflow.com/questions/2531336/asynctask-wont-stop-even-when-the-activity-has-destroyed

activity is destroyed and created again. So I override the onRetainNonConfigurationInstance method and save all the downloaded data executed in the AsyncTask...

Save cache when rotate device

http://stackoverflow.com/questions/3250987/save-cache-when-rotate-device

to do to get it right. What you want to do is implement onRetainNonConfigurationInstance in your activity. This is called just before your activity is.. a moment e.g. for screen rotation . Your implementation of onRetainNonConfigurationInstance may return any object it likes 'this' is a good choice or in.. that will be the object you previously passed back from onRetainNonConfigurationInstance and you can extract any information you want from it. This generally..

Is AsyncTask really conceptually flawed or am I just missing something?

http://stackoverflow.com/questions/3357477/is-asynctask-really-conceptually-flawed-or-am-i-just-missing-something

null mWorker.mActivity this ... @Override public Object onRetainNonConfigurationInstance return mWorker @Override protected void onDestroy super.onDestroy..

How to prevent Custom Views from losing state across screen orientation changes

http://stackoverflow.com/questions/3542333/how-to-prevent-custom-views-from-losing-state-across-screen-orientation-changes

screen orientation changes I've successfully implemented onRetainNonConfigurationInstance for my main activity to save and restore certain critical components.. Is there a crafty way to implement something similar to onRetainNonConfigurationInstance for a custom view or do I need to just implement methods in..

Background task, progress dialog, orientation change - is there any 100% working solution?

http://stackoverflow.com/questions/3821423/background-task-progress-dialog-orientation-change-is-there-any-100-working

supply the current Activity to the constructor. Step #4 In onRetainNonConfigurationInstance return the AsyncTask after detaching it from the original now.. and onPostExecute are suspended between the start of onRetainNonConfigurationInstance and the end of the subsequent onCreate . Here is a sample project..

How to save state during orientation change in Android if the state is made of my classes?

http://stackoverflow.com/questions/3915952/how-to-save-state-during-orientation-change-in-android-if-the-state-is-made-of-m

object specifically for orientation changes using onRetainNonConfigurationInstance . See this Android Developers blog post . Just be careful not..

Which one to use: onSaveInstanceState vs. onRetainNonConfigurationInstance?

http://stackoverflow.com/questions/4285877/which-one-to-use-onsaveinstancestate-vs-onretainnonconfigurationinstance

one to use onSaveInstanceState vs. onRetainNonConfigurationInstance As far as I can see onRetainNonConfigurationInstance is a redundant.. vs. onRetainNonConfigurationInstance As far as I can see onRetainNonConfigurationInstance is a redundant callback. If my activity has really expensive.. share improve this question As far as I can see onRetainNonConfigurationInstance is a redundant callback. No it is not. If my activity has really..

Handle screen orientation changes when there are AsyncTasks running

http://stackoverflow.com/questions/4584015/handle-screen-orientation-changes-when-there-are-asynctasks-running

way of fixing 2.3 to switch back to portrait I know about onRetainNonConfigurationInstance but I'm not sure it would be a good idea to save the AsyncTask..

Best practice: AsyncTask during orientation change

http://stackoverflow.com/questions/7128670/best-practice-asynctask-during-orientation-change

survive and updating it with the new activity instance via onRetainNonConfigurationInstance Just canceling the task when the activity is destroyed and restarting.. this issue. This is very bad practice. Do NOT use Activity#onRetainNonConfigurationInstance either. This is less modular and not well suited for Fragment..

Is that possible to check was onCreate called because of orientation change?

http://stackoverflow.com/questions/7295804/is-that-possible-to-check-was-oncreate-called-because-of-orientation-change

need logic of default onCreate . @Override public Object onRetainNonConfigurationInstance prefsEditor.putString fromOrient true prefsEditor.commit .. from by changing orientation. If orientation changed onRetainNonConfigurationInstance then we set the flag value in preference which let us know whether..

When to call activity context OR application context?

http://stackoverflow.com/questions/7298731/when-to-call-activity-context-or-application-context

the handle to the binding between Activity instances via onRetainNonConfigurationInstance . Android internally tracks bindings via these ServiceConnections..

Android Fragments. Retaining an AsyncTask during screen rotation or configuration change

http://stackoverflow.com/questions/8417885/android-fragments-retaining-an-asynctask-during-screen-rotation-or-configuratio

SETUP UI OBJECTS restoreAsyncTask @Override public Object onRetainNonConfigurationInstance if pd null pd.dismiss if asyncLoginThread null return asyncLoginThread.. asyncLoginThread null return asyncLoginThread return super.onRetainNonConfigurationInstance private void restoreAsyncTask pd new ProgressDialog Login.this.. entry or launch new Login Succesful Activity I cant use onRetainNonConfigurationInstance since it has to be called from the Activity and not the Fragment..

checkbox in listview for multiple selection of contacts

http://stackoverflow.com/questions/9834723/checkbox-in-listview-for-multiple-selection-of-contacts

AsyncTask won't stop even when the activity has destroyed

http://stackoverflow.com/questions/2531336/asynctask-wont-stop-even-when-the-activity-has-destroyed

eg when the android screen's orientation changes then the activity is destroyed and created again. So I override the onRetainNonConfigurationInstance method and save all the downloaded data executed in the AsyncTask. My purpose of doing this is to not have AsyncTask run..

Save cache when rotate device

http://stackoverflow.com/questions/3250987/save-cache-when-rotate-device

is discouraged because there's so much work you have to do to get it right. What you want to do is implement onRetainNonConfigurationInstance in your activity. This is called just before your activity is killed when the system knows it will be restarting it in a.. is killed when the system knows it will be restarting it in a moment e.g. for screen rotation . Your implementation of onRetainNonConfigurationInstance may return any object it likes 'this' is a good choice or in your case your cache . This object will be held and made available.. proceed as you would normally. If it returns non null then that will be the object you previously passed back from onRetainNonConfigurationInstance and you can extract any information you want from it. This generally means that you don't need anything from the savedInstanceState..

Is AsyncTask really conceptually flawed or am I just missing something?

http://stackoverflow.com/questions/3357477/is-asynctask-really-conceptually-flawed-or-am-i-just-missing-something

mWorker Worker getLastNonConfigurationInstance if mWorker null mWorker.mActivity this ... @Override public Object onRetainNonConfigurationInstance return mWorker @Override protected void onDestroy super.onDestroy if mWorker null mWorker.mActivity null void startWork..

How to prevent Custom Views from losing state across screen orientation changes

http://stackoverflow.com/questions/3542333/how-to-prevent-custom-views-from-losing-state-across-screen-orientation-changes

to prevent Custom Views from losing state across screen orientation changes I've successfully implemented onRetainNonConfigurationInstance for my main activity to save and restore certain critical components across screen orientation changes. But it seems my.. X Y plot and the plotted points are stored in the custom view. Is there a crafty way to implement something similar to onRetainNonConfigurationInstance for a custom view or do I need to just implement methods in the custom view which allow me to get and set its state Thanks..

Background task, progress dialog, orientation change - is there any 100% working solution?

http://stackoverflow.com/questions/3821423/background-task-progress-dialog-orientation-change-is-there-any-100-working

and a setter. Step #3 When creating the AsyncTask supply the current Activity to the constructor. Step #4 In onRetainNonConfigurationInstance return the AsyncTask after detaching it from the original now going away activity. Step #5 In onCreate if getLastNonConfigurationInstance.. If you follow the above recipe it will all work. onProgressUpdate and onPostExecute are suspended between the start of onRetainNonConfigurationInstance and the end of the subsequent onCreate . Here is a sample project demonstrating the technique. Another approach is to ditch..

How to save state during orientation change in Android if the state is made of my classes?

http://stackoverflow.com/questions/3915952/how-to-save-state-during-orientation-change-in-android-if-the-state-is-made-of-m

your own non view state data you can actually pass an arbitrary object specifically for orientation changes using onRetainNonConfigurationInstance . See this Android Developers blog post . Just be careful not to put any Views or other references to the pre rotation Context..

Which one to use: onSaveInstanceState vs. onRetainNonConfigurationInstance?

http://stackoverflow.com/questions/4285877/which-one-to-use-onsaveinstancestate-vs-onretainnonconfigurationinstance

one to use onSaveInstanceState vs. onRetainNonConfigurationInstance As far as I can see onRetainNonConfigurationInstance is a redundant callback. If my activity has really expensive initialization.. one to use onSaveInstanceState vs. onRetainNonConfigurationInstance As far as I can see onRetainNonConfigurationInstance is a redundant callback. If my activity has really expensive initialization I am better off using onSaveInstanceState. Saved.. any guideline for using one API vs. the other Thanks. android share improve this question As far as I can see onRetainNonConfigurationInstance is a redundant callback. No it is not. If my activity has really expensive initialization I am better off using onSaveInstanceState...

Handle screen orientation changes when there are AsyncTasks running

http://stackoverflow.com/questions/4584015/handle-screen-orientation-changes-when-there-are-asynctasks-running

stopped. Is there any other way of doing this or is there a way of fixing 2.3 to switch back to portrait I know about onRetainNonConfigurationInstance but I'm not sure it would be a good idea to save the AsyncTask instance mainly because the class that extends AsyncTask..

Best practice: AsyncTask during orientation change

http://stackoverflow.com/questions/7128670/best-practice-asynctask-during-orientation-change

sure not the way you should handle this. Letting the task survive and updating it with the new activity instance via onRetainNonConfigurationInstance Just canceling the task when the activity is destroyed and restarting it when the activity is created again. Binding the.. this question Do NOT use android configChanges to address this issue. This is very bad practice. Do NOT use Activity#onRetainNonConfigurationInstance either. This is less modular and not well suited for Fragment based applications. You can read my article describing how..

Is that possible to check was onCreate called because of orientation change?

http://stackoverflow.com/questions/7295804/is-that-possible-to-check-was-oncreate-called-because-of-orientation-change

per need logic of orientation changed. else do as per need logic of default onCreate . @Override public Object onRetainNonConfigurationInstance prefsEditor.putString fromOrient true prefsEditor.commit return null @Override protected void onDestroy if fromOrientation.. like by defalut we are considering that onCreate is not called from by changing orientation. If orientation changed onRetainNonConfigurationInstance then we set the flag value in preference which let us know whether onCreate is called from on orientation or not. And finally..

When to call activity context OR application context?

http://stackoverflow.com/questions/7298731/when-to-call-activity-context-or-application-context

an Activity if you wish to pass the ServiceConnection i.e. the handle to the binding between Activity instances via onRetainNonConfigurationInstance . Android internally tracks bindings via these ServiceConnections and holds references to the Contexts that create the bindings...

Android Fragments. Retaining an AsyncTask during screen rotation or configuration change

http://stackoverflow.com/questions/8417885/android-fragments-retaining-an-asynctask-during-screen-rotation-or-configuratio

icicle super.onCreate icicle setContentView R.layout.login SETUP UI OBJECTS restoreAsyncTask @Override public Object onRetainNonConfigurationInstance if pd null pd.dismiss if asyncLoginThread null return asyncLoginThread return super.onRetainNonConfigurationInstance private.. onRetainNonConfigurationInstance if pd null pd.dismiss if asyncLoginThread null return asyncLoginThread return super.onRetainNonConfigurationInstance private void restoreAsyncTask pd new ProgressDialog Login.this if getLastNonConfigurationInstance null asyncLoginThread.. if result pd.dismiss Handle the response. Either deny entry or launch new Login Succesful Activity I cant use onRetainNonConfigurationInstance since it has to be called from the Activity and not the Fragment same goes with getLastNonConfigurationInstance . I've read..

checkbox in listview for multiple selection of contacts

http://stackoverflow.com/questions/9834723/checkbox-in-listview-for-multiple-selection-of-contacts