在onFinish of countDownTimer中,我使用以下代码播放声音:
AssetFileDescriptor afd = getActivity().getApplicationContext().getAssets().openFd("NoticeWarning.wav");
mMediaPlayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
afd.close();
mMediaPlayer.prepare();
mMediaPlayer.start();现在,当我启动timer并在android设备上使用Power将设备放入睡眠模式时,当timer完成声音时,在Android2.3.3(GalaxyS2)中不播放声音。
在计时器结束后,声音不会在睡眠模式下播放,过了一段时间,当我打开设备时,按下电源按钮,再播放声音。这种声音在拥有Android2.2的Galaxy S中播放得很好。
任何人都知道为什么在android 2.3.3中,当设备处于睡眠模式时,声音不会播放。
附加信息
如果2.3.3设备与USB电缆连接,则不会出现上述问题。
发布于 2012-10-30 10:22:22
欢迎来到设备/操作系统不一致的令人兴奋的世界。
考虑使用AlarmManager代替
https://stackoverflow.com/questions/13136745
复制相似问题