2013.09.02(2)——— android 耳机意外拔出关闭声音

2013.09.02(2)——— android 耳机意外拔出关闭声音


<receiver android:name=".MusicIntentReceiver">
   <intent-filter>
      <action android:name="android.media.AUDIO_BECOMING_NOISY" />
   </intent-filter></receiver>





public class MusicIntentReceiver implements android.content.BroadcastReceiver {
   @Override
   public void onReceive(Context ctx, Intent intent) {
      if (intent.getAction().equals(
                    android.media.AudioManager.ACTION_AUDIO_BECOMING_NOISY)) {
          // signal your service to stop playback
          // (via an Intent, for instance)
      }
   }
}











猜你喜欢

转载自trylovecatch.iteye.com/blog/1935471