Android 判断是否有声音在播放
在Android中,我们可以通过AudioManager来判断是否有声音在播放。
实例1:
源码地址: PhoneWindowManager.java
(frameworks\base\policy\src\com\android\internal\policy\impl)
源码如下:
/*** @return Whether fm is being played right now.*/boolean isFmActive() {final AudioManager am = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);if (am == null) {Log.w(TAG, "isFmActive: couldn't get AudioManager reference");return false;}return am.isFmActive();}