I have button Play/Stop , One button which changes his resource by the playing or not,But when I go to other fragment(Activity) and return to fragment with Play/Stop button, music is playing but resource is default.
If i press button , it stopService and that is OK,only problem is ImageResource change.
My code :
int button_status = 1;
.... other code ...
public void onClick(View v) {
if (button_status == 1){
button_status = 0;
buttonPlayStop.setImageResource(R.drawable.pause);
getActivity().startService(new Intent(getActivity(), Service.class));
}else{
button_status = 1;
buttonPlayStop.setImageResource(R.drawable.play);
getActivity().stopService(new Intent(getActivity(), Service.class));
}
}
Any ideas ?