Git Product home page Git Product logo

flutter_overlay_window's Introduction

👋 Hello! I'm Iheb Briki known as X-SLAYER

I'm a full-stack developer and mainly use Flutter,React & nextJs

Remember, open source is not commercial software development. The projects I share here are just tools I've built for myself to make my life better. Be mindful and respect the time that I (and every other contributor) provide to the community free of charge. 💜

X-SLAYER

flutter_overlay_window's People

Contributors

x-slayer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

flutter_overlay_window's Issues

How to send data from overlay to main app

Greetings,

I am trying to send data from overlay to main app. My use case is that whe I tap the overlay, I call:
await FlutterOverlayWindow.shareData("capture");

Then I the initState of the home widget of the main App, I am listening to the overlay listener
FlutterOverlayWindow.overlayListener.listen((event) { print("Overlay $event"); });

Unfortunately, the listener (in the main app) is not triggering when I call shareData (from the overlay).

Please help! 😭
TIA

Android API30 crashes with a java.lang.IllegalArgumentException

Testing flutter_overlay_window plugin on emulated Android 30 crashes with a java.lang.IllegalArgumentException (Compiled with SDK 31; Emulater version is 31.2.10)

E/AndroidRuntime(31320): java.lang.RuntimeException: Unable to create service flutter.overlay.window.flutter_overlay_window.OverlayService: java.lang.IllegalArgumentException: home.project.demo_overlay_window: Targeting S+ (version 10000 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
E/AndroidRuntime(31320): Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.

I believe that Issue #4 has addressed the similar issue for API 31 and above. Would it possible to lower the API level that PendingIntent.FLAG_IMMUTABLE flag is set with the outgoing pending intent, down to API 30?

Or possibly down to API 23 that the flag is first introduced.

哥们你在pub.dev上的包似乎没更新

  • 今天先是在pub.dev上发现了这个好东西,使用时可以正常打开悬浮窗,但却无法关闭,一调用FlutterOverlayWindow.closeOverlay()就报错:
E/flutter ( 7080): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method close on channel x-slayer/overlay)
E/flutter ( 7080): #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:294:7)
E/flutter ( 7080): <asynchronous suspension>
E/flutter ( 7080): #1      FlutterOverlayWindow.closeOverlay (package:flutter_overlay_window/flutter_overlay_window.dart:83:24)
  • 后来直接下载github上的示例却能打开悬浮窗也能关闭,于是开始对比代码区别,最终发现使用pub.dev上的包时就会出错:
flutter_overlay_window: ^0.3.2

直接下载github上的包到本地使用就正常:

  flutter_overlay_window: 
    path: ./lib/plugins/flutter_overlay_window/{本地包路径}

MissingPluginException (MissingPluginException(No implementation found for method resizeOverlay on channel x-slayer/overlay))

Exception is thrown when at the last line of this code -

final status = await FlutterOverlayWindow.isPermissionGranted();

