Skip to content

I get error Activity Context must be set to non-null value in Android in all rememberAdHandlers #143

Description

@chirag38-unity

I use navigation3 setup and try to load ads in the top of the screen. I also tried setting up the rememberBannerAd in child composables but I get the same error.

An example

@OptIn(ExperimentalComposeUiApi::class, KoinExperimentalAPI::class, ExperimentalCalfUiApi::class, DependsOnGoogleMobileAds::class)
@composable
fun MainScreen(
onNavigateToDetailsFromRoot: (String) -> Unit,
) {
val homeBackStack = rememberMFBackStack(MFScreens.Home)
val feedBackStack = rememberMFBackStack(MFScreens.Feed)
var selectedTab by rememberSaveable { mutableStateOf(MainTab.HOME) }
var pendingNavigation by remember { mutableStateOf<(() -> Unit)?>(null) }

pendingNavigation?.let { navigate ->
    InterstitialAd(
        onDismissed = { pendingNavigation = null; navigate() },
        onFailure = { pendingNavigation = null; navigate() },
    )
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions