可以在Flutter中的另一个应用中调用平台通道吗?

huangapple go评论86阅读模式
英文:

Can i call platform channel from another app in flutter?

问题

我正在Flutter中开发一个应用程序,我想使用一个在Flutter中不可用的SDK,他们有一个用Java编写的示例项目。我想将该项目集成到我的当前Flutter应用程序中,是否可以使用平台通道来完成?

我在Android原生方面的经验非常有限,所以我几乎无法理解那个项目。

提前感谢。

英文:

I am developing an app in flutter and I want to use an SDK which isn't available for flutter and they have a sample project which is written in java (android native) and I want to integrate that app to my current flutter app, is that possible to be done with platform channels?

My experience in the android native is very weak so I almost can pick up with that project.

Thanks in advance,

答案1

得分: 1

可以的。这是你自己的应用,不是另一个应用。而且这不是必需的,但Android Studio会帮助你。

你需要修改你的Flutter项目的/android项目。你需要实现所需的SDK,并复制/粘贴/重构相关的示例代码。然后,你可以通过方法通道将这些代码暴露给Flutter一侧。要了解如何操作,阅读此文档

重要提示:热重启不会更新原生代码。每次要应用原生代码更改时,你都需要重新编译。

英文:

Yes, you can. It's your own app though, not another one. And it's not necessary, but Android Studio will help you.

You have to modify the /android project of your Flutter project. You need to implement the SDK in question, and copy/paste/refactor the relevant sample code. You can then expose this code to the Flutter side via a method channel. To learn how, read this doc.

Important : Hot Restart will not update native code. You have to recompile everytime you want to apply native code changes.

huangapple
  • 本文由 发表于 2020年8月10日 05:34:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/63331558.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定