if (status) {
  await FlutterOverlayWindow.showOverlay(
    alignment: OverlayAlignment.bottomCenter,
    overlayTitle: "Call Ended",
    visibility: NotificationVisibility.visibilitySecret,
    overlayContent: "Call ended with $number",
  );

  await FlutterOverlayWindow.resizeOverlay(80, 120);

Working with this dependency -

  flutter_overlay_window:
    git:
      url: https://github.com/X-SLAYER/flutter_overlay_window.git
      ref: FULL_SCREEN

It has the same result on latest pub version

bubble freezes

sometimes the bubble in the messenger chat head freezes and does not open when I click on it shows me this line at the console

performTraversals mFirst=false windowShouldResize=false viewVisibilityChanged=false mForceNextWindowRelayout=false params={(486,962)(82x82) gr=CENTER sim={adjust=pan} ty=APPLICATION_OVERLAY fmt=TRANSLUCENT

does this support multiple overlay windows?

I need two different overlay windows for my app, currently i had one that is working fine, but i want to show 2nd window that is related to other feature of my app. can i do following for 2nd overlay as i had done for the first overlay. If can do so, how the code differentiate between two windows.

// overlay entry point
@pragma("vm:entry-point")
void overlayMain() {
  runApp(const MaterialApp(
    debugShowCheckedModeBanner: false,
    home: Material(child: Text("My overlay"))
  ));
}

or i had to change the child of Material widget to display other widget as overlay . This means i technically have only have one overlay whose content is changed.

I looked into flutter_floatwing plugin also but i can't able to understand that their example was unnecessarily complex. But they use id pram to differentiate between multiple windows.
There is also another one called system_alert_window but that give less options to customize the window

if anyone had implemented 2-3 different window please comment down any demo code or any info you can provide me.

when close, the app crash

hey:
when i close the window with: FlutterOverlayWindow.closeOverlay();
the app will be crash, get log:

E/flutter (23445): [ERROR:flutter/fml/platform/android/jni_util.cc(204)] java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.view.ViewParent.requestSendAccessibilityEvent(android.view.View, android.view.accessibility.AccessibilityEvent)' on a null object reference
E/flutter (23445): at io.flutter.view.AccessibilityBridge.sendAccessibilityEvent(AccessibilityBridge.java:1908)
E/flutter (23445): at io.flutter.view.AccessibilityBridge.sendWindowContentChangeEvent(AccessibilityBridge.java:1967)
E/flutter (23445): at io.flutter.view.AccessibilityBridge.updateSemantics(AccessibilityBridge.java:1719)
E/flutter (23445): at io.flutter.view.AccessibilityBridge$1.updateSemantics(AccessibilityBridge.java:345)
E/flutter (23445): at io.flutter.embedding.engine.FlutterJNI.updateSemantics(FlutterJNI.java:762)
E/flutter (23445): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (23445): at android.os.MessageQueue.next(MessageQueue.java:374)
E/flutter (23445): at android.os.Looper.loopOnce(Looper.java:163)
E/flutter (23445): at android.os.Looper.loop(Looper.java:293)
E/flutter (23445): at android.app.ActivityThread.main(ActivityThread.java:9551)
E/flutter (23445): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (23445): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:586)
E/flutter (23445): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1204)
E/flutter (23445):
F/flutter (23445): [FATAL:flutter/shell/platform/android/platform_view_android_jni_impl.cc(1233)] Check failed: fml::jni::CheckException(env).

any i will atention?

Resize Overlay is not working

Hi there,

Unable to use the feature of resize overlay

D/EGL_emulation(13076): app_time_stats: avg=6515.98ms min=6515.98ms max=6515.98ms count=1
E/flutter (13076): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method resizeOverlay on channel x-slayer/overlay)
E/flutter (13076): #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:165:7)
E/flutter (13076): <asynchronous suspension>
E/flutter (13076): #1      FlutterOverlayWindow.resizeOverlay (package:flutter_overlay_window/flutter_overlay_window.dart:110:24)
E/flutter (13076): <asynchronous suspension>
E/flutter (13076): #2      _MessangerChatHeadState.resize (package:flutter_overlay_window_example/overlays/messanger_chathead.dart:21:5)
E/flutter (13076): <asynchronous suspension>
E/flutter (13076): 

This was the code changes which I did

class MessangerChatHead extends StatefulWidget {
  const MessangerChatHead({Key? key}) : super(key: key);

  @override
  State<MessangerChatHead> createState() => _MessangerChatHeadState();
}

class _MessangerChatHeadState extends State<MessangerChatHead> {
  Color color = const Color(0xFFFFFFFF);

  @override
  void initState() {
    super.initState();
    resize();
  }

  resize() async{
    await FlutterOverlayWindow.resizeOverlay(80, 120);
  }

  @override
  Widget build(BuildContext context) {
    return Material(
        color: Colors.transparent,
        elevation: 0.0,
        child: FloatingActionButton(
          elevation: 0,

          splashColor: Colors.transparent,
          child: const Text('02:00'),
          onPressed: () {
          FlutterOverlayWindow.closeOverlay();
        },)
    );
  }
}

Admob view blank

