Search code examples
androidflutterbackgroundalarmmanager

How to launch app like Google's alarm app using alarm_manager in flutter?


I'm making alarm app using android alarm manager in flutter.

Alarm is correctly working by using this hack. But there is problem that some device doesn't launch my app when alarm is fired on background.

For example, When set the alarm and click home button, just callback function has been called, app hasn't been launch.

Using Samsung s8, app is launched when alarm is fired. But emulator sdk_gphone_x86_arm and Samsung s10 doesn't launch app.

I want to make google's alarm app, but some device doesn't launch app. what is problem?


Solution

  • Finally, I find solution using few days!!

    CAUSE:

    Android 10.0(Q) prevent to start Active in background. You can see document here.

    SOLUTION:

    1. Add this in Manifest <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    2. Allow permission at your flutter app
      (Route: Setting -> Apps & notifications -> Your flutter app -> Advanced -> Display over other apps)

    REFERENCE:

    cannot start activity background in android 10, android Q