Skip to content

Android SDK is making background requests when the app is closed observed up to 9 minutes #104

@rubixhacker

Description

@rubixhacker

Expected Behavior

After the initial flush on close, the Amplitude SDK should not make additional background requests.

Current Behavior

Background network requests are made every 30 seconds, depending on the device, for one minute to nine minutes. Even with flushEventsOnClose set as false and flushMaxRetries set as zero.

Possible Solution

The issue appears to lie in amplitudeScope, AndroidLifecyclePlugin should cancel all children scopes and then restart all the children scopes when the app returns to the foreground

Steps to Reproduce

  1. Implement the Amplitude SDK in an Android app
  2. With the app running open the App Inspection tab in Android Studio
  3. Go to the Network Inspector tab
  4. Background the app (close or hit the home button)
  5. Notice that network calls are made every 30 seconds to https://api2.amplitude.com/2/httpapi

Environment

  • Android Plugin Version: 1.6.1
  • Device: Samsung Fold 3, Surface Duo, Pixel 6a and Android Emulator
  • Device OS and Version: Android, multiple versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions