Skip to content

Commit bf4d4eb

Browse files
committed
Show consent screen only if activity is still open
1 parent 3186209 commit bf4d4eb

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

  • app/src/main/kotlin/com/njlabs/showjava/utils

app/src/main/kotlin/com/njlabs/showjava/utils/Ads.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package com.njlabs.showjava.utils
2020

2121
import android.annotation.SuppressLint
22+
import android.app.Activity
2223
import android.content.Context
2324
import android.content.Intent
2425
import android.content.SharedPreferences
@@ -68,7 +69,9 @@ class Ads(val context: Context) {
6869
consentForm = ConsentForm.Builder(context, URL(context.getString(R.string.privacyPolicyUrl)))
6970
.withListener(object : ConsentFormListener() {
7071
override fun onConsentFormLoaded() {
71-
consentForm.show()
72+
if (context is Activity && !context.isFinishing) {
73+
consentForm.show()
74+
}
7275
}
7376

7477
override fun onConsentFormOpened() {

0 commit comments

Comments
 (0)