Skip to content

Commit 8cdac83

Browse files
committed
android: fix startRingtone use handler inside thread without looper
1 parent c0fa1f5 commit 8cdac83

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

android/src/main/java/com/zxcpoiu/incallmanager/InCallManagerModule.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import android.os.PowerManager;
3232
import android.os.Build;
3333
import android.os.Handler;
34+
import android.os.Looper;
3435
import android.provider.Settings;
3536
import androidx.annotation.Nullable;
3637
import androidx.core.app.ActivityCompat;
@@ -919,6 +920,8 @@ public void startRingtone(final String ringtoneUriType, final int seconds) {
919920
@Override
920921
public void run() {
921922
try {
923+
Looper.prepare();
924+
922925
Log.d(TAG, "startRingtone(): UriType=" + ringtoneUriType);
923926
if (mRingtone != null) {
924927
if (mRingtone.isPlaying()) {
@@ -978,9 +981,11 @@ public void run() {
978981
}
979982
}, seconds * 1000);
980983
}
984+
985+
Looper.loop();
981986
} catch(Exception e) {
982987
wakeLockUtils.releasePartialWakeLock();
983-
Log.d(TAG, "startRingtone() failed");
988+
Log.e(TAG, "startRingtone() failed", e);
984989
}
985990
}
986991
};

0 commit comments

Comments
 (0)