I add google_mobile_ads but banner only show white
D/EgretLoader(29530): EgretLoader(Context context)
D/EgretLoader(29530): The context is not activity
E/flutter (29530): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method create on channel flutter/platform_views)
E/flutter (29530): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:294:7)
E/flutter (29530):
E/flutter (29530): #1 TextureAndroidViewController._sendCreateMessage (package:flutter/src/services/platform_views.dart:1146:18)
E/flutter (29530):
E/flutter (29530): #2 AndroidViewController.create (package:flutter/src/services/platform_views.dart:792:5)
E/flutter (29530):

Displaying overlay when the app is closed

Hi, I want to show the overlay when the main app is closed and a new incmoing call is received. I have created a BroadcastReceiver which keeps running when the app is closed. On receiving a new call, it calls a background callback when the is closed. In this callback I am calling FlutterOverlayWindow.showOverlay. The callback works fine when the app is closed, I have done some print to show this. However when the app is closed, it gives me the following error

app is in background uid UidRecord{c767979 u0a588 CEM  idle change:cached procs:0 seq(0,0,0)}, null, android.app.BackgroundServiceStartNotAllowedException: Not allowed to start service Intent

Upon investigating the matter further, I found out https://stackoverflow.com/a/47654126/1671807 and applied the following changes in FlutterOverlayWindowPlugin.onMethodCall

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        context.startForegroundService(intent);
} else {
        context.startService(intent);
}

But now I am getting the following error

E/AndroidRuntime(20853): java.lang.RuntimeException: Unable to create service flutter.overlay.window.flutter_overlay_window.OverlayService: java.lang.NullPointerException: Attempt to invoke virtual method 'io.flutter.embedding.engine.dart.DartExecutor io.flutter.embedding.engine.FlutterEngine.getDartExecutor()' on a null object reference
E/AndroidRuntime(20853): 	at android.app.ActivityThread.handleCreateService(ActivityThread.java:4701)
E/AndroidRuntime(20853): 	at android.app.ActivityThread.access$100(ActivityThread.java:258)
E/AndroidRuntime(20853): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2230)
E/AndroidRuntime(20853): 	at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(20853): 	at android.os.Looper.loopOnce(Looper.java:233)
E/AndroidRuntime(20853): 	at android.os.Looper.loop(Looper.java:344)
E/AndroidRuntime(20853): 	at android.app.ActivityThread.main(ActivityThread.java:8204)
E/AndroidRuntime(20853): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(20853): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:589)
E/AndroidRuntime(20853): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1071)
E/AndroidRuntime(20853): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'io.flutter.embedding.engine.dart.DartExecutor io.flutter.embedding.engine.FlutterEngine.getDartExecutor()' on a null object reference
E/AndroidRuntime(20853): 	at flutter.overlay.window.flutter_overlay_window.OverlayService.<init>(OverlayService.java:37)
E/AndroidRuntime(20853): 	at java.lang.Class.newInstance(Native Method)
E/AndroidRuntime(20853): 	at android.app.AppComponentFactory.instantiateService(AppComponentFactory.java:129)
E/AndroidRuntime(20853): 	at androidx.core.app.CoreComponentFactory.instantiateService(CoreComponentFactory.java:75)
E/AndroidRuntime(20853): 	at android.app.ActivityThread.handleCreateService(ActivityThread.java:4670)
E/AndroidRuntime(20853): 	... 9 more

I am not sure how to solve this. Can you please help?

Bugs (Gravity + Drag inversion)

Good work. Thanks for your contribution.

Alignment enum bugs exist where drag direction is inverted on horizontal, vertical or both axis depending on alignment:

TopLeft=OK
CenterLeft=OK
BottomLeft = Vertical drag axis inverted.
TopCenter = OK
Center = OK
BottomCenter = Vert drag axis inverted
TopRight = Horizontal drag inverted
CenterRight = Horizontal drag inverted
BottomRight = Both drag axis inverted.

I'm not a Java programmer but your ACTION_MOVE switch statement seems to look fine, and obviously works fine gravity set to center etc. It is a weird gravity issue, possibly a bug between window manager and the flutterview? Out of my depth sorry.

