diff --git a/lexactivator/src/main/java/com/cryptlex/android/lexactivator/LexActivator.java b/lexactivator/src/main/java/com/cryptlex/android/lexactivator/LexActivator.java index 74ee5f0..f4e0c23 100644 --- a/lexactivator/src/main/java/com/cryptlex/android/lexactivator/LexActivator.java +++ b/lexactivator/src/main/java/com/cryptlex/android/lexactivator/LexActivator.java @@ -659,15 +659,19 @@ public static FeatureEntitlement GetFeatureEntitlement(String featureName) throw * @throws UnsupportedEncodingException */ public static String GetLicenseMetadata(String key) throws LexActivatorException, UnsupportedEncodingException { - int status; - - ByteBuffer buffer = ByteBuffer.allocate(256); - status = LexActivatorNative.GetLicenseMetadata(key, buffer, 256); + int bufferSize = 256; + while (bufferSize <= 4096) { + ByteBuffer buffer = ByteBuffer.allocate(bufferSize); + int status = LexActivatorNative.GetLicenseMetadata(key, buffer, bufferSize); if (LA_OK == status) { return new String(buffer.array(), "UTF-8").trim(); } - - throw new LexActivatorException(status); + if (status != LexActivatorException.LA_E_BUFFER_SIZE) { + throw new LexActivatorException(status); + } + bufferSize *= 2; + } + throw new LexActivatorException(LexActivatorException.LA_E_BUFFER_SIZE); } /**