I want to get xml in a service and return that xml-string via AIDL. Today, I realized that the calling app receives only a null-value when this string is very long. I tested a bit and found, that the limit for the string-length seems to be about 520000 characters, which is near 512*1024=524288. Java stores strings internally as UTF-16 and I think, but I’m not sure, that each character is internally (at least) two bytes big, so this limit would be at 1MB.
Now, I want to know if this limit is documented anywhere or if anyone had problems with it before. Does anyone know how I can easily return such big strings?
AFAIK, it is not formally documented, but there is a ~1MB limit on the contents of an IPC call, no matter how that is accomplished (AIDL, broadcast
Intent, etc.) or what the data is (string, bitmap, other form of byte array, etc.).Use a file. If you wish, serve the file via a
ContentProviderandopenFile(), supplying theUrito the content in the AIDL response.