To rectify in the short term in your onTouch method if you can't find the cause :
int xx = params.x + (int) dx; (subtract dx instead on problematic right gravity)
int yy = params.y + (int) dy; (subtract dx instead on problematic bottom gravity)

Also there is a screen dims / vertical centering issue. If you pass a full screen colored container from flutter you might see the screen centering too far north, off the screen and padded at the bottom. NavBar size calculation issue??

close error

Hi

I try to close overlay.
but I got some issue..

please help me!
thanks.

error

[debug]
E/flutter (25852): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method close on channel x-slayer/overlay_channel)
E/flutter (25852): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:294:7)
E/flutter (25852):
E/flutter (25852): #1 FlutterOverlayWindow.closeOverlay (package:flutter_overlay_window/flutter_overlay_window.dart:83:24)
E/flutter (25852):
E/flutter (25852):

can't close overlay_window

Hi,

overlay_windows run perfectly fine, but I can't close overlay_window.

E/flutter (15267): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method close on channel x-slayer/overlay) E/flutter (15267): #0 MethodChannel._invokeMethod E/flutter (15267): <asynchronous suspension> E/flutter (15267): #1 FlutterOverlayWindow.closeOverlay E/flutter (15267): <asynchronous suspension> E/flutter (15267): #2 _HomePageState.build.<anonymous closure> E/flutter (15267): <asynchronous suspension> E/flutter (15267):

MissingPluginException on close overlay / non-transparent clickthrough / overlay over system bars

Hello, I have an issue and 2 questions.

The issue: On trying to close the overlay I get this error:
E/flutter ( 5856): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method close on channel x-slayer/overlay) E/flutter ( 5856): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:294:7) E/flutter ( 5856): <asynchronous suspension> E/flutter ( 5856): #1 FlutterOverlayWindow.closeOverlay (package:flutter_overlay_window/flutter_overlay_window.dart:83:24) E/flutter ( 5856): <asynchronous suspension> E/flutter ( 5856): [log] Try to close
Question 1:
Is there a way to make the overlay, when set to clickthrough, non-transparent? Right now whenever I set it to clickthrough it becomes semi transparent.

Question 2:
Is there a way to overlay the content above the system navigation bar or statusbar? Right now I'm only able to position it as if there was a safe area around it.

Thank you in advance!

Need to set only Messenger Chat Head for Overlay

I need to set only Messenger Chat Head... How can I do it??, because when I open the overlay, at first, it covers the entire screen... and then when I tap once, it becomes like a chat head...

Also, how can I open the APP by clicking on the overlay??

Kindly suggest me best ways to implement my two conditions!!

Thanks in Advance...

The overlay window is transparent when released apk

KakaoTalk_20220512_013413299

Hello!
First, Thank you for developing the plugin.
I have built the apk example of the plugin, but the overlay window is not visible.
It's like Transparent. Can't touch between the red lines.
Do you know how to solve it?

My device is Galaxy S22

KakaoTalk_20220512_013413299

Possible to call from an isolate?

I am using Android Alarm Manager Plus to start an isolate at a fixed time. Now I want to call the overlay from that isolate. So far, I am not seeing any overlay, or any related error messages. My other audio code in the isolate is working though.

Entry point for isolate called by Android Alarm Manager Plus:

@pragma('vm:entry-point')
void ringAlarm() async {
  var alarms = await FlutterSystemRingtones.getAlarmSounds();
  final DateTime now = DateTime.now();
  final player = AudioPlayer();
  await player.setAudioSource(AudioSource.uri(Uri.parse(alarms[0].uri)));
  player.play();

  await FlutterOverlayWindow.showOverlay();

  FlutterOverlayWindow.overlayListener.listen((event) {
    if (event == "dismiss") {
      FlutterOverlayWindow.closeOverlay();
      player.stop();
    }
  });
}

Entry point for overlay:

