X-SLAYER / flutter_overlay_window

Flutter plugin for displaying flutter app over other apps on the screen
https://pub.dev/packages/flutter_overlay_window
MIT License
110 stars 114 forks source link

Open overlay causes crashing when upgrade Android SDK to 34 #120

Open ducviet321 opened 3 months ago

ducviet321 commented 3 months ago

Can be fixed in android/src/main/java/flutter/overlay/window/flutter_overlay_window/OverlayService.java

Find and Replace

        startForeground(OverlayConstants.NOTIFICATION_ID, notification);

To

        if (Build.VERSION.SDK_INT >= 34) {
            startForeground(
                    OverlayConstants.NOTIFICATION_ID,
                    notification,
                    ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE);
        } else {
            startForeground(
                    OverlayConstants.NOTIFICATION_ID,
                    notification);
        }

And add import import android.content.pm.ServiceInfo;

X-SLAYER commented 3 months ago

Thank you for bringing up this issue and suggesting a solution! Could you please open a Pull Request (PR) with the following changes? This will allow everyone to benefit from the fix.

harshmdr commented 2 months ago

Please upgrade package with above fix.