Public Sub GetUniqueID As String
Try
Dim jo As JavaObject = Me
Dim ID As String = jo.RunMethod("getUniqueID", Null)
Log(ID)
Return ID
Catch
Return ""
End Try
End Sub
#If Java
import android.media.MediaDrm;
import android.os.Build;
import android.content.*;
import java.util.*;
//private final Context context;
private String initialVal = "";
public String getUniqueID() {
UUID wideVineUuid = new UUID(-0x121074568629b532L, -0x5c37d8232ae2de13L);
try {
MediaDrm wvDrm = new MediaDrm(wideVineUuid);
byte[] wideVineId = wvDrm.getPropertyByteArray(MediaDrm.PROPERTY_DEVICE_UNIQUE_ID);
Base64.Encoder enc = Base64.getEncoder();
String encodedUid = enc.encodeToString(wideVineId);
return encodedUid;
} catch (Exception e) {
return "";
}
}
#End If
OK, ChatGPT says the below, but it's solution was confusing, so I won't post it. But basically it is saying:
The issue you're encountering seems to stem from the fact that NoClassDefFoundError and ClassCastException are not standard Exception types in Java—they are Error and RuntimeException, respectively. In Java (and B4A as well), the Catch block only catches exceptions that are instances of java.lang.Exception and not java.lang.Error.
Going to add this code to check for Kindles before the call
B4X:
Dim InstalledFrom As String = cGenFuncs.GetInstallerPackageName
InstalledFrom = InstalledFrom.ToLowerCase
If InstalledFrom.Contains("amazon") Then
Log("Kindle Fire")
Return "Kindle Fire"
End If
Dim R As Reflector
Dim Temp As String = r.GetStaticField("android.os.Build", "MODEL")
If Temp.StartsWith("KF") Then
Log("Kindle Fire")
Return "Kindle Fire"
End If
This should get this user up and running - don't know if I have many kindle users I'm NOT in the Amazon store