android FM播放时拔出耳机后FM APP自动close解决方法
时间:2020-11-15 14:16:11|栏目:Android代码|点击: 次
1.修改FMRadioService.java
添加:
public static final int MSG_EXIT_FM = 1234;
private Handler sHandler11 = new Handler() {
@Override
public void handleMessage(Message msg) {
FMRadioLogUtils.d(TAG, "sHandler11 = " + msg.what);
switch (msg.what) {
case MSG_EXIT_FM:
android.os.Process.killProcess(android.os.Process.myPid());
break;
}
}
};
2.修改onReceive 方法
在
switchAntennaAsync(mValueHeadSetPlug);
之后添加:
if(mValueHeadSetPlug == 1 && mIsPowerUp )
sHandler11.sendMessageDelayed(sHandler.obtainMessage(MSG_EXIT_FM, FMRadioService.this),(long)1000);
else
sHandler11.removeMessages(MSG_EXIT_FM);
添加:
复制代码 代码如下:
public static final int MSG_EXIT_FM = 1234;
private Handler sHandler11 = new Handler() {
@Override
public void handleMessage(Message msg) {
FMRadioLogUtils.d(TAG, "sHandler11 = " + msg.what);
switch (msg.what) {
case MSG_EXIT_FM:
android.os.Process.killProcess(android.os.Process.myPid());
break;
}
}
};
2.修改onReceive 方法
在
switchAntennaAsync(mValueHeadSetPlug);
之后添加:
复制代码 代码如下:
if(mValueHeadSetPlug == 1 && mIsPowerUp )
sHandler11.sendMessageDelayed(sHandler.obtainMessage(MSG_EXIT_FM, FMRadioService.this),(long)1000);
else
sHandler11.removeMessages(MSG_EXIT_FM);
上一篇:Android实现不同apk间共享数据的方法(2种方法)
栏 目:Android代码
下一篇:android通过jxl读excel存入sqlite3数据库
本文标题:android FM播放时拔出耳机后FM APP自动close解决方法
本文地址:http://www.codeinn.net/misctech/22829.html