Is there any way to refresh or update the activity in android? for example: I am having two activities Counter1 and Counter2 activity.Here in the two activities there is one text view(tv_count) and the two buttons(bt_plus and bt_minus), plus and minus button respectively.when the user clicks on the respective button count(textview value) will get increase & decrease, the count starts from zero now the count=4,where I am saving the count values in a model class, starting the second activity without finishing the first activity.
button_next.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent=new Intent(getApplicationContext(), Counter2.class);
startActivity(intent);
}
});
Now I am navigating to the second activity where i can further increase the count value from 4,now count=6.
button_back.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
finish();
}
});
when i click back the current activity will get finish.But the value of the count remains same 4 which should be updated to 6 in Counter1 activity.
As per surfing, they are saying to finish the first activity before moving to second activity.But i don't want to finish the first activity rather to do some operation onResume() or onRestart() and onPause().
Solution need: To update the value of a count on the first activity without finishing and calling the activity explicitly.
Below are the referral links: link1 link2
This question might be asked already but I want some one to brief me clearly. It will be very helpful,Thanks in Advance..
EDITED:Actually this is just about a single value and single textview actually my requirement is some thing else.. I am developing a restaurant app where there will be many products in list view and in expandable list view which is in a sliding tabs. when the user add pizza the count will get increase when the user search the same product in search view the count can be increased.. the increased count is updated in model class but in the list view of sliding tabs is not getting updated.