Home | History | Annotate | Download | only in docs
      1 # Defining constants as part of an interface
      2 
      3 AIDL has been enhanced to support defining integer and string constants
      4 as part of an interface.
      5 
      6 ## Integer constants
      7 
      8 ```
      9 interface IMyInterface {
     10     const int CONST_A = 1;
     11     const int CONST_B = 2;
     12     const int CONST_C = 3;
     13     ...
     14 }
     15 ```
     16 
     17 These map to appropriate 32 bit integer class constants in Java and C++ (e.g.
     18 `IMyInterface.CONST_A` and `IMyInterface::CONST_A` respectively).
     19 
     20 ## String constants
     21 
     22 ```
     23 interface IMyInterface {
     24     const String CONST_A = "foo";
     25     const String CONST_B = "bar";
     26     ...
     27 }
     28 ```
     29 
     30 These map to class level String constants in Java, and static getter
     31 functions that return a const android::String16& in C++.
     32 
     33 The constants are limited to contain printable ASCII characters < 0x10
     34 and without backspaces (i.e. no '\' character).
     35 
     36