@pragma("vm:entry-point")
void overlayMain() {
  runApp(
    MaterialApp(
        home: Scaffold(
          body: TextButton(
            onPressed: () async {
              await FlutterOverlayWindow.shareData("dismiss");
            },
            child: const Text("Dismiss"),
          ),
        )),
  );
}

Is it even possible?

flutter_overlay_window: ^0.3.3

FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.

When I run the example app I get the following error
java.lang.RuntimeException: Unable to create service flutter.overlay.window.flutter_overlay_window.OverlayService: java.lang.IllegalArgumentException: com.example.flutter_overlay_window_example: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. E/AndroidRuntime(17128): Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.

It seems that in onCreate method of OverlayService, one needs to pass PendingIntent.FLAG_IMMUTABLE while creating the pending intent.

And also how to show some animation when showing the overlay. Right now it just pops up. It would be nice if there is some nice configurable animation.

Sharing data from foreground service

The opening and closing of overlay works flawlessly , the data sharing also works when app is open and foreground service is running but when app get closed the data sharing doesn't work and the

FlutterOverlayWindow.shareData()

returns null,
it does not causes any error,

could you point me in direction why this is happening, does it had to do something with the app isolate .

close overlay

How to automatically close the overlay by clicking on outside overlay

await FlutterOverlayWindow.resizeOverlay(80, 120); is not working

Hi @X-SLAYER resizing the overlay widget is not working as expected. If we resize the UI component with specific height and width it leads to overflow pixel issues, as the UI was changing at the Run Time instead of compile. But if, we use match_parent for both height and width without having any content in the UI. For instance, Container with match_parent for both height and width. It was working fine.

But not for Container having another Row or Column of widgets. It's not working perfectly.

How to send data from the app to the overlay widget.

Hi there,

I want to send some data from the app to the overlay button. For ex: Overlay chat head is having a text which can present the timer value. So, after enabling the overlay. I want to run the timer in the app, and the same data should reflect on the chat head as well. Please do help me on the same asap.

Is it possible show overlay_window without flutter app?

Hi.

I are developing the Auto send SMS/MMS after call with flutter.

I want to develop like this.

  1. Open flutter_overlay_window after end of call.
  2. Select sms/mms saved.
  3. Send.
    Only SMS/MMS setting in the Flutter App.

Currently,

  1. Checking end of call by Android reciver.
  2. Sharing inform of call by FlutterOverlayWindow.shareData
  3. FlutterOverlayWindow.showOverlay

But, It works good before Flutter App closed.
It only works for a few minutes after the Flutter App closed.

Should I develop it by a native Android?

click not working

i have folow code like sample but created a bug this.`void main() {
runApp(const MyApp());
}

@pragma("vm:entry-point")
void overlayMain() {
runApp(
const MaterialApp(
debugShowCheckedModeBanner: false,
home: OverlayScreen(),
),
);
}
`

and overlays
@override Widget build(BuildContext context) { return Material( color: Colors.transparent, child: Center( child: Container( height: 100, padding: const EdgeInsets.symmetric(vertical: 12.0), decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomRight, colors: isGold ? _goldColors : _silverColors, ), borderRadius: BorderRadius.circular(12.0), ), child: Container( child: Column( children: [ ElevatedButton( onPressed: () async { print("click button share "); await FlutterOverlayWindow.shareData(" data from Overlays"); }, child: const Text("Share data")) ], ), ), ), ), ); } }

Error with context differences state(Very Need a help)

Error : When you open overlay_windown and terminal the app , and open again (the overlay still run in background but i can not cancel Timer ().
Screen Shot 2022-10-28 at 08 44 49.

Screen Shot 2022-10-28 at 08 47 13

Screen Shot 2022-10-28 at 08 48 59

Steps to Reproduce :
Download example in Git and add Timer in initState like code below
Screen Shot 2022-10-28 at 08 54 22
in Home Page
Screen Shot 2022-10-28 at 08 54 54

Run the app , and open overlay windown . => terminate app (kill the app by swipe)
=>Open app and Click Close Timer .

Thanks you .

Method channel calls inside the OverlayService class is not working.

Hi there,

Method channel calls inside the OverlayService class is not working.

E/flutter (14596): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method updateFlag on channel x-slayer/overlay)
E/flutter (14596): #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:165:7)
E/flutter (14596): <asynchronous suspension>
E/flutter (14596): #1      FlutterOverlayWindow.updateFlag (package:flutter_overlay_window/flutter_overlay_window.dart:103:24)
E/flutter (14596): <asynchronous suspension>
E/flutter (14596): 

