private void prepareSendAiBroadcast(String aiPath) {
int i = 0;
// while 循環 三次
while (i == 3) {
//如果文件不存在
if (!FileHelper.isFileExists(aiPath)) {
// sleep 2秒等待文件
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
LogHelper.e(TAG, " InterruptedExceptiont!!");
}
i++;
// 如果重試三次返回空
if (i == 3) {
return;
}
} else {
// 通过广播将路径发出
Context context = Utils.getContext();
Intent intent = new Intent(ACTION_AI_DATA);
intent.putExtra(EXTRA_PATH, aiPath);
LogHelper.i(TAG, "Start sendBroadcast AI_DATA_LOAD_COMPLETED!!");
context.sendBroadcast(intent, AI_DATA_PERMISSION);
break;
}
}
while (!FileHelper.isFileExists(aiPath)) {
if (i <= 3) {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
LogHelper.e(TAG, " InterruptedExceptiont!!");
}
i++;
} else {
return;
}
}
}
08-31
6382
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)