Skip to content

Commit 1e44daf

Browse files
author
Xia Ning
committed
fix sleep logic
1 parent 0a97c53 commit 1e44daf

1 file changed

Lines changed: 9 additions & 15 deletions

File tree

  • Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced

Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/RTMPStreaming.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import android.content.Context;
44
import android.os.AsyncTask;
55
import android.os.Bundle;
6-
import android.os.Handler;
76
import android.text.TextUtils;
87
import android.util.Log;
98
import android.view.LayoutInflater;
@@ -690,21 +689,16 @@ public void run() {
690689
private final AsyncTask retryTask = new AsyncTask() {
691690
@Override
692691
protected Object doInBackground(Object[] objects) {
693-
while (true){
694-
retry();
695-
}
696-
}
697-
698-
private void retry(){
699-
Handler handler = new Handler();
700-
handler.postDelayed(new Runnable() {
701-
public void run() {
702-
if(publishing)
703-
return;
704-
engine.addPublishStreamUrl(et_url.getText().toString(), transCodeSwitch.isChecked());
705-
retry();
692+
Integer result = null;
693+
for (int i = 0; i < MAX_RETRY_TIMES; i++) {
694+
try {
695+
Thread.sleep(60 * 1000);
696+
} catch (InterruptedException e) {
697+
Log.e(TAG, e.getMessage());
706698
}
707-
}, 60 * 1000);
699+
result = engine.addPublishStreamUrl(et_url.getText().toString(), transCodeSwitch.isChecked());
700+
}
701+
return result;
708702
}
709703
};
710704
}

0 commit comments

Comments
 (0)