Clipboard.setData it does not work

Hello,
I am trying to copy a text that appears in the overlay but it is not copied using
Clipboard.setData(ClipboardData(text: "your text"));

My code to start the overlay is as follows
await FlutterOverlayWindow.showOverlay( width: 150, height: 691, //765, enableDrag: false, overlayTitle: t.generals.notify.overlays.title, overlayContent: t.generals.notify.overlays.description, flag: OverlayFlag.defaultFlag, alignment: OverlayAlignment.centerRight, visibility: NotificationVisibility.visibilityPublic, positionGravity: PositionGravity.auto, );

resizeOverlay can't find method channel

/// Update the overlay size in the screen
await FlutterOverlayWindow.resizeOverlay(80, 120);

hey, above method is not support? or a bug?
wish to get reply, ths.

After opening overlay, unable to call any method to execute

I've a periodic method to update location... it works fine when the app is opened... but after the overlay is opened by minimizing or closing the app, that method is not working... any suggestion to execute a method periodically, for like 10 seconds once, when the overlay is opened...

Thanks in Advance...

Showing overlay from background

Thanks for this awesome package!

I had no problem showing/closing an overlay when the app is in the foreground or paused. But, in my use case, I attempted to show an overlay from a background task (workmanager). And I got the java.lang.IllegalStateException: Not allowed to start service Intent exception.

Logs
...
Background start not allowed: service Intent { flg=0x30000000 cmp=com.example.overlay_test/flutter.overlay.window.flutter_overlay_window.OverlayService } to com.example.overlay_test/flutter.overlay.window.flutter_overlay_window.OverlayService from pid=10481 uid=10125 pkg=com.example.overlay_test startFg?=false

Failed to handle method call
    java.lang.IllegalStateException: Not allowed to start service Intent { flg=0x30000000 cmp=com.example.overlay_test/flutter.overlay.window.flutter_overlay_window.OverlayService }: app is in background uid UidRecord{4e22f0e u0a125 CEM  idle change:cached procs:1 seq(0,0,0)}
        at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1715)
        at android.app.ContextImpl.startService(ContextImpl.java:1670)
        at android.content.ContextWrapper.startService(ContextWrapper.java:720)
        at flutter.overlay.window.flutter_overlay_window.FlutterOverlayWindowPlugin.onMethodCall(FlutterOverlayWindowPlugin.java:99)
        at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
        at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
        at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
        at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

errorCode: error, errorMessage: Not allowed to start service Intent { flg=0x30000000 cmp=com.example.overlay_test/flutter.overlay.window.flutter_overlay_window.OverlayService }: app is in background uid UidRecord{4e22f0e u0a125 CEM  idle change:cached procs:1 seq(0,0,0)}
...

Now I have zero experience with Java but as a programmer, I just took the error and pasted it onto google. After going through some stackoverflows I found out that the IntentService used here -

final Intent intent = new Intent(context, OverlayService.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
context.startService(intent);

is deprecated and not allowed above Android 8.0 when the app is in background, or something along those lines.

As for fixes, I found that the new JobScheduler can be used or the service can be moved to foreground context.startForegroundService(intent);. Of course, I'm not familiar with the internals that's why I can't tell which parts need to be affected after applying the above fixes.

If possible, please address the issue. Else, if possible, please provide me some helpers/pointers on the subject so that I can work on the same.

can't change start tip logo

hey, the product is good.
just when i use FlutterOverlayWindow.showOverlay to show the overlay window in my pixel 2 phone,
it will pop the tip, and the tip have a logo,not my app logo, it's the flutter default logo,
can i have a method to change the logo or not to pop the tip.
have a good day, ths.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.