I have a BaseActivity that gets extended by every other activity. The thing is, I have the music muted whenever the user leaves (onPause) the activity. I also stop listening for telephone calls. The problem is, onPause
is getting called whenever the user switches between activities, meaning the app is unnecessarily muting and stopping telephonymanager
, even though it should only be muting and stopping telephonymanager
if the user were to leave the app.:
@Override
protected void onPause() {
Log.v(TAG, "IN onPause!");
// unregister phone listener to telephony manager
tManager.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE);
mute();
super.onPause();
}
Now say I switch between public class myClass extends BaseActivity
and switch to public class myOtherClass extends BaseActivity
. This switch is unnecessarily executing onPause
, even though I only want onPause
to be called when the user leaves the app. What should I do?
Thanks for the expert advice,
Rich
onPause
method of anActivity
gets called when anotherActivity
comes into the foreground: developer.android.com/reference/android/app/… – Laborstelephoney manager
when the user exits the app. Since I can't useonPause
, what should I use? – Crumhorn