使用 FlutterFragmentActivity 在 Flutter 中进行深度链接

发布于 2025-01-09 21:23:30 字数 1140 浏览 1 评论 0原文

我有一个连接到 ChromeCast 的 Straming 应用程序。

它使用这个包来处理连接: https://github.com/samyakkkk/flutter_video_cast

它需要使用 FlutterFragmentActivity 才能正常连接,但是,如果我使用它,我就失去了深度链接的能力。如果我需要使用 FlutterFragmentActivity 我怎样才能成功?

这是使 Chromecast 工作但破坏 DeepLinking 的代码:

    class MainActivity : FlutterFragmentActivity() {

    override fun provideFlutterEngine(context: Context): FlutterEngine? {
        return AudioServicePlugin.getFlutterEngine(context)
    }
    
    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        GeneratedPluginRegistrant.registerWith(flutterEngine)
        provideFlutterEngine(applicationContext)
    }
}

这是使 DeepLinking 工作但破坏 ChromeCast 连接的代码:

    class MainActivity : FlutterActivity() {
    override fun provideFlutterEngine(context: Context): FlutterEngine? {
        configureFlutterEngine(FlutterEngine(applicationContext))
        return AudioServicePlugin.getFlutterEngine(context)
    }
}

我需要使用“AudioServicePlugin”来播放音频,因此还需要设置此行。

I have an Straming app that connects to ChromeCast.

It uses this package to handle the connection:
https://github.com/samyakkkk/flutter_video_cast

It needs to use FlutterFragmentActivity so the connection can work, but, if i use it, i lose the hability to DeepLinking. How can i succed in this if i need to use FlutterFragmentActivity?

Here is the code that makes Chromecast Work but breaks DeepLinking:

    class MainActivity : FlutterFragmentActivity() {

    override fun provideFlutterEngine(context: Context): FlutterEngine? {
        return AudioServicePlugin.getFlutterEngine(context)
    }
    
    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        GeneratedPluginRegistrant.registerWith(flutterEngine)
        provideFlutterEngine(applicationContext)
    }
}

Here is the code that DeepLinking works but breaks the ChromeCast connection:

    class MainActivity : FlutterActivity() {
    override fun provideFlutterEngine(context: Context): FlutterEngine? {
        configureFlutterEngine(FlutterEngine(applicationContext))
        return AudioServicePlugin.getFlutterEngine(context)
    }
}

I need to use "AudioServicePlugin" for playing audio, so this line need to be set also.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文