Open ducviet321 opened 1 month ago
Hi @ducviet321 , Im very interested in your idea / implementation, could not make it work, could you please explain a little more. The file you are referencing is: OverlayService.java? In wich line did you add your code? Do you need to do something else beside calling it as you said?
Thanks in advance!
@macdo-py First you need to find your app namespace (maybe in android/app/src/main/kotlin/com/example/myapp/MainActivity.kt
)
In /lib/src/overlay_window.dart
add to class FlutterOverlayWindow
static Future<bool?> openMainApp() async {
final bool? _res = await _overlayChannel.invokeMethod<bool?>('openMainApp');
return _res;
}
in android/src/main/java/flutter/overlay/window/flutter_overlay_window/OverlayService.java
Find flutterChannel.setMethodCallHandler((call, result) -> {
and add below
} else if (call.method.equals("resizeOverlay")) {
...
} else if (call.method.equals("openMainApp")) {
Intent intent = new Intent();
intent.setClassName("com.vitinc. myapp", "com.vitinc.myapp.MainActivity");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
@ducviet321 thank you so much for your help!!! it worked but I hag to remove the line
Intent intent = new Intent();
And also, I'd like to know why you added a space in your app namespace, was it a typo o it should be like that.
Thanks again and best regards!
Yeah it was my typo, maybe be you should rename intent variable instead of removing it, I haven't looked, just try to make it work quickly
I'm looking for a better solution to open the main application from the floating window, right now I'm only able to archive this by modifying
OverlayServices.java
and call it asFlutterOverlayWindow.openMainApp();