|
|
@@ -1,6 +1,9 @@
|
|
|
package com.yingyangfly.game.play
|
|
|
|
|
|
import android.annotation.SuppressLint
|
|
|
+import android.app.Activity
|
|
|
+import android.app.ActivityManager
|
|
|
+import android.content.Context
|
|
|
import android.content.Intent
|
|
|
import android.os.Build
|
|
|
import android.os.Bundle
|
|
|
@@ -428,8 +431,10 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
}
|
|
|
}
|
|
|
if (voicePlayer != null) {
|
|
|
- voicePlayer?.play(it) {
|
|
|
+ if (isTopActivity(this)) {
|
|
|
+ voicePlayer?.play(it) {
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -517,4 +522,13 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
"completionTrainingDialog"
|
|
|
)
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断当前activity是否位于栈顶
|
|
|
+ */
|
|
|
+ private fun isTopActivity(activity: Activity): Boolean {
|
|
|
+ val am = activity.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
|
|
|
+ val cn = am.getRunningTasks(1)[0].topActivity
|
|
|
+ return cn!!.className == activity.javaClass.name
|
|
|
+ }
|
|
|
}
|