I've made a rudimentary Data logging app, which is supposed to have the user input values into a dynamic and often large number of EditText views. Once the user has finished entering all of the Data, a button can be pressed which takes a picture of the data entry (bear with me about storing the input as a picture, there are specific reasons for this), and saves the picture to storage.
Problem: It works very well, except for one particular issue. On occasion, when the user puts the phone into idle (which occurs frequently before the input actually gets saved), all of the input in the EditText views will clear (making me a very angry/sad person). What's more, it's only ever occured when I'm in the field and unable to look at the log files in eclipse to figure out what methods might be being called differently than normal.
Question: Why is it that the values in my EditTexts persist most of the time when the phone goes to and from idle, yet they clear on seemingly random (and often inconvenient) occasions?
I have a feeling that this is caused by onStop() being called instead of onPause() (or perhaps vice versa) on certain occasions, but my knowledge of these methods isn't quite up to speed yet. Also, I'm aware that this issue could be solved via a sharedPreferences file (or some such idea), but I would like to know what is occuring for the sake of understanding more than anything else.
Details:
-I'm not sure if any of this code might be relevant to the question in a meaningful way, but I'll include a snippet of my onCreate() method if it helps. Let me know if I should add anything else:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_input_param);
Intent intent = getIntent();
//Rest of the code just builds the layout from data taken from the intent
-I haven't overridden any of the lifecycle methods (i.e. onStop(), onResume(), etc.) except for onCreate(). None of the other methods in my activity should have anything to do with the issue/ as far as I can tell
No comments:
Post a Comment