SoFunction
Updated on 2025-03-02

Solution to automatically close the FM APP after unplugging the headset during android FM playback

1. Modify
Add to:
Copy the codeThe code is as follows:

public static final int MSG_EXIT_FM = 1234;
private Handler sHandler11 = new Handler() {
@Override
public void handleMessage(Message msg) {
(TAG, "sHandler11 = " + );
switch () {
case MSG_EXIT_FM:
(());
break;
}
}
};

2. Modify the onReceive method
exist
switchAntennaAsync(mValueHeadSetPlug);
After that add:
Copy the codeThe code is as follows:

if(mValueHeadSetPlug == 1 && mIsPowerUp )
((MSG_EXIT_FM, ),(long)1000);
else
(MSG_EXIT_FM);