简体   繁体   English

如何在 android 中将 function 作为 prop 传递给 aar

[英]how to pass function as prop to aar in android

I develop the flutter package and in this package one of class get function argument.我开发了 flutter package 并在此 package class 之一得到 function 参数。 When I use this package in another flutter app, I can send function as prop to this package.当我在另一个 flutter 应用程序中使用这个 package 时,我可以将 function 作为 prop 发送给这个 package。

Now I just want to learn if I use the flutter module and build the aar, how can I send function as prop in native android?现在我只想了解如果我使用 flutter 模块并构建 aar,我如何在原生 android 中将 function 作为 prop 发送?

Thanks谢谢

This is not possible because you can send only serializable types这是不可能的,因为您只能发送可序列化类型

By default, AIDL supports the following data types:默认情况下,AIDL 支持以下数据类型:

  • All primitive types in the Java programming language (such as int, long, char, boolean, and so on) Java编程语言中的所有原始类型(如int、long、char、boolean等)
  • Arrays of primitive types such as int[] Arrays 原始类型如 int[]
  • String细绳
  • CharSequence字符序列
  • List列表
    All elements in the List must be one of the supported data types in this list or one of the other AIDL-generated interfaces or parcelables you've declared. List 中的所有元素必须是此列表中受支持的数据类型之一,或者是您声明的其他 AIDL 生成的接口或 parcelables 之一。 A List may optionally be used as a parameterized type class (for example, List).可以选择将列表用作参数化类型 class(例如,列表)。 The actual concrete class that the other side receives is always an ArrayList, although the method is generated to use the List interface.对方收到的实际具体 class 始终是一个 ArrayList,尽管该方法是使用 List 接口生成的。
  • Map. Map。
    All elements in the Map must be one of the supported data types in this list or one of the other AIDL-generated interfaces or parcelables you've declared. Map 中的所有元素必须是此列表中受支持的数据类型之一,或者是您声明的其他 AIDL 生成的接口或 parcelables 之一。 Parameterized type maps, (such as those of the form Map<String,Integer>) are not supported.不支持参数化类型映射(例如 Map<String,Integer> 形式的映射)。 The actual concrete class that the other side receives is always a HashMap, although the method is generated to use the Map interface.对方收到的实际具体class始终是HashMap,虽然生成方法是使用Map接口。 Consider using a Bundle as an alternative to Map.考虑使用 Bundle 作为 Map 的替代方案。

For more detailed information you can refer to the official AIDL documentation更详细的信息可以参考AIDL官方文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM