Android的,暂停和恢复处理回调
我有我使用一个处理程序如下:
I have a handler that I am using as follows:
handler.postDelayed(Play, 1000);
在我的应用程序的onPause()之前,这就是所谓的做,我需要暂停它,并告诉它不执行postDelayed,直到我重新开始。
when my application onPause() is called before this is done, I need to pause it and tell it not to perform the "postDelayed" until I resume.
这是可能的,或者是有另一种方式?
is this possible, or is there an alternative way?
我的问题是,当在onPause()被调用我暂停音频(SoundManager类),但如果这handler.postDelayed之后被调用时,声音不会被暂停,并会继续与我在后台应用程序中播放。
My problem is that when onPause() is called I pause the audio (SoundManager), but if this handler.postDelayed is called after that, the audio will not be paused and will continue to play with my application in the background.
@Override
public void onPause()
{
Soundmanager.autoPause()
}
但1000毫秒后postDelayed开始声音再次播放。
but then the postDelayed after 1000ms starts the audio playing again.
你有没有试着用:
@Override
public void onPause()
{
handler.removeCallbacks(Play);
Soundmanager.autoPause()
}
芨芨草