Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open the main app from floating window? #108

Open
ducviet321 opened this issue Apr 7, 2024 · 8 comments
Open

Open the main app from floating window? #108

ducviet321 opened this issue Apr 7, 2024 · 8 comments

Comments

@ducviet321
Copy link

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 as FlutterOverlayWindow.openMainApp();

    private void openMainApp() {
        Intent intent = new Intent();
        intent.setClassName("com.vitinc.myapp", "com.vitinc.myapp.MainActivity");
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
    }
@macdo-py
Copy link

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!

@ducviet321
Copy link
Author

ducviet321 commented Apr 16, 2024

@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);
            }

@macdo-py
Copy link

@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!

@ducviet321
Copy link
Author

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

@icanall10
Copy link

use https://pub.dev/packages/android_intent_plus with app links

@selvam920
Copy link

@icanall10 can you share example to open the app using android_intent_plus?

@icanall10
Copy link

icanall10 commented Aug 24, 2024

@selvam920 you should pre-configure app_links and then run

AndroidIntent intent = AndroidIntent(
      action: 'action_view',
      data: 'your-app-link-schema://your-app-link-host/some-path',
);

await intent.launch();

@selvam920
Copy link

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants