`

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)
      }
   }
}











分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics