|
@@ -13,14 +13,16 @@ public class PlayMusicReceiver extends BroadcastReceiver {
|
|
|
String action = intent.getAction();
|
|
|
if (action.equals(Intent.ACTION_HEADSET_PLUG)) {
|
|
|
if (intent.hasExtra("state")) {
|
|
|
- if (intent.getIntExtra("state", 0) == 0) {
|
|
|
+ int state = intent.getIntExtra("state", 0);
|
|
|
+ if (state == 0) {
|
|
|
//无耳机插入
|
|
|
Constants.HEADSET_PLUE_TAG = "";
|
|
|
- } else if (intent.getIntExtra("state", 0) == 1) {
|
|
|
+ } else if (state == 1) {
|
|
|
//有耳机插入
|
|
|
Constants.HEADSET_PLUE_TAG = "有线耳机";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|