Android的,暂停和恢复处理回调 [英] Android, pausing and resuming handler callbacks

查看:184
本文介绍了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()
}

芨芨草

这篇关于Android的,暂停和恢复处理回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