Skip to content

Keep the Android host Activity alive when a backgrounded survey auto-closes #94

Closed

Description

@lukaszreszetow

Problem

When the Android host app goes to the background while a survey is on its ending (“Thank you”) card, the survey can auto-close after the fragment state has been saved. The SDK's FormbricksFragment.safeDismiss() then calls activity?.finish(), closing the host Activity; returning from Recents starts the app fresh. The same fallback also runs if dismissal throws. The SDK should not terminate its host to dismiss its own survey.

Goal

Dismiss or defer dismissal of only the survey sheet across background/foreground transitions without finishing the host Activity.

Done when

  • Auto-close on the ending card while the Activity is backgrounded does not finish or restart the host; returning to the app leaves the host usable and the survey closes safely.
  • Normal foreground auto-close and user-initiated close still dismiss the survey, without leaving an intercepting sheet or duplicate survey on resume.
  • A saved-state or dismissal-error path never terminates the host Activity; lifecycle regression coverage exercises both foreground and background closure where feasible.

Technical context

Verified against formbricks/android current main: android/src/main/java/com/formbricks/android/webview/FormbricksFragment.kt routes the WebView close callback through safeDismiss() and calls activity?.finish() both when the fragment is not added/state is saved and in its exception handler. dismissAllowingStateLoss() is one reporter-suggested approach, not an agreed requirement. Android instrumented fragment tests exist under android/src/androidTest/java/com/formbricks/android/webview/.

References

Activity

  1. changed the title [-]Survey auto-close while the app is in the background calls activity.finish() and closes the host Activity[/-] [+]Keep the Android host Activity alive when a backgrounded survey auto-closes[/+] on Oct 12, 2026
  2. self-assigned this
    on Nov 3, 2026
  3. ivy-formbricks commented on Nov 9, 2026

    @ivy-formbricks

    The fix is merged into main in #99 and will ship with the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions