现象:
正常流程:
答题开始之前,先检查是否有录音录像权限(结果记录到sharedpreferences中),然后定位(开启自定义CountDownTimer每秒钟检查定位结果),然后进入答题。
1. 当不需要定位的时候,sharedpreferences最终是有记录的。
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<boolean name="55126f22585729fdc4c96bf2_video" value="true" />
<boolean name="54cecf63585729fdc4af61f3_video" value="true" />
</map>
2. 当需要定位的时候,sharedpreferences最终内容为空。
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map />
由于这两个操作是完全不搭嘎的,比较难理解。
在debug中发现,当准备调用定位的计时器时,此时sharedpreferences中还是有值的
// 可以开启定位,等定位,1分钟,每1s检查一次
mc = new MyCount(locationWaitingMinute * 1000, 1000);
mc.start();
在MyCount的第一次onTick中,sharedpreferences就被清空了
/* 定义一个倒计时的内部类 */
class MyCount extends CountDownTimer {
public MyCount(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
@Override
public void onFinish() {
Log.d(TAG, "count down finish");
if (baiduClient != null) {
baiduClient.stopLocation();
}
}
@Override
public void onTick(long millisUntilFinished) {
Log.d(TAG, "on Tick");
String text = getString(R.string.locate_loading_first);
String textFormat = String.format(text, locationWaitingMinute
- millisUntilFinished / 1000);
progressDialog.setProgressText(textFormat);
if (receivedGPS) {
this.cancel();
}
}
}
目前未找到原因。