Skip to content

In KMP mode, calling createNotification(NotificationType.ALERT).show() on Android will cause a crash. The version is 2.0.0, and the reason is as follows: #14

@tangzhihua

Description

@tangzhihua

android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
at android.view.ViewRootImpl.setView(ViewRootImpl.java:1728)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:472)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:172)
at android.app.Dialog.show(Dialog.java:979)
at NativeNotify_androidKt$createNotification$2.show(NativeNotify.android.kt:37)
at Notification.show$default(NativeNotify.kt:18)
at cn.skyduck.app.utils.toast.NotificationUtilKt.showAlert(NotificationUtil.kt:24)

In Android, the parameter context for AlertDialog.Builder(context) must be an Activity context. I reviewed your code implementation and found that your AppContext only retrieves the Application context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions