I have a fragment, which have various questions. These question are fetched dynamically. Page does not have any save button. Pages answer(s) is saved once user navigate away from page.
onStop()
method is used to save the answer.
Problem: I have several question pages. So suppose user saves some answer in page one and quickly navigate to page 2 and page 3, answers are not getting saved. Below is the pictorial representation to explain
My QuestionPagefragment onStop() method have these calls
public void onStop()
{
super.onstop();
new LongOperation().execute("");
}
private class LongOperation extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... params) {
TaskAdapter adapter = TaskAdapter.getInstance();
adpater.saveDataInCache();
//create result
adpater.updateResults();
//update result
adpater.updateDatabase();
}
@Override
protected void onPostExecute(String result) {
}
@Override
protected void onPreExecute() {}
@Override
protected void onProgressUpdate(Void... values) {}
}
My question is, how do I save the result in onStop(). When I am adding a message dialog to indicate progress is going on, the message dialog comes up in main page not in the question page, as it is called on onStop;. Can anybody suggest me some thing .