说明
Purpose of this receiver is to disable keep alives when screen is off
解释
这个接收器的目的是屏幕关闭的时候进行保活。<—翻译的准确性,等更加深刻的分析源码时更正,或者读者自己在下面评论也可以。
介绍
此类为接收器,接收外部传来的广播。
KeepAliveReceiver.java
/*
* Purpose of this receiver is to disable keep alives when screen is off
* */
public class KeepAliveReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (!LinphoneService.isReady()) {
Log.i("Keep alive broadcast received while Linphone service not ready");
return;
} else {
if (intent.getAction().equalsIgnoreCase(Intent.ACTION_SCREEN_ON)) {
LinphoneManager.getLc().enableKeepAlive(true);
} else if (intent.getAction().equalsIgnoreCase(Intent.ACTION_SCREEN_OFF)) {
LinphoneManager.getLc().enableKeepAlive(false);
}
}
}
}