test.aidl文件
interface test{
const int i = 1;
const String s = "test";
}
编译后自动生成的java文件test.java,里面的定义为:
//忽略前面的方法
public static final int i= 1;
public static final String s= "test";
但是aidl文件里面只能定义这两种,原话来自于https://developer.android.com/guide/components/aidl,
- String and int constants can be defined in the AIDL interface. For example:
const int VERSION = 1;(好像只有看英文版的才能看到这句话)
意思就是只有String和int类型可以定义常量。
本文探讨了Android接口定义语言(AIDL)中常量定义的限制,指出仅能定义String和int类型的常量,并提供了具体的示例代码。通过对比AIDL文件与自动生成的Java文件,阐明了这一限制的具体实现。

1万+

被折叠的 条评论
为什么被折叠?



