I have an application I am creating with a DashboardActivity & a SettingsActivity. On the dashboard, I have one object displayed, but when I go into settings, I want to be able to select/deselect X options. Once the user clicks the back button, I save that data locally and to the server. Once the phone receives a success message from the server that it was stored properly, I want to reload the dashboard.
I thought I would do this with the onPause and onResume, but they are called when the DashboardActivity is first created. What would be the best way to reload the dashboard by calling my web service after the settings were saved to the server? Here is what I am doing when the back button is hit
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
//Save data to the server once the user hits the back button
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
SchoolSearchActivity.this.divisionProxy = new DivisionProxy(SchoolSearchActivity.this.saveUserDivisionHandler);
SchoolSearchActivity.this.divisionProxy.submitUserDivisions(SchoolSearchActivity.this.userDivisions, SchoolSearchActivity.this.user_id);
//SchoolSearchActivity.this.finish();
//Toast.makeText(SchoolSearchActivity.this, "Divisions Saved",Toast.LENGTH_LONG).show();
}
return true;
}
The above opens an HTTP connection, and when the response is received, the handler processes the response. I want to: 1) submit the data to the server 2) return to the previous activity 3) show a progress dialog until the response from #1 returns (response handler is in the settings activity; and we are now in the dashboard activity) 4) "refresh" the dashboard
What is the best way to accomplish this so I can just resume the dashboard as it was. Like I said, when I overwrite the onResume method, it is called when the activity is first created. I was considering putting my webservice call in onResume, so it's called once everytime you make it to the Activity, but it doesn't seem like the cleanest way.
What would you suggest for 